[openwrt/openwrt] build: add a config knob to enable gc-sections for all packages
LEDE Commits
lede-commits at lists.infradead.org
Tue Mar 21 10:28:39 PDT 2023
ansuel pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/aef8bab9d71d85dcb6d99ff70078be3f2bdfbf61
commit aef8bab9d71d85dcb6d99ff70078be3f2bdfbf61
Author: Andre Heider <a.heider at gmail.com>
AuthorDate: Fri Feb 3 13:15:43 2023 +0100
build: add a config knob to enable gc-sections for all packages
This enables the linker's garbage collection for all packages which haven't
opted-out.
Signed-off-by: Andre Heider <a.heider at gmail.com>
---
config/Config-build.in | 8 ++++++++
include/package.mk | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/config/Config-build.in b/config/Config-build.in
index 8c81ef654c..f93ad37586 100644
--- a/config/Config-build.in
+++ b/config/Config-build.in
@@ -144,6 +144,14 @@ menu "Global build settings"
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 IPV6
def_bool y
diff --git a/include/package.mk b/include/package.mk
index 0fb947f035..687f74edc1 100644
--- a/include/package.mk
+++ b/include/package.mk
@@ -51,7 +51,7 @@ ifdef CONFIG_USE_MIPS16
TARGET_CXXFLAGS += -mips16 -minterlink-mips16
endif
endif
-ifeq ($(call pkg_build_flag,gc-sections,0),1)
+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
More information about the lede-commits
mailing list