aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Piggin2016-08-24 07:29:20 -0500
committerMichal Marek2016-09-09 03:47:00 -0500
commitb67067f1176df6ee727450546b58704e4b588563 (patch)
tree59cfd4ebc0ea13e799b9e4393740591f9e16985d /Makefile
parenta5967db9af51a84f5e181600954714a9e4c69f1f (diff)
downloadkernel-b67067f1176df6ee727450546b58704e4b588563.tar.gz
kernel-b67067f1176df6ee727450546b58704e4b588563.tar.xz
kernel-b67067f1176df6ee727450546b58704e4b588563.zip
kbuild: allow archs to select link dead code/data elimination
Introduce LD_DEAD_CODE_DATA_ELIMINATION option for architectures to select to build with -ffunction-sections, -fdata-sections, and link with --gc-sections. It requires some work (documented) to ensure all unreferenced entrypoints are live, and requires toolchain and build verification, so it is made a per-arch option for now. On a random powerpc64le build, this yelds a significant size saving, it boots and runs fine, but there is a lot I haven't tested as yet, so these savings may be reduced if there are bugs in the link. text data bss dec filename 11169741 1180744 1923176 14273661 vmlinux 10445269 1004127 1919707 13369103 vmlinux.dce ~700K text, ~170K data, 6% removed from kernel image size. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile9
1 files changed, 9 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 70de1448c571..6d40f3a3a8cc 100644
--- a/Makefile
+++ b/Makefile
@@ -622,6 +622,11 @@ include arch/$(SRCARCH)/Makefile
622KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) 622KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
623KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,) 623KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
624 624
625ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
626KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,)
627KBUILD_CFLAGS += $(call cc-option,-fdata-sections,)
628endif
629
625ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 630ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
626KBUILD_CFLAGS += -Os 631KBUILD_CFLAGS += -Os
627else 632else
@@ -809,6 +814,10 @@ LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
809KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) 814KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
810LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) 815LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID)
811 816
817ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
818LDFLAGS_vmlinux += $(call ld-option, --gc-sections,)
819endif
820
812ifeq ($(CONFIG_STRIP_ASM_SYMS),y) 821ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
813LDFLAGS_vmlinux += $(call ld-option, -X,) 822LDFLAGS_vmlinux += $(call ld-option, -X,)
814endif 823endif