aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-08-22 09:51:09 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-08-23 19:10:00 -0400
commite85d1d65cd8a9083040e280d172eba762875f8f1 (patch)
tree8038ed2a967ad92502f45a7173bdda15cfed57b7
parentf6f57a46435d7253a52a1a07a58183678ad266a0 (diff)
kbuild: test dead code/data elimination support in Kconfig
This config option should be enabled only when both the compiler and the linker support necessary flags. Add proper dependencies to Kconfig. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r--Makefile8
-rw-r--r--init/Kconfig2
2 files changed, 4 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index c4d7b4befac6..1623b8b6e8f5 100644
--- a/Makefile
+++ b/Makefile
@@ -790,8 +790,8 @@ KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
790endif 790endif
791 791
792ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION 792ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
793KBUILD_CFLAGS_KERNEL += $(call cc-option,-ffunction-sections,) 793KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
794KBUILD_CFLAGS_KERNEL += $(call cc-option,-fdata-sections,) 794LDFLAGS_vmlinux += --gc-sections
795endif 795endif
796 796
797# arch Makefile may override CC so keep this after arch Makefile is included 797# arch Makefile may override CC so keep this after arch Makefile is included
@@ -857,10 +857,6 @@ LDFLAGS_BUILD_ID := $(call ld-option, --build-id)
857KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) 857KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
858LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) 858LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID)
859 859
860ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
861LDFLAGS_vmlinux += $(call ld-option, --gc-sections,)
862endif
863
864ifeq ($(CONFIG_STRIP_ASM_SYMS),y) 860ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
865LDFLAGS_vmlinux += $(call ld-option, -X,) 861LDFLAGS_vmlinux += $(call ld-option, -X,)
866endif 862endif
diff --git a/init/Kconfig b/init/Kconfig
index 9bd50ba8253f..21b855921eaf 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1085,6 +1085,8 @@ config LD_DEAD_CODE_DATA_ELIMINATION
1085 bool "Dead code and data elimination (EXPERIMENTAL)" 1085 bool "Dead code and data elimination (EXPERIMENTAL)"
1086 depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION 1086 depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION
1087 depends on EXPERT 1087 depends on EXPERT
1088 depends on $(cc-option,-ffunction-sections -fdata-sections)
1089 depends on $(ld-option,--gc-sections)
1088 help 1090 help
1089 Enable this if you want to do dead code and data elimination with 1091 Enable this if you want to do dead code and data elimination with
1090 the linker by compiling with -ffunction-sections -fdata-sections, 1092 the linker by compiling with -ffunction-sections -fdata-sections,