mirror of
https://github.com/coolsnowwolf/lede
synced 2025-01-07 07:46:47 +08:00
build: introduce PKG_BUILD_FLAGS
This commit is contained in:
parent
4561705e1b
commit
0186d52076
@ -152,6 +152,21 @@ menu "Global build settings"
|
||||
default n
|
||||
help
|
||||
Adds -g3 to the CFLAGS.
|
||||
|
||||
config USE_GC_SECTIONS
|
||||
bool
|
||||
prompt "Dead code and data elimination for all packages (EXPERIMENTAL)"
|
||||
help
|
||||
Places functions and data items into its own sections to use the linker's
|
||||
garbage collection capabilites.
|
||||
Packages can choose to opt-out via setting PKG_BUILD_FLAGS:=no-gc-sections
|
||||
|
||||
config USE_LTO
|
||||
bool
|
||||
prompt "Use the link-time optimizer for all packages (EXPERIMENTAL)"
|
||||
help
|
||||
Adds LTO flags to the CFLAGS and LDFLAGS.
|
||||
Packages can choose to opt-out via setting PKG_BUILD_FLAGS:=no-lto
|
||||
|
||||
config IPV6
|
||||
def_bool y
|
||||
|
@ -11,8 +11,6 @@ include $(INCLUDE_DIR)/download.mk
|
||||
PKG_BUILD_DIR ?= $(BUILD_DIR)/$(if $(BUILD_VARIANT),$(PKG_NAME)-$(BUILD_VARIANT)/)$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
|
||||
PKG_INSTALL_DIR ?= $(PKG_BUILD_DIR)/ipkg-install
|
||||
PKG_BUILD_PARALLEL ?=
|
||||
PKG_USE_MIPS16 ?= 1
|
||||
PKG_IREMAP ?= 1
|
||||
PKG_SKIP_DOWNLOAD=$(USE_SOURCE_DIR)$(USE_GIT_TREE)$(USE_GIT_SRC_CHECKOUT)
|
||||
|
||||
MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j))
|
||||
@ -24,17 +22,52 @@ PKG_JOBS?=-j1
|
||||
else
|
||||
PKG_JOBS?=$(if $(PKG_BUILD_PARALLEL),$(MAKE_J),-j1)
|
||||
endif
|
||||
ifdef CONFIG_USE_MIPS16
|
||||
ifeq ($(strip $(PKG_USE_MIPS16)),1)
|
||||
TARGET_ASFLAGS_DEFAULT = $(filter-out -mips16 -minterlink-mips16,$(TARGET_CFLAGS))
|
||||
TARGET_CFLAGS += -mips16 -minterlink-mips16
|
||||
endif
|
||||
|
||||
PKG_BUILD_FLAGS?=
|
||||
# TODO remove this when all packages moved to PKG_BUILD_FLAGS=no-mips16
|
||||
PKG_USE_MIPS16?=1
|
||||
ifneq ($(strip $(PKG_USE_MIPS16)),1)
|
||||
PKG_BUILD_FLAGS+=no-mips16
|
||||
endif
|
||||
ifeq ($(strip $(PKG_IREMAP)),1)
|
||||
|
||||
__unknown_flags=$(filter-out no-iremap no-mips16 gc-sections no-gc-sections lto no-lto no-mold,$(PKG_BUILD_FLAGS))
|
||||
ifneq ($(__unknown_flags),)
|
||||
$(error unknown PKG_BUILD_FLAGS: $(__unknown_flags))
|
||||
endif
|
||||
|
||||
# $1=flagname, $2=default (0/1)
|
||||
define pkg_build_flag
|
||||
$(if $(filter no-$(1),$(PKG_BUILD_FLAGS)),0,$(if $(filter $(1),$(PKG_BUILD_FLAGS)),1,$(2)))
|
||||
endef
|
||||
|
||||
ifeq ($(call pkg_build_flag,iremap,1),1)
|
||||
IREMAP_CFLAGS = $(call iremap,$(PKG_BUILD_DIR),$(notdir $(PKG_BUILD_DIR)))
|
||||
TARGET_CFLAGS += $(IREMAP_CFLAGS)
|
||||
endif
|
||||
|
||||
ifdef CONFIG_USE_MIPS16
|
||||
ifeq ($(call pkg_build_flag,mips16,1),1)
|
||||
TARGET_ASFLAGS_DEFAULT = $(filter-out -mips16 -minterlink-mips16,$(TARGET_CFLAGS))
|
||||
TARGET_CFLAGS += -mips16 -minterlink-mips16
|
||||
TARGET_CXXFLAGS += -mips16 -minterlink-mips16
|
||||
endif
|
||||
endif
|
||||
ifeq ($(call pkg_build_flag,gc-sections,$(if $(CONFIG_USE_GC_SECTIONS),1,0)),1)
|
||||
TARGET_CFLAGS+= -ffunction-sections -fdata-sections
|
||||
TARGET_CXXFLAGS+= -ffunction-sections -fdata-sections
|
||||
TARGET_LDFLAGS+= -Wl,--gc-sections
|
||||
endif
|
||||
ifeq ($(call pkg_build_flag,lto,$(if $(CONFIG_USE_LTO),1,0)),1)
|
||||
TARGET_CFLAGS+= -flto=auto -fno-fat-lto-objects
|
||||
TARGET_CXXFLAGS+= -flto=auto -fno-fat-lto-objects
|
||||
TARGET_LDFLAGS+= -flto=auto -fuse-linker-plugin
|
||||
endif
|
||||
ifdef CONFIG_USE_MOLD
|
||||
ifeq ($(call pkg_build_flag,mold,1),1)
|
||||
TARGET_LINKER:=mold
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(INCLUDE_DIR)/hardening.mk
|
||||
include $(INCLUDE_DIR)/prereq.mk
|
||||
include $(INCLUDE_DIR)/unpack.mk
|
||||
|
Loading…
Reference in New Issue
Block a user