aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile66
-rw-r--r--arch/arm/boot/Makefile1
-rw-r--r--arch/arm/boot/bootp/Makefile3
-rw-r--r--arch/arm/vdso/Makefile2
-rw-r--r--arch/h8300/boot/compressed/Makefile1
-rw-r--r--arch/ia64/Makefile6
-rw-r--r--arch/m32r/boot/compressed/Makefile1
-rw-r--r--arch/mn10300/boot/compressed/Makefile1
-rw-r--r--arch/nios2/boot/compressed/Makefile1
-rw-r--r--arch/s390/boot/compressed/Makefile1
-rw-r--r--arch/sh/boot/compressed/Makefile1
-rw-r--r--arch/sh/boot/romimage/Makefile1
-rw-r--r--arch/unicore32/boot/Makefile2
-rw-r--r--arch/unicore32/boot/compressed/Makefile1
-rw-r--r--arch/x86/boot/compressed/Makefile1
-rw-r--r--arch/x86/entry/vdso/Makefile4
-rw-r--r--arch/x86/purgatory/Makefile2
-rw-r--r--arch/x86/realmode/rm/Makefile1
-rw-r--r--include/linux/export.h33
-rw-r--r--init/Kconfig29
-rw-r--r--kernel/gcov/Kconfig1
-rw-r--r--scripts/Kbuild.include45
-rw-r--r--scripts/Makefile.build44
-rw-r--r--scripts/Makefile.extrawarn1
-rw-r--r--scripts/Makefile.lib8
-rwxr-xr-xscripts/adjust_autoksyms.sh101
-rw-r--r--scripts/basic/fixdep.c61
-rw-r--r--scripts/genksyms/genksyms.c3
-rw-r--r--tools/build/Makefile.build8
29 files changed, 335 insertions, 95 deletions
diff --git a/Makefile b/Makefile
index 0f9cb36d45c2..9ee5863dae23 100644
--- a/Makefile
+++ b/Makefile
@@ -128,6 +128,10 @@ _all:
128# Cancel implicit rules on top Makefile 128# Cancel implicit rules on top Makefile
129$(CURDIR)/Makefile Makefile: ; 129$(CURDIR)/Makefile Makefile: ;
130 130
131ifneq ($(words $(subst :, ,$(CURDIR))), 1)
132 $(error main directory cannot contain spaces nor colons)
133endif
134
131ifneq ($(KBUILD_OUTPUT),) 135ifneq ($(KBUILD_OUTPUT),)
132# Invoke a second make in the output directory, passing relevant variables 136# Invoke a second make in the output directory, passing relevant variables
133# check that the output directory actually exists 137# check that the output directory actually exists
@@ -142,7 +146,7 @@ PHONY += $(MAKECMDGOALS) sub-make
142$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make 146$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
143 @: 147 @:
144 148
145sub-make: FORCE 149sub-make:
146 $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ 150 $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
147 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) 151 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
148 152
@@ -364,7 +368,7 @@ AFLAGS_MODULE =
364LDFLAGS_MODULE = 368LDFLAGS_MODULE =
365CFLAGS_KERNEL = 369CFLAGS_KERNEL =
366AFLAGS_KERNEL = 370AFLAGS_KERNEL =
367CFLAGS_GCOV = -fprofile-arcs -ftest-coverage 371CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im -Wno-maybe-uninitialized
368CFLAGS_KCOV = -fsanitize-coverage=trace-pc 372CFLAGS_KCOV = -fsanitize-coverage=trace-pc
369 373
370 374
@@ -617,7 +621,11 @@ KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
617ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 621ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
618KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) 622KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
619else 623else
620KBUILD_CFLAGS += -O2 624ifdef CONFIG_PROFILE_ALL_BRANCHES
625KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
626else
627KBUILD_CFLAGS += -O2
628endif
621endif 629endif
622 630
623# Tell gcc to never replace conditional load with a non-conditional one 631# Tell gcc to never replace conditional load with a non-conditional one
@@ -697,9 +705,10 @@ KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
697KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior) 705KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
698else 706else
699 707
700# This warning generated too much noise in a regular build. 708# These warnings generated too much noise in a regular build.
701# Use make W=1 to enable this warning (see scripts/Makefile.build) 709# Use make W=1 to enable them (see scripts/Makefile.build)
702KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 710KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
711KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
703endif 712endif
704 713
705ifdef CONFIG_FRAME_POINTER 714ifdef CONFIG_FRAME_POINTER
@@ -926,27 +935,41 @@ export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Doc
926 935
927vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) 936vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
928 937
929# Final link of vmlinux 938# Include targets which we want to execute sequentially if the rest of the
930 cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) 939# kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be
931quiet_cmd_link-vmlinux = LINK $@ 940# evaluated more than once.
932 941PHONY += vmlinux_prereq
933# Include targets which we want to 942vmlinux_prereq: $(vmlinux-deps) FORCE
934# execute if the rest of the kernel build went well.
935vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE
936ifdef CONFIG_HEADERS_CHECK 943ifdef CONFIG_HEADERS_CHECK
937 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 944 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
938endif 945endif
939ifdef CONFIG_SAMPLES
940 $(Q)$(MAKE) $(build)=samples
941endif
942ifdef CONFIG_BUILD_DOCSRC 946ifdef CONFIG_BUILD_DOCSRC
943 $(Q)$(MAKE) $(build)=Documentation 947 $(Q)$(MAKE) $(build)=Documentation
944endif 948endif
945ifdef CONFIG_GDB_SCRIPTS 949ifdef CONFIG_GDB_SCRIPTS
946 $(Q)ln -fsn `cd $(srctree) && /bin/pwd`/scripts/gdb/vmlinux-gdb.py 950 $(Q)ln -fsn `cd $(srctree) && /bin/pwd`/scripts/gdb/vmlinux-gdb.py
947endif 951endif
952ifdef CONFIG_TRIM_UNUSED_KSYMS
953 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
954 "$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile vmlinux_prereq"
955endif
956
957# standalone target for easier testing
958include/generated/autoksyms.h: FORCE
959 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh true
960
961# Final link of vmlinux
962 cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux)
963quiet_cmd_link-vmlinux = LINK $@
964
965vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE
948 +$(call if_changed,link-vmlinux) 966 +$(call if_changed,link-vmlinux)
949 967
968# Build samples along the rest of the kernel
969ifdef CONFIG_SAMPLES
970vmlinux-dirs += samples
971endif
972
950# The actual objects are generated when descending, 973# The actual objects are generated when descending,
951# make sure no implicit rule kicks in 974# make sure no implicit rule kicks in
952$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; 975$(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
@@ -998,10 +1021,12 @@ prepare2: prepare3 outputmakefile asm-generic
998prepare1: prepare2 $(version_h) include/generated/utsrelease.h \ 1021prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
999 include/config/auto.conf 1022 include/config/auto.conf
1000 $(cmd_crmodverdir) 1023 $(cmd_crmodverdir)
1024 $(Q)test -e include/generated/autoksyms.h || \
1025 touch include/generated/autoksyms.h
1001 1026
1002archprepare: archheaders archscripts prepare1 scripts_basic 1027archprepare: archheaders archscripts prepare1 scripts_basic
1003 1028
1004prepare0: archprepare FORCE 1029prepare0: archprepare
1005 $(Q)$(MAKE) $(build)=. 1030 $(Q)$(MAKE) $(build)=.
1006 1031
1007# All the preparing.. 1032# All the preparing..
@@ -1061,7 +1086,7 @@ INSTALL_FW_PATH=$(INSTALL_MOD_PATH)/lib/firmware
1061export INSTALL_FW_PATH 1086export INSTALL_FW_PATH
1062 1087
1063PHONY += firmware_install 1088PHONY += firmware_install
1064firmware_install: FORCE 1089firmware_install:
1065 @mkdir -p $(objtree)/firmware 1090 @mkdir -p $(objtree)/firmware
1066 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_install 1091 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_install
1067 1092
@@ -1081,7 +1106,7 @@ PHONY += archscripts
1081archscripts: 1106archscripts:
1082 1107
1083PHONY += __headers 1108PHONY += __headers
1084__headers: $(version_h) scripts_basic asm-generic archheaders archscripts FORCE 1109__headers: $(version_h) scripts_basic asm-generic archheaders archscripts
1085 $(Q)$(MAKE) $(build)=scripts build_unifdef 1110 $(Q)$(MAKE) $(build)=scripts build_unifdef
1086 1111
1087PHONY += headers_install_all 1112PHONY += headers_install_all
@@ -1192,7 +1217,8 @@ else # CONFIG_MODULES
1192# Modules not configured 1217# Modules not configured
1193# --------------------------------------------------------------------------- 1218# ---------------------------------------------------------------------------
1194 1219
1195modules modules_install: FORCE 1220PHONY += modules modules_install
1221modules modules_install:
1196 @echo >&2 1222 @echo >&2
1197 @echo >&2 "The present kernel configuration has modules disabled." 1223 @echo >&2 "The present kernel configuration has modules disabled."
1198 @echo >&2 "Type 'make config' and enable loadable module support." 1224 @echo >&2 "Type 'make config' and enable loadable module support."
@@ -1283,6 +1309,7 @@ boards := $(sort $(notdir $(boards)))
1283board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig)) 1309board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1284board-dirs := $(sort $(notdir $(board-dirs:/=))) 1310board-dirs := $(sort $(notdir $(board-dirs:/=)))
1285 1311
1312PHONY += help
1286help: 1313help:
1287 @echo 'Cleaning targets:' 1314 @echo 'Cleaning targets:'
1288 @echo ' clean - Remove most generated files but keep the config and' 1315 @echo ' clean - Remove most generated files but keep the config and'
@@ -1453,6 +1480,7 @@ $(clean-dirs):
1453clean: rm-dirs := $(MODVERDIR) 1480clean: rm-dirs := $(MODVERDIR)
1454clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers 1481clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
1455 1482
1483PHONY += help
1456help: 1484help:
1457 @echo ' Building external modules.' 1485 @echo ' Building external modules.'
1458 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target' 1486 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index 446705a4325a..5be33a2d59a9 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -82,7 +82,6 @@ $(obj)/uImage: $(obj)/zImage FORCE
82 82
83$(obj)/bootp/bootp: $(obj)/zImage initrd FORCE 83$(obj)/bootp/bootp: $(obj)/zImage initrd FORCE
84 $(Q)$(MAKE) $(build)=$(obj)/bootp $@ 84 $(Q)$(MAKE) $(build)=$(obj)/bootp $@
85 @:
86 85
87$(obj)/bootpImage: $(obj)/bootp/bootp FORCE 86$(obj)/bootpImage: $(obj)/bootp/bootp FORCE
88 $(call if_changed,objcopy) 87 $(call if_changed,objcopy)
diff --git a/arch/arm/boot/bootp/Makefile b/arch/arm/boot/bootp/Makefile
index 5761f0039133..5e4acd253b30 100644
--- a/arch/arm/boot/bootp/Makefile
+++ b/arch/arm/boot/bootp/Makefile
@@ -17,7 +17,6 @@ targets := bootp init.o kernel.o initrd.o
17# Note that bootp.lds picks up kernel.o and initrd.o 17# Note that bootp.lds picks up kernel.o and initrd.o
18$(obj)/bootp: $(src)/bootp.lds $(addprefix $(obj)/,init.o kernel.o initrd.o) FORCE 18$(obj)/bootp: $(src)/bootp.lds $(addprefix $(obj)/,init.o kernel.o initrd.o) FORCE
19 $(call if_changed,ld) 19 $(call if_changed,ld)
20 @:
21 20
22# kernel.o and initrd.o includes a binary image using 21# kernel.o and initrd.o includes a binary image using
23# .incbin, a dependency which is not tracked automatically 22# .incbin, a dependency which is not tracked automatically
@@ -26,4 +25,4 @@ $(obj)/kernel.o: arch/arm/boot/zImage FORCE
26 25
27$(obj)/initrd.o: $(INITRD) FORCE 26$(obj)/initrd.o: $(INITRD) FORCE
28 27
29PHONY += $(INITRD) FORCE 28PHONY += $(INITRD)
diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
index 1160434eece0..59a8fa7b8a3b 100644
--- a/arch/arm/vdso/Makefile
+++ b/arch/arm/vdso/Makefile
@@ -74,5 +74,5 @@ $(MODLIB)/vdso: FORCE
74 @mkdir -p $(MODLIB)/vdso 74 @mkdir -p $(MODLIB)/vdso
75 75
76PHONY += vdso_install 76PHONY += vdso_install
77vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso FORCE 77vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso
78 $(call cmd,vdso_install) 78 $(call cmd,vdso_install)
diff --git a/arch/h8300/boot/compressed/Makefile b/arch/h8300/boot/compressed/Makefile
index 7643633f1330..613bfe6f5272 100644
--- a/arch/h8300/boot/compressed/Makefile
+++ b/arch/h8300/boot/compressed/Makefile
@@ -23,7 +23,6 @@ LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -estartup -T $(obj)/vmlinux.lds \
23 23
24$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE 24$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE
25 $(call if_changed,ld) 25 $(call if_changed,ld)
26 @:
27 26
28$(obj)/vmlinux.bin: vmlinux FORCE 27$(obj)/vmlinux.bin: vmlinux FORCE
29 $(call if_changed,objcopy) 28 $(call if_changed,objcopy)
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 970d0bd99621..c100d780f1eb 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -95,8 +95,8 @@ define archhelp
95 echo '* unwcheck - Check vmlinux for invalid unwind info' 95 echo '* unwcheck - Check vmlinux for invalid unwind info'
96endef 96endef
97 97
98archprepare: make_nr_irqs_h FORCE 98archprepare: make_nr_irqs_h
99PHONY += make_nr_irqs_h FORCE 99PHONY += make_nr_irqs_h
100 100
101make_nr_irqs_h: FORCE 101make_nr_irqs_h:
102 $(Q)$(MAKE) $(build)=arch/ia64/kernel include/generated/nr-irqs.h 102 $(Q)$(MAKE) $(build)=arch/ia64/kernel include/generated/nr-irqs.h
diff --git a/arch/m32r/boot/compressed/Makefile b/arch/m32r/boot/compressed/Makefile
index 01729c2979ba..0606a727aab2 100644
--- a/arch/m32r/boot/compressed/Makefile
+++ b/arch/m32r/boot/compressed/Makefile
@@ -19,7 +19,6 @@ LDFLAGS_vmlinux := -T
19 19
20$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(obj)/piggy.o FORCE 20$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(obj)/piggy.o FORCE
21 $(call if_changed,ld) 21 $(call if_changed,ld)
22 @:
23 22
24$(obj)/vmlinux.bin: vmlinux FORCE 23$(obj)/vmlinux.bin: vmlinux FORCE
25 $(call if_changed,objcopy) 24 $(call if_changed,objcopy)
diff --git a/arch/mn10300/boot/compressed/Makefile b/arch/mn10300/boot/compressed/Makefile
index 08a95e171685..5f56f9de1061 100644
--- a/arch/mn10300/boot/compressed/Makefile
+++ b/arch/mn10300/boot/compressed/Makefile
@@ -8,7 +8,6 @@ LDFLAGS_vmlinux := -Ttext $(CONFIG_KERNEL_ZIMAGE_BASE_ADDRESS) -e startup_32
8 8
9$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE 9$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
10 $(call if_changed,ld) 10 $(call if_changed,ld)
11 @:
12 11
13$(obj)/vmlinux.bin: vmlinux FORCE 12$(obj)/vmlinux.bin: vmlinux FORCE
14 $(call if_changed,objcopy) 13 $(call if_changed,objcopy)
diff --git a/arch/nios2/boot/compressed/Makefile b/arch/nios2/boot/compressed/Makefile
index 5b0fb346d888..d5921c9a9726 100644
--- a/arch/nios2/boot/compressed/Makefile
+++ b/arch/nios2/boot/compressed/Makefile
@@ -11,7 +11,6 @@ LDFLAGS_vmlinux := -T
11 11
12$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(obj)/piggy.o FORCE 12$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(obj)/piggy.o FORCE
13 $(call if_changed,ld) 13 $(call if_changed,ld)
14 @:
15 14
16LDFLAGS_piggy.o := -r --format binary --oformat elf32-littlenios2 -T 15LDFLAGS_piggy.o := -r --format binary --oformat elf32-littlenios2 -T
17 16
diff --git a/arch/s390/boot/compressed/Makefile b/arch/s390/boot/compressed/Makefile
index fac6ac9790fa..1dd210347e12 100644
--- a/arch/s390/boot/compressed/Makefile
+++ b/arch/s390/boot/compressed/Makefile
@@ -22,7 +22,6 @@ OBJECTS += $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o
22LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup -T 22LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup -T
23$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) 23$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS)
24 $(call if_changed,ld) 24 $(call if_changed,ld)
25 @:
26 25
27sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\)$$/\#define SZ\2 0x\1/p' 26sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\)$$/\#define SZ\2 0x\1/p'
28 27
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
index 6df826ee7316..c4c47ea9fa94 100644
--- a/arch/sh/boot/compressed/Makefile
+++ b/arch/sh/boot/compressed/Makefile
@@ -55,7 +55,6 @@ $(addprefix $(obj)/,$(lib1funcs-y)): $(obj)/%: $(lib1funcs-dir)/% FORCE
55 55
56$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(lib1funcs-obj) FORCE 56$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(lib1funcs-obj) FORCE
57 $(call if_changed,ld) 57 $(call if_changed,ld)
58 @:
59 58
60$(obj)/vmlinux.bin: vmlinux FORCE 59$(obj)/vmlinux.bin: vmlinux FORCE
61 $(call if_changed,objcopy) 60 $(call if_changed,objcopy)
diff --git a/arch/sh/boot/romimage/Makefile b/arch/sh/boot/romimage/Makefile
index 2216ee57f251..43c41191de5d 100644
--- a/arch/sh/boot/romimage/Makefile
+++ b/arch/sh/boot/romimage/Makefile
@@ -17,7 +17,6 @@ LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(load-y) -e romstart \
17 17
18$(obj)/vmlinux: $(obj)/head.o $(obj-y) $(obj)/piggy.o FORCE 18$(obj)/vmlinux: $(obj)/head.o $(obj-y) $(obj)/piggy.o FORCE
19 $(call if_changed,ld) 19 $(call if_changed,ld)
20 @:
21 20
22OBJCOPYFLAGS += -j .empty_zero_page 21OBJCOPYFLAGS += -j .empty_zero_page
23 22
diff --git a/arch/unicore32/boot/Makefile b/arch/unicore32/boot/Makefile
index ec7fb70b412b..828855007b29 100644
--- a/arch/unicore32/boot/Makefile
+++ b/arch/unicore32/boot/Makefile
@@ -31,7 +31,7 @@ $(obj)/uImage: $(obj)/zImage FORCE
31 $(call if_changed,uimage) 31 $(call if_changed,uimage)
32 @echo ' Image $@ is ready' 32 @echo ' Image $@ is ready'
33 33
34PHONY += initrd FORCE 34PHONY += initrd
35initrd: 35initrd:
36 @test "$(INITRD)" != "" || \ 36 @test "$(INITRD)" != "" || \
37 (echo You must specify INITRD; exit -1) 37 (echo You must specify INITRD; exit -1)
diff --git a/arch/unicore32/boot/compressed/Makefile b/arch/unicore32/boot/compressed/Makefile
index 96494fb646f7..9aecdd3ddc48 100644
--- a/arch/unicore32/boot/compressed/Makefile
+++ b/arch/unicore32/boot/compressed/Makefile
@@ -54,7 +54,6 @@ LDFLAGS_vmlinux += -T
54$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/head.o $(obj)/piggy.o \ 54$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/head.o $(obj)/piggy.o \
55 $(obj)/misc.o FORCE 55 $(obj)/misc.o FORCE
56 $(call if_changed,ld) 56 $(call if_changed,ld)
57 @:
58 57
59# We now have a PIC decompressor implementation. Decompressors running 58# We now have a PIC decompressor implementation. Decompressors running
60# from RAM should not define ZTEXTADDR. Decompressors running directly 59# from RAM should not define ZTEXTADDR. Decompressors running directly
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index cfdd8c3f8af2..f1356889204e 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -87,7 +87,6 @@ vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o
87 87
88$(obj)/vmlinux: $(vmlinux-objs-y) FORCE 88$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
89 $(call if_changed,ld) 89 $(call if_changed,ld)
90 @:
91 90
92OBJCOPYFLAGS_vmlinux.bin := -R .comment -S 91OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
93$(obj)/vmlinux.bin: vmlinux FORCE 92$(obj)/vmlinux.bin: vmlinux FORCE
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 6874da5f67fc..253b72eaade6 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -193,10 +193,10 @@ vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%)
193$(MODLIB)/vdso: FORCE 193$(MODLIB)/vdso: FORCE
194 @mkdir -p $(MODLIB)/vdso 194 @mkdir -p $(MODLIB)/vdso
195 195
196$(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso FORCE 196$(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso
197 $(call cmd,vdso_install) 197 $(call cmd,vdso_install)
198 198
199PHONY += vdso_install $(vdso_img_insttargets) 199PHONY += vdso_install $(vdso_img_insttargets)
200vdso_install: $(vdso_img_insttargets) FORCE 200vdso_install: $(vdso_img_insttargets)
201 201
202clean-files := vdso32.so vdso32.so.dbg vdso64* vdso-image-*.c vdsox32.so* 202clean-files := vdso32.so vdso32.so.dbg vdso64* vdso-image-*.c vdsox32.so*
diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile
index 92e3e1d84c1d..12734a96df47 100644
--- a/arch/x86/purgatory/Makefile
+++ b/arch/x86/purgatory/Makefile
@@ -26,7 +26,5 @@ quiet_cmd_bin2c = BIN2C $@
26 26
27$(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE 27$(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
28 $(call if_changed,bin2c) 28 $(call if_changed,bin2c)
29 @:
30
31 29
32obj-$(CONFIG_KEXEC_FILE) += kexec-purgatory.o 30obj-$(CONFIG_KEXEC_FILE) += kexec-purgatory.o
diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
index b95964610ea7..c556c5ae8de5 100644
--- a/arch/x86/realmode/rm/Makefile
+++ b/arch/x86/realmode/rm/Makefile
@@ -59,7 +59,6 @@ OBJCOPYFLAGS_realmode.bin := -O binary
59targets += realmode.bin 59targets += realmode.bin
60$(obj)/realmode.bin: $(obj)/realmode.elf $(obj)/realmode.relocs FORCE 60$(obj)/realmode.bin: $(obj)/realmode.elf $(obj)/realmode.relocs FORCE
61 $(call if_changed,objcopy) 61 $(call if_changed,objcopy)
62 @:
63 62
64quiet_cmd_relocs = RELOCS $@ 63quiet_cmd_relocs = RELOCS $@
65 cmd_relocs = arch/x86/tools/relocs --realmode $< > $@ 64 cmd_relocs = arch/x86/tools/relocs --realmode $< > $@
diff --git a/include/linux/export.h b/include/linux/export.h
index 96e45ea463e7..2f9ccbe6a639 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -38,7 +38,7 @@ extern struct module __this_module;
38 38
39#ifdef CONFIG_MODULES 39#ifdef CONFIG_MODULES
40 40
41#ifndef __GENKSYMS__ 41#if defined(__KERNEL__) && !defined(__GENKSYMS__)
42#ifdef CONFIG_MODVERSIONS 42#ifdef CONFIG_MODVERSIONS
43/* Mark the CRC weak since genksyms apparently decides not to 43/* Mark the CRC weak since genksyms apparently decides not to
44 * generate a checksums for some symbols */ 44 * generate a checksums for some symbols */
@@ -53,7 +53,7 @@ extern struct module __this_module;
53#endif 53#endif
54 54
55/* For every exported symbol, place a struct in the __ksymtab section */ 55/* For every exported symbol, place a struct in the __ksymtab section */
56#define __EXPORT_SYMBOL(sym, sec) \ 56#define ___EXPORT_SYMBOL(sym, sec) \
57 extern typeof(sym) sym; \ 57 extern typeof(sym) sym; \
58 __CRC_SYMBOL(sym, sec) \ 58 __CRC_SYMBOL(sym, sec) \
59 static const char __kstrtab_##sym[] \ 59 static const char __kstrtab_##sym[] \
@@ -65,6 +65,35 @@ extern struct module __this_module;
65 __attribute__((section("___ksymtab" sec "+" #sym), unused)) \ 65 __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
66 = { (unsigned long)&sym, __kstrtab_##sym } 66 = { (unsigned long)&sym, __kstrtab_##sym }
67 67
68#if defined(__KSYM_DEPS__)
69
70/*
71 * For fine grained build dependencies, we want to tell the build system
72 * about each possible exported symbol even if they're not actually exported.
73 * We use a string pattern that is unlikely to be valid code that the build
74 * system filters out from the preprocessor output (see ksym_dep_filter
75 * in scripts/Kbuild.include).
76 */
77#define __EXPORT_SYMBOL(sym, sec) === __KSYM_##sym ===
78
79#elif defined(CONFIG_TRIM_UNUSED_KSYMS)
80
81#include <linux/kconfig.h>
82#include <generated/autoksyms.h>
83
84#define __EXPORT_SYMBOL(sym, sec) \
85 __cond_export_sym(sym, sec, config_enabled(__KSYM_##sym))
86#define __cond_export_sym(sym, sec, conf) \
87 ___cond_export_sym(sym, sec, conf)
88#define ___cond_export_sym(sym, sec, enabled) \
89 __cond_export_sym_##enabled(sym, sec)
90#define __cond_export_sym_1(sym, sec) ___EXPORT_SYMBOL(sym, sec)
91#define __cond_export_sym_0(sym, sec) /* nothing */
92
93#else
94#define __EXPORT_SYMBOL ___EXPORT_SYMBOL
95#endif
96
68#define EXPORT_SYMBOL(sym) \ 97#define EXPORT_SYMBOL(sym) \
69 __EXPORT_SYMBOL(sym, "") 98 __EXPORT_SYMBOL(sym, "")
70 99
diff --git a/init/Kconfig b/init/Kconfig
index a9c4aefd5436..f755a602d4a1 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1306,6 +1306,17 @@ source "usr/Kconfig"
1306 1306
1307endif 1307endif
1308 1308
1309choice
1310 prompt "Compiler optimization level"
1311 default CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
1312
1313config CC_OPTIMIZE_FOR_PERFORMANCE
1314 bool "Optimize for performance"
1315 help
1316 This is the default optimization level for the kernel, building
1317 with the "-O2" compiler flag for best performance and most
1318 helpful compile-time warnings.
1319
1309config CC_OPTIMIZE_FOR_SIZE 1320config CC_OPTIMIZE_FOR_SIZE
1310 bool "Optimize for size" 1321 bool "Optimize for size"
1311 help 1322 help
@@ -1314,6 +1325,8 @@ config CC_OPTIMIZE_FOR_SIZE
1314 1325
1315 If unsure, say N. 1326 If unsure, say N.
1316 1327
1328endchoice
1329
1317config SYSCTL 1330config SYSCTL
1318 bool 1331 bool
1319 1332
@@ -2049,6 +2062,22 @@ config MODULE_COMPRESS_XZ
2049 2062
2050endchoice 2063endchoice
2051 2064
2065config TRIM_UNUSED_KSYMS
2066 bool "Trim unused exported kernel symbols"
2067 depends on MODULES && !UNUSED_SYMBOLS
2068 help
2069 The kernel and some modules make many symbols available for
2070 other modules to use via EXPORT_SYMBOL() and variants. Depending
2071 on the set of modules being selected in your kernel configuration,
2072 many of those exported symbols might never be used.
2073
2074 This option allows for unused exported symbols to be dropped from
2075 the build. In turn, this provides the compiler more opportunities
2076 (especially when using LTO) for optimizing the code and reducing
2077 binary size. This might have some security advantages as well.
2078
2079 If unsure say N.
2080
2052endif # MODULES 2081endif # MODULES
2053 2082
2054config MODULES_TREE_LOOKUP 2083config MODULES_TREE_LOOKUP
diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
index c92e44855ddd..1276aabaab55 100644
--- a/kernel/gcov/Kconfig
+++ b/kernel/gcov/Kconfig
@@ -37,6 +37,7 @@ config ARCH_HAS_GCOV_PROFILE_ALL
37 37
38config GCOV_PROFILE_ALL 38config GCOV_PROFILE_ALL
39 bool "Profile entire Kernel" 39 bool "Profile entire Kernel"
40 depends on !COMPILE_TEST
40 depends on GCOV_KERNEL 41 depends on GCOV_KERNEL
41 depends on ARCH_HAS_GCOV_PROFILE_ALL 42 depends on ARCH_HAS_GCOV_PROFILE_ALL
42 default n 43 default n
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index b2ab2a92a375..0f82314621f2 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -7,6 +7,7 @@ quote := "
7squote := ' 7squote := '
8empty := 8empty :=
9space := $(empty) $(empty) 9space := $(empty) $(empty)
10space_escape := _-_SPACE_-_
10 11
11### 12###
12# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o 13# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
@@ -226,10 +227,10 @@ objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
226# See Documentation/kbuild/makefiles.txt for more info 227# See Documentation/kbuild/makefiles.txt for more info
227 228
228ifneq ($(KBUILD_NOCMDDEP),1) 229ifneq ($(KBUILD_NOCMDDEP),1)
229# Check if both arguments has same arguments. Result is empty string if equal. 230# Check if both arguments are the same including their order. Result is empty
230# User may override this check using make KBUILD_NOCMDDEP=1 231# string if equal. User may override this check using make KBUILD_NOCMDDEP=1
231arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ 232arg-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), \
232 $(filter-out $(cmd_$@), $(cmd_$(1))) ) 233 $(subst $(space),$(space_escape),$(strip $(cmd_$1))))
233else 234else
234arg-check = $(if $(strip $(cmd_$@)),,1) 235arg-check = $(if $(strip $(cmd_$@)),,1)
235endif 236endif
@@ -256,10 +257,42 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
256# Execute the command and also postprocess generated .d dependencies file. 257# Execute the command and also postprocess generated .d dependencies file.
257if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ 258if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \
258 @set -e; \ 259 @set -e; \
260 $(cmd_and_fixdep), @:)
261
262ifndef CONFIG_TRIM_UNUSED_KSYMS
263
264cmd_and_fixdep = \
259 $(echo-cmd) $(cmd_$(1)); \ 265 $(echo-cmd) $(cmd_$(1)); \
260 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ 266 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
261 rm -f $(depfile); \ 267 rm -f $(depfile); \
262 mv -f $(dot-target).tmp $(dot-target).cmd, @:) 268 mv -f $(dot-target).tmp $(dot-target).cmd;
269
270else
271
272# Filter out exported kernel symbol names from the preprocessor output.
273# See also __KSYM_DEPS__ in include/linux/export.h.
274# We disable the depfile generation here, so as not to overwrite the existing
275# depfile while fixdep is parsing it.
276flags_nodeps = $(filter-out -Wp$(comma)-M%, $($(1)))
277ksym_dep_filter = \
278 case "$(1)" in \
279 cc_*_c|cpp_i_c) \
280 $(CPP) $(call flags_nodeps,c_flags) -D__KSYM_DEPS__ $< ;; \
281 as_*_S|cpp_s_S) \
282 $(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;; \
283 boot*|build*|*cpp_lds_S|dtc|host*|vdso*) : ;; \
284 *) echo "Don't know how to preprocess $(1)" >&2; false ;; \
285 esac | tr ";" "\n" | sed -rn 's/^.*=== __KSYM_(.*) ===.*$$/KSYM_\1/p'
286
287cmd_and_fixdep = \
288 $(echo-cmd) $(cmd_$(1)); \
289 $(ksym_dep_filter) | \
290 scripts/basic/fixdep -e $(depfile) $@ '$(make-cmd)' \
291 > $(dot-target).tmp; \
292 rm -f $(depfile); \
293 mv -f $(dot-target).tmp $(dot-target).cmd;
294
295endif
263 296
264# Usage: $(call if_changed_rule,foo) 297# Usage: $(call if_changed_rule,foo)
265# Will check if $(cmd_foo) or any of the prerequisites changed, 298# Will check if $(cmd_foo) or any of the prerequisites changed,
@@ -341,8 +374,6 @@ endif
341# 374#
342############################################################################### 375###############################################################################
343# 376#
344space_escape := %%%SPACE%%%
345#
346define config_filename 377define config_filename
347ifneq ($$(CONFIG_$(1)),"") 378ifneq ($$(CONFIG_$(1)),"")
348$(1)_FILENAME := $$(subst \\,\,$$(subst \$$(quote),$$(quote),$$(subst $$(space_escape),\$$(space),$$(patsubst "%",%,$$(subst $$(space),$$(space_escape),$$(CONFIG_$(1))))))) 379$(1)_FILENAME := $$(subst \\,\,$$(subst \$$(quote),$$(quote),$$(subst $$(space_escape),\$$(space),$$(patsubst "%",%,$$(subst $$(space),$$(space_escape),$$(CONFIG_$(1)))))))
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index e1bc1907090e..0d1ca5bf42fb 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -152,11 +152,11 @@ cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
152$(obj)/%.s: $(src)/%.c FORCE 152$(obj)/%.s: $(src)/%.c FORCE
153 $(call if_changed_dep,cc_s_c) 153 $(call if_changed_dep,cc_s_c)
154 154
155quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@ 155quiet_cmd_cpp_i_c = CPP $(quiet_modtag) $@
156cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< 156cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $<
157 157
158$(obj)/%.i: $(src)/%.c FORCE 158$(obj)/%.i: $(src)/%.c FORCE
159 $(call if_changed_dep,cc_i_c) 159 $(call if_changed_dep,cpp_i_c)
160 160
161cmd_gensymtypes = \ 161cmd_gensymtypes = \
162 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ 162 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \
@@ -266,26 +266,24 @@ endif # CONFIG_STACK_VALIDATION
266 266
267define rule_cc_o_c 267define rule_cc_o_c
268 $(call echo-cmd,checksrc) $(cmd_checksrc) \ 268 $(call echo-cmd,checksrc) $(cmd_checksrc) \
269 $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ 269 $(call cmd_and_fixdep,cc_o_c) \
270 $(cmd_modversions) \ 270 $(cmd_modversions) \
271 $(cmd_objtool) \ 271 $(cmd_objtool) \
272 $(call echo-cmd,record_mcount) \ 272 $(call echo-cmd,record_mcount) $(cmd_record_mcount)
273 $(cmd_record_mcount) \
274 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
275 $(dot-target).tmp; \
276 rm -f $(depfile); \
277 mv -f $(dot-target).tmp $(dot-target).cmd
278endef 273endef
279 274
280define rule_as_o_S 275define rule_as_o_S
281 $(call echo-cmd,as_o_S) $(cmd_as_o_S); \ 276 $(call cmd_and_fixdep,as_o_S) \
282 $(cmd_objtool) \ 277 $(cmd_objtool)
283 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,as_o_S)' > \
284 $(dot-target).tmp; \
285 rm -f $(depfile); \
286 mv -f $(dot-target).tmp $(dot-target).cmd
287endef 278endef
288 279
280# List module undefined symbols (or empty line if not enabled)
281ifdef CONFIG_TRIM_UNUSED_KSYMS
282cmd_undef_syms = $(NM) $@ | sed -n 's/^ \+U //p' | xargs echo
283else
284cmd_undef_syms = echo
285endif
286
289# Built-in and composite module parts 287# Built-in and composite module parts
290$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE 288$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
291 $(call cmd,force_checksrc) 289 $(call cmd,force_checksrc)
@@ -296,7 +294,8 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
296$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE 294$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
297 $(call cmd,force_checksrc) 295 $(call cmd,force_checksrc)
298 $(call if_changed_rule,cc_o_c) 296 $(call if_changed_rule,cc_o_c)
299 @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) 297 @{ echo $(@:.o=.ko); echo $@; \
298 $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
300 299
301quiet_cmd_cc_lst_c = MKLST $@ 300quiet_cmd_cc_lst_c = MKLST $@
302 cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ 301 cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
@@ -314,11 +313,11 @@ modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
314$(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) 313$(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
315$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) 314$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
316 315
317quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ 316quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@
318cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< 317cmd_cpp_s_S = $(CPP) $(a_flags) -o $@ $<
319 318
320$(obj)/%.s: $(src)/%.S FORCE 319$(obj)/%.s: $(src)/%.S FORCE
321 $(call if_changed_dep,as_s_S) 320 $(call if_changed_dep,cpp_s_S)
322 321
323quiet_cmd_as_o_S = AS $(quiet_modtag) $@ 322quiet_cmd_as_o_S = AS $(quiet_modtag) $@
324cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< 323cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
@@ -426,7 +425,8 @@ $(call multi_depend, $(multi-used-y), .o, -objs -y)
426 425
427$(multi-used-m): FORCE 426$(multi-used-m): FORCE
428 $(call if_changed,link_multi-m) 427 $(call if_changed,link_multi-m)
429 @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod) 428 @{ echo $(@:.o=.ko); echo $(link_multi_deps); \
429 $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
430$(call multi_depend, $(multi-used-m), .o, -objs -y -m) 430$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
431 431
432targets += $(multi-used-y) $(multi-used-m) 432targets += $(multi-used-y) $(multi-used-m)
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index f9e47a70509c..53449a6ff6aa 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -24,6 +24,7 @@ warning-1 += $(call cc-option, -Wmissing-prototypes)
24warning-1 += -Wold-style-definition 24warning-1 += -Wold-style-definition
25warning-1 += $(call cc-option, -Wmissing-include-dirs) 25warning-1 += $(call cc-option, -Wmissing-include-dirs)
26warning-1 += $(call cc-option, -Wunused-but-set-variable) 26warning-1 += $(call cc-option, -Wunused-but-set-variable)
27warning-1 += $(call cc-option, -Wunused-const-variable)
27warning-1 += $(call cc-disable-warning, missing-field-initializers) 28warning-1 += $(call cc-disable-warning, missing-field-initializers)
28warning-1 += $(call cc-disable-warning, sign-compare) 29warning-1 += $(call cc-disable-warning, sign-compare)
29 30
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index ed1b7c4fb674..e7df0f5db7ec 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -96,10 +96,10 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
96# Note: Files that end up in two or more modules are compiled without the 96# Note: Files that end up in two or more modules are compiled without the
97# KBUILD_MODNAME definition. The reason is that any made-up name would 97# KBUILD_MODNAME definition. The reason is that any made-up name would
98# differ in different configs. 98# differ in different configs.
99name-fix = $(subst $(comma),_,$(subst -,_,$1)) 99name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
100basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" 100basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
101modname_flags = $(if $(filter 1,$(words $(modname))),\ 101modname_flags = $(if $(filter 1,$(words $(modname))),\
102 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") 102 -DKBUILD_MODNAME=$(call name-fix,$(modname)))
103 103
104orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ 104orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
105 $(ccflags-y) $(CFLAGS_$(basetarget).o) 105 $(ccflags-y) $(CFLAGS_$(basetarget).o)
@@ -162,7 +162,7 @@ endif
162 162
163c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 163c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
164 $(__c_flags) $(modkern_cflags) \ 164 $(__c_flags) $(modkern_cflags) \
165 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) 165 $(basename_flags) $(modname_flags)
166 166
167a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 167a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
168 $(__a_flags) $(modkern_aflags) 168 $(__a_flags) $(modkern_aflags)
diff --git a/scripts/adjust_autoksyms.sh b/scripts/adjust_autoksyms.sh
new file mode 100755
index 000000000000..8dc1918b6783
--- /dev/null
+++ b/scripts/adjust_autoksyms.sh
@@ -0,0 +1,101 @@
1#!/bin/sh
2
3# Script to create/update include/generated/autoksyms.h and dependency files
4#
5# Copyright: (C) 2016 Linaro Limited
6# Created by: Nicolas Pitre, January 2016
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License version 2 as
10# published by the Free Software Foundation.
11
12# Create/update the include/generated/autoksyms.h file from the list
13# of all module's needed symbols as recorded on the third line of
14# .tmp_versions/*.mod files.
15#
16# For each symbol being added or removed, the corresponding dependency
17# file's timestamp is updated to force a rebuild of the affected source
18# file. All arguments passed to this script are assumed to be a command
19# to be exec'd to trigger a rebuild of those files.
20
21set -e
22
23cur_ksyms_file="include/generated/autoksyms.h"
24new_ksyms_file="include/generated/autoksyms.h.tmpnew"
25
26info() {
27 if [ "$quiet" != "silent_" ]; then
28 printf " %-7s %s\n" "$1" "$2"
29 fi
30}
31
32info "CHK" "$cur_ksyms_file"
33
34# Use "make V=1" to debug this script.
35case "$KBUILD_VERBOSE" in
36*1*)
37 set -x
38 ;;
39esac
40
41# We need access to CONFIG_ symbols
42case "${KCONFIG_CONFIG}" in
43*/*)
44 . "${KCONFIG_CONFIG}"
45 ;;
46*)
47 # Force using a file from the current directory
48 . "./${KCONFIG_CONFIG}"
49esac
50
51# In case it doesn't exist yet...
52if [ -e "$cur_ksyms_file" ]; then touch "$cur_ksyms_file"; fi
53
54# Generate a new ksym list file with symbols needed by the current
55# set of modules.
56cat > "$new_ksyms_file" << EOT
57/*
58 * Automatically generated file; DO NOT EDIT.
59 */
60
61EOT
62sed -ns -e '3{s/ /\n/g;/^$/!p;}' "$MODVERDIR"/*.mod | sort -u |
63while read sym; do
64 if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then
65 sym="${sym#_}"
66 fi
67 echo "#define __KSYM_${sym} 1"
68done >> "$new_ksyms_file"
69
70# Special case for modversions (see modpost.c)
71if [ -n "$CONFIG_MODVERSIONS" ]; then
72 echo "#define __KSYM_module_layout 1" >> "$new_ksyms_file"
73fi
74
75# Extract changes between old and new list and touch corresponding
76# dependency files.
77changed=$(
78count=0
79sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u |
80sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" |
81while read sympath; do
82 if [ -z "$sympath" ]; then continue; fi
83 depfile="include/config/ksym/${sympath}.h"
84 mkdir -p "$(dirname "$depfile")"
85 touch "$depfile"
86 echo $((count += 1))
87done | tail -1 )
88changed=${changed:-0}
89
90if [ $changed -gt 0 ]; then
91 # Replace the old list with tne new one
92 old=$(grep -c "^#define __KSYM_" "$cur_ksyms_file" || true)
93 new=$(grep -c "^#define __KSYM_" "$new_ksyms_file" || true)
94 info "KSYMS" "symbols: before=$old, after=$new, changed=$changed"
95 info "UPD" "$cur_ksyms_file"
96 mv -f "$new_ksyms_file" "$cur_ksyms_file"
97 # Then trigger a rebuild of affected source files
98 exec $@
99else
100 rm -f "$new_ksyms_file"
101fi
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index caef815d1743..746ec1ece614 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -120,13 +120,15 @@
120#define INT_NFIG ntohl(0x4e464947) 120#define INT_NFIG ntohl(0x4e464947)
121#define INT_FIG_ ntohl(0x4649475f) 121#define INT_FIG_ ntohl(0x4649475f)
122 122
123int insert_extra_deps;
123char *target; 124char *target;
124char *depfile; 125char *depfile;
125char *cmdline; 126char *cmdline;
126 127
127static void usage(void) 128static void usage(void)
128{ 129{
129 fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n"); 130 fprintf(stderr, "Usage: fixdep [-e] <depfile> <target> <cmdline>\n");
131 fprintf(stderr, " -e insert extra dependencies given on stdin\n");
130 exit(1); 132 exit(1);
131} 133}
132 134
@@ -138,6 +140,40 @@ static void print_cmdline(void)
138 printf("cmd_%s := %s\n\n", target, cmdline); 140 printf("cmd_%s := %s\n\n", target, cmdline);
139} 141}
140 142
143/*
144 * Print out a dependency path from a symbol name
145 */
146static void print_config(const char *m, int slen)
147{
148 int c, i;
149
150 printf(" $(wildcard include/config/");
151 for (i = 0; i < slen; i++) {
152 c = m[i];
153 if (c == '_')
154 c = '/';
155 else
156 c = tolower(c);
157 putchar(c);
158 }
159 printf(".h) \\\n");
160}
161
162static void do_extra_deps(void)
163{
164 if (insert_extra_deps) {
165 char buf[80];
166 while(fgets(buf, sizeof(buf), stdin)) {
167 int len = strlen(buf);
168 if (len < 2 || buf[len-1] != '\n') {
169 fprintf(stderr, "fixdep: bad data on stdin\n");
170 exit(1);
171 }
172 print_config(buf, len-1);
173 }
174 }
175}
176
141struct item { 177struct item {
142 struct item *next; 178 struct item *next;
143 unsigned int len; 179 unsigned int len;
@@ -197,23 +233,12 @@ static void define_config(const char *name, int len, unsigned int hash)
197static void use_config(const char *m, int slen) 233static void use_config(const char *m, int slen)
198{ 234{
199 unsigned int hash = strhash(m, slen); 235 unsigned int hash = strhash(m, slen);
200 int c, i;
201 236
202 if (is_defined_config(m, slen, hash)) 237 if (is_defined_config(m, slen, hash))
203 return; 238 return;
204 239
205 define_config(m, slen, hash); 240 define_config(m, slen, hash);
206 241 print_config(m, slen);
207 printf(" $(wildcard include/config/");
208 for (i = 0; i < slen; i++) {
209 c = m[i];
210 if (c == '_')
211 c = '/';
212 else
213 c = tolower(c);
214 putchar(c);
215 }
216 printf(".h) \\\n");
217} 242}
218 243
219static void parse_config_file(const char *map, size_t len) 244static void parse_config_file(const char *map, size_t len)
@@ -250,7 +275,7 @@ static void parse_config_file(const char *map, size_t len)
250 } 275 }
251} 276}
252 277
253/* test is s ends in sub */ 278/* test if s ends in sub */
254static int strrcmp(const char *s, const char *sub) 279static int strrcmp(const char *s, const char *sub)
255{ 280{
256 int slen = strlen(s); 281 int slen = strlen(s);
@@ -333,6 +358,7 @@ static void parse_dep_file(void *map, size_t len)
333 358
334 /* Ignore certain dependencies */ 359 /* Ignore certain dependencies */
335 if (strrcmp(s, "include/generated/autoconf.h") && 360 if (strrcmp(s, "include/generated/autoconf.h") &&
361 strrcmp(s, "include/generated/autoksyms.h") &&
336 strrcmp(s, "arch/um/include/uml-config.h") && 362 strrcmp(s, "arch/um/include/uml-config.h") &&
337 strrcmp(s, "include/linux/kconfig.h") && 363 strrcmp(s, "include/linux/kconfig.h") &&
338 strrcmp(s, ".ver")) { 364 strrcmp(s, ".ver")) {
@@ -378,6 +404,8 @@ static void parse_dep_file(void *map, size_t len)
378 exit(1); 404 exit(1);
379 } 405 }
380 406
407 do_extra_deps();
408
381 printf("\n%s: $(deps_%s)\n\n", target, target); 409 printf("\n%s: $(deps_%s)\n\n", target, target);
382 printf("$(deps_%s):\n", target); 410 printf("$(deps_%s):\n", target);
383} 411}
@@ -434,7 +462,10 @@ int main(int argc, char *argv[])
434{ 462{
435 traps(); 463 traps();
436 464
437 if (argc != 4) 465 if (argc == 5 && !strcmp(argv[1], "-e")) {
466 insert_extra_deps = 1;
467 argv++;
468 } else if (argc != 4)
438 usage(); 469 usage();
439 470
440 depfile = argv[1]; 471 depfile = argv[1];
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index dafaf96e0a34..06121ce524a7 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -873,5 +873,8 @@ int main(int argc, char **argv)
873 (double)nsyms / (double)HASH_BUCKETS); 873 (double)nsyms / (double)HASH_BUCKETS);
874 } 874 }
875 875
876 if (dumpfile)
877 fclose(dumpfile);
878
876 return errors != 0; 879 return errors != 0;
877} 880}
diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build
index ee566e8bd1cf..27f3583193e6 100644
--- a/tools/build/Makefile.build
+++ b/tools/build/Makefile.build
@@ -58,8 +58,8 @@ quiet_cmd_mkdir = MKDIR $(dir $@)
58quiet_cmd_cc_o_c = CC $@ 58quiet_cmd_cc_o_c = CC $@
59 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 59 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
60 60
61quiet_cmd_cc_i_c = CPP $@ 61quiet_cmd_cpp_i_c = CPP $@
62 cmd_cc_i_c = $(CC) $(c_flags) -E -o $@ $< 62 cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $<
63 63
64quiet_cmd_cc_s_c = AS $@ 64quiet_cmd_cc_s_c = AS $@
65 cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $< 65 cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $<
@@ -83,11 +83,11 @@ $(OUTPUT)%.o: %.S FORCE
83 83
84$(OUTPUT)%.i: %.c FORCE 84$(OUTPUT)%.i: %.c FORCE
85 $(call rule_mkdir) 85 $(call rule_mkdir)
86 $(call if_changed_dep,cc_i_c) 86 $(call if_changed_dep,cpp_i_c)
87 87
88$(OUTPUT)%.s: %.S FORCE 88$(OUTPUT)%.s: %.S FORCE
89 $(call rule_mkdir) 89 $(call rule_mkdir)
90 $(call if_changed_dep,cc_i_c) 90 $(call if_changed_dep,cpp_i_c)
91 91
92$(OUTPUT)%.s: %.c FORCE 92$(OUTPUT)%.s: %.c FORCE
93 $(call rule_mkdir) 93 $(call rule_mkdir)