]> www.infradead.org Git - mtd-utils.git/commitdiff
mtd-utils: enable garbage collection of unused function/data sections
authorMike Frysinger <vapier@gentoo.org>
Fri, 1 Oct 2010 05:37:14 +0000 (01:37 -0400)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 1 Oct 2010 06:29:14 +0000 (09:29 +0300)
On my default build, this cumulatively shaves off ~100KiB of unused
code and data from the mtd-utils programs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
common.mk

index 0444ad93b545d0a99be41607cb2e974bb2dda94b..a55c5482fd05475565910de45fcdd2a7ce73df86 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -3,6 +3,7 @@ AR := $(CROSS)ar
 RANLIB := $(CROSS)ranlib
 
 # Stolen from Linux build system
+comma = ,
 try-run = $(shell set -e; ($(1)) >/dev/null 2>&1 && echo "$(2)" || echo "$(3)")
 cc-option = $(call try-run, $(CC) $(1) -c -xc /dev/null -o /dev/null,$(1),$(2))
 
@@ -12,6 +13,8 @@ WFLAGS := -Wall \
        $(call cc-option,-Wwrite-strings) \
        $(call cc-option,-Wno-sign-compare)
 CFLAGS += $(WFLAGS)
+SECTION_CFLAGS := $(call cc-option,-ffunction-sections -fdata-sections -Wl$(comma)--gc-sections)
+CFLAGS += $(SECTION_CFLAGS)
 
 ifneq ($(WITHOUT_LARGEFILE), 1)
   CPPFLAGS += -D_FILE_OFFSET_BITS=64