Skip to content

Commit

Permalink
build: add a config knob to enable gc-sections for all packages
Browse files Browse the repository at this point in the history
This enables the linker's garbage collection for all packages which haven't
opted-out.

Signed-off-by: Andre Heider <[email protected]>
  • Loading branch information
dhewg authored and Ansuel committed Mar 21, 2023
1 parent 07730ff commit aef8bab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions config/Config-build.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion include/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aef8bab

Please sign in to comment.