summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-20 11:36:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-20 11:36:47 -0400
commitd7b0827f28ab3a4fd65864451ffefa695e3255fd (patch)
treeed93beb88fa420cf276b2c3fc22c02c022dde693
parent574cc4539762561d96b456dbc0544d8898bd4c6e (diff)
parent77564a4829ef6d309331d443ea6ceb065f3dc371 (diff)
Merge tag 'kbuild-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada: - add modpost warn exported symbols marked as 'static' because 'static' and EXPORT_SYMBOL is an odd combination - break the build early if gold linker is used - optimize the Bison rule to produce .c and .h files by a single pattern rule - handle PREEMPT_RT in the module vermagic and UTS_VERSION - warn CONFIG options leaked to the user-space except existing ones - make single targets work properly - rebuild modules when module linker scripts are updated - split the module final link stage into scripts/Makefile.modfinal - fix the missed error code in merge_config.sh - improve the error message displayed on the attempt of the O= build in unclean source tree - remove 'clean-dirs' syntax - disable -Wimplicit-fallthrough warning for Clang - add CONFIG_CC_OPTIMIZE_FOR_SIZE_O3 for ARC - remove ARCH_{CPP,A,C}FLAGS variables - add $(BASH) to run bash scripts - change *CFLAGS_<basetarget>.o to take the relative path to $(obj) instead of the basename - stop suppressing Clang's -Wunused-function warnings when W=1 - fix linux/export.h to avoid genksyms calculating CRC of trimmed exported symbols - misc cleanups * tag 'kbuild-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (63 commits) genksyms: convert to SPDX License Identifier for lex.l and parse.y modpost: use __section in the output to *.mod.c modpost: use MODULE_INFO() for __module_depends export.h, genksyms: do not make genksyms calculate CRC of trimmed symbols export.h: remove defined(__KERNEL__), which is no longer needed kbuild: allow Clang to find unused static inline functions for W=1 build kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN kbuild: refactor scripts/Makefile.extrawarn merge_config.sh: ignore unwanted grep errors kbuild: change *FLAGS_<basetarget>.o to take the path relative to $(obj) modpost: add NOFAIL to strndup modpost: add guid_t type definition kbuild: add $(BASH) to run scripts with bash-extension kbuild: remove ARCH_{CPP,A,C}FLAGS kbuild,arc: add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 for ARC kbuild: Do not enable -Wimplicit-fallthrough for clang for now kbuild: clean up subdir-ymn calculation in Makefile.clean kbuild: remove unneeded '+' marker from cmd_clean kbuild: remove clean-dirs syntax kbuild: check clean srctree even earlier ...
-rw-r--r--.gitignore2
-rw-r--r--Documentation/kbuild/kbuild.rst28
-rw-r--r--Documentation/kbuild/makefiles.rst67
-rw-r--r--Kbuild7
-rw-r--r--Makefile296
-rw-r--r--arch/Kconfig7
-rw-r--r--arch/alpha/Kconfig1
-rw-r--r--arch/arc/Makefile8
-rw-r--r--arch/arc/configs/axs101_defconfig1
-rw-r--r--arch/arc/configs/axs103_defconfig1
-rw-r--r--arch/arc/configs/axs103_smp_defconfig1
-rw-r--r--arch/arc/configs/haps_hs_defconfig1
-rw-r--r--arch/arc/configs/haps_hs_smp_defconfig1
-rw-r--r--arch/arc/configs/hsdk_defconfig1
-rw-r--r--arch/arc/configs/nps_defconfig1
-rw-r--r--arch/arc/configs/nsim_700_defconfig1
-rw-r--r--arch/arc/configs/nsim_hs_defconfig1
-rw-r--r--arch/arc/configs/nsim_hs_smp_defconfig1
-rw-r--r--arch/arc/configs/nsimosci_defconfig1
-rw-r--r--arch/arc/configs/nsimosci_hs_defconfig1
-rw-r--r--arch/arc/configs/nsimosci_hs_smp_defconfig1
-rw-r--r--arch/arc/configs/tb10x_defconfig1
-rw-r--r--arch/arc/configs/vdk_hs38_defconfig1
-rw-r--r--arch/arc/configs/vdk_hs38_smp_defconfig1
-rw-r--r--arch/arm/Makefile2
-rw-r--r--arch/arm/kvm/Makefile5
-rw-r--r--arch/arm64/Kconfig1
-rw-r--r--arch/arm64/Makefile2
-rw-r--r--arch/ia64/Kconfig1
-rw-r--r--arch/ia64/Makefile2
-rw-r--r--arch/m68k/Kconfig1
-rw-r--r--arch/m68k/Makefile2
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/mips/boot/Makefile2
-rw-r--r--arch/parisc/Makefile2
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/Makefile2
-rw-r--r--arch/powerpc/Makefile.postlink2
-rw-r--r--arch/powerpc/kernel/prom_init_check.sh2
-rw-r--r--arch/riscv/Kconfig1
-rw-r--r--arch/riscv/Makefile2
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/um/Kconfig1
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/entry/vdso/Makefile3
-rw-r--r--drivers/gpu/drm/amd/display/dc/calcs/Makefile6
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/Makefile4
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn21/Makefile2
-rw-r--r--drivers/gpu/drm/amd/display/dc/dml/Makefile25
-rw-r--r--drivers/gpu/drm/amd/display/dc/dsc/Makefile7
-rw-r--r--drivers/gpu/drm/i915/Makefile2
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/hw_atl/Makefile2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/accel/Makefile2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/diag/Makefile2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/Makefile2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/xsk/Makefile1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_accel/Makefile2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fpga/Makefile2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/ipoib/Makefile2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/lib/Makefile2
-rw-r--r--drivers/net/ethernet/netronome/nfp/bpf/Makefile2
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/Makefile2
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfpcore/Makefile2
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000/Makefile2
-rw-r--r--drivers/net/ethernet/netronome/nfp/nic/Makefile2
-rw-r--r--include/linux/compiler_types.h20
-rw-r--r--include/linux/export.h42
-rw-r--r--include/linux/vermagic.h2
-rw-r--r--init/Kconfig26
-rw-r--r--init/Makefile5
-rw-r--r--kernel/Makefile2
-rw-r--r--scripts/Kconfig.include3
-rw-r--r--scripts/Makefile2
-rw-r--r--scripts/Makefile.build73
-rw-r--r--scripts/Makefile.clean31
-rw-r--r--scripts/Makefile.extrawarn121
-rw-r--r--scripts/Makefile.host39
-rw-r--r--scripts/Makefile.lib63
-rw-r--r--scripts/Makefile.modfinal60
-rw-r--r--scripts/Makefile.modpost80
-rw-r--r--scripts/Makefile.package (renamed from scripts/package/Makefile)43
-rw-r--r--scripts/basic/Makefile14
-rw-r--r--scripts/genksyms/Makefile11
-rw-r--r--scripts/genksyms/keywords.c6
-rw-r--r--scripts/genksyms/lex.l32
-rw-r--r--scripts/genksyms/parse.y32
-rwxr-xr-xscripts/headers_install.sh72
-rw-r--r--scripts/kconfig/Makefile10
-rwxr-xr-xscripts/kconfig/merge_config.sh12
-rwxr-xr-xscripts/link-vmlinux.sh40
-rwxr-xr-xscripts/mkcompile_h4
-rwxr-xr-xscripts/mkmakefile4
-rw-r--r--scripts/mod/file2alias.c5
-rw-r--r--scripts/mod/modpost.c48
-rw-r--r--usr/include/Makefile4
96 files changed, 763 insertions, 686 deletions
diff --git a/.gitignore b/.gitignore
index 2030c7a4d2f8..ce2c6348d372 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,7 +34,6 @@
34*.mod.c 34*.mod.c
35*.o 35*.o
36*.o.* 36*.o.*
37*.order
38*.patch 37*.patch
39*.s 38*.s
40*.so 39*.so
@@ -46,6 +45,7 @@
46*.xz 45*.xz
47Module.symvers 46Module.symvers
48modules.builtin 47modules.builtin
48modules.order
49 49
50# 50#
51# Top-level generic files 51# Top-level generic files
diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst
index 61b2181ed3ea..f1e5dce86af7 100644
--- a/Documentation/kbuild/kbuild.rst
+++ b/Documentation/kbuild/kbuild.rst
@@ -105,6 +105,15 @@ The output directory can also be specified using "O=...".
105 105
106Setting "O=..." takes precedence over KBUILD_OUTPUT. 106Setting "O=..." takes precedence over KBUILD_OUTPUT.
107 107
108KBUILD_EXTRA_WARN
109-----------------
110Specify the extra build checks. The same value can be assigned by passing
111W=... from the command line.
112
113See `make help` for the list of the supported values.
114
115Setting "W=..." takes precedence over KBUILD_EXTRA_WARN.
116
108KBUILD_DEBARCH 117KBUILD_DEBARCH
109-------------- 118--------------
110For the deb-pkg target, allows overriding the normal heuristics deployed by 119For the deb-pkg target, allows overriding the normal heuristics deployed by
@@ -241,11 +250,6 @@ To get all available archs you can also specify all. E.g.::
241 250
242 $ make ALLSOURCE_ARCHS=all tags 251 $ make ALLSOURCE_ARCHS=all tags
243 252
244KBUILD_ENABLE_EXTRA_GCC_CHECKS
245------------------------------
246If enabled over the make command line with "W=1", it turns on additional
247gcc -W... options for more extensive build-time checking.
248
249KBUILD_BUILD_TIMESTAMP 253KBUILD_BUILD_TIMESTAMP
250---------------------- 254----------------------
251Setting this to a date string overrides the timestamp used in the 255Setting this to a date string overrides the timestamp used in the
@@ -258,17 +262,3 @@ KBUILD_BUILD_USER, KBUILD_BUILD_HOST
258These two variables allow to override the user@host string displayed during 262These two variables allow to override the user@host string displayed during
259boot and in /proc/version. The default value is the output of the commands 263boot and in /proc/version. The default value is the output of the commands
260whoami and host, respectively. 264whoami and host, respectively.
261
262KBUILD_LDS
263----------
264The linker script with full path. Assigned by the top-level Makefile.
265
266KBUILD_VMLINUX_OBJS
267-------------------
268All object files for vmlinux. They are linked to vmlinux in the same
269order as listed in KBUILD_VMLINUX_OBJS.
270
271KBUILD_VMLINUX_LIBS
272-------------------
273All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS
274together specify all the object files used to link vmlinux.
diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
index f4f0f7ffde2b..6ba9d5365ff3 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -471,21 +471,6 @@ more details, with real examples.
471 The second argument is optional, and if supplied will be used 471 The second argument is optional, and if supplied will be used
472 if first argument is not supported. 472 if first argument is not supported.
473 473
474 cc-ldoption
475 cc-ldoption is used to check if $(CC) when used to link object files
476 supports the given option. An optional second option may be
477 specified if first option are not supported.
478
479 Example::
480
481 #arch/x86/kernel/Makefile
482 vsyscall-flags += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
483
484 In the above example, vsyscall-flags will be assigned the option
485 -Wl$(comma)--hash-style=sysv if it is supported by $(CC).
486 The second argument is optional, and if supplied will be used
487 if first argument is not supported.
488
489 as-instr 474 as-instr
490 as-instr checks if the assembler reports a specific instruction 475 as-instr checks if the assembler reports a specific instruction
491 and then outputs either option1 or option2 476 and then outputs either option1 or option2
@@ -765,7 +750,8 @@ Files matching the patterns "*.[oas]", "*.ko", plus some additional files
765generated by kbuild are deleted all over the kernel src tree when 750generated by kbuild are deleted all over the kernel src tree when
766"make clean" is executed. 751"make clean" is executed.
767 752
768Additional files can be specified in kbuild makefiles by use of $(clean-files). 753Additional files or directories can be specified in kbuild makefiles by use of
754$(clean-files).
769 755
770 Example:: 756 Example::
771 757
@@ -776,23 +762,8 @@ When executing "make clean", the file "crc32table.h" will be deleted.
776Kbuild will assume files to be in the same relative directory as the 762Kbuild will assume files to be in the same relative directory as the
777Makefile, except if prefixed with $(objtree). 763Makefile, except if prefixed with $(objtree).
778 764
779To delete a directory hierarchy use: 765To exclude certain files or directories from make clean, use the
780 766$(no-clean-files) variable.
781 Example::
782
783 #scripts/package/Makefile
784 clean-dirs := $(objtree)/debian/
785
786This will delete the directory debian in the toplevel directory, including all
787subdirectories.
788
789To exclude certain files from make clean, use the $(no-clean-files) variable.
790This is only a special case used in the top level Kbuild file:
791
792 Example::
793
794 #Kbuild
795 no-clean-files := $(bounds-file) $(offsets-file)
796 767
797Usually kbuild descends down in subdirectories due to "obj-* := dir/", 768Usually kbuild descends down in subdirectories due to "obj-* := dir/",
798but in the architecture makefiles where the kbuild infrastructure 769but in the architecture makefiles where the kbuild infrastructure
@@ -988,13 +959,25 @@ When kbuild executes, the following steps are followed (roughly):
988 $(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic 959 $(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic
989 mode) if this option is supported by $(AR). 960 mode) if this option is supported by $(AR).
990 961
991 ARCH_CPPFLAGS, ARCH_AFLAGS, ARCH_CFLAGS Overrides the kbuild defaults 962 KBUILD_LDS
963
964 The linker script with full path. Assigned by the top-level Makefile.
965
966 KBUILD_LDS_MODULE
967
968 The module linker script with full path. Assigned by the top-level
969 Makefile and additionally by the arch Makefile.
970
971 KBUILD_VMLINUX_OBJS
972
973 All object files for vmlinux. They are linked to vmlinux in the same
974 order as listed in KBUILD_VMLINUX_OBJS.
992 975
993 These variables are appended to the KBUILD_CPPFLAGS, 976 KBUILD_VMLINUX_LIBS
994 KBUILD_AFLAGS, and KBUILD_CFLAGS, respectively, after the
995 top-level Makefile has set any other flags. This provides a
996 means for an architecture to override the defaults.
997 977
978 All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and
979 KBUILD_VMLINUX_LIBS together specify all the object files used to
980 link vmlinux.
998 981
9996.2 Add prerequisites to archheaders 9826.2 Add prerequisites to archheaders
1000------------------------------------ 983------------------------------------
@@ -1139,7 +1122,7 @@ When kbuild executes, the following steps are followed (roughly):
1139 1122
1140 header-test-y 1123 header-test-y
1141 1124
1142 header-test-y specifies headers (*.h) in the current directory that 1125 header-test-y specifies headers (`*.h`) in the current directory that
1143 should be compile tested to ensure they are self-contained, 1126 should be compile tested to ensure they are self-contained,
1144 i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled, 1127 i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled,
1145 this builds them as part of extra-y. 1128 this builds them as part of extra-y.
@@ -1147,11 +1130,11 @@ When kbuild executes, the following steps are followed (roughly):
1147 header-test-pattern-y 1130 header-test-pattern-y
1148 1131
1149 This works as a weaker version of header-test-y, and accepts wildcard 1132 This works as a weaker version of header-test-y, and accepts wildcard
1150 patterns. The typical usage is: 1133 patterns. The typical usage is::
1151 1134
1152 header-test-pattern-y += *.h 1135 header-test-pattern-y += *.h
1153 1136
1154 This specifies all the files that matches to '*.h' in the current 1137 This specifies all the files that matches to `*.h` in the current
1155 directory, but the files in 'header-test-' are excluded. 1138 directory, but the files in 'header-test-' are excluded.
1156 1139
11576.7 Commands useful for building a boot image 11406.7 Commands useful for building a boot image
diff --git a/Kbuild b/Kbuild
index 8637fd14135f..3109ac786e76 100644
--- a/Kbuild
+++ b/Kbuild
@@ -18,8 +18,6 @@ $(bounds-file): kernel/bounds.s FORCE
18 18
19timeconst-file := include/generated/timeconst.h 19timeconst-file := include/generated/timeconst.h
20 20
21targets += $(timeconst-file)
22
23filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $< 21filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $<
24 22
25$(timeconst-file): kernel/time/timeconst.bc FORCE 23$(timeconst-file): kernel/time/timeconst.bc FORCE
@@ -42,7 +40,6 @@ $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
42# Check for missing system calls 40# Check for missing system calls
43 41
44always += missing-syscalls 42always += missing-syscalls
45targets += missing-syscalls
46 43
47quiet_cmd_syscalls = CALL $< 44quiet_cmd_syscalls = CALL $<
48 cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags) 45 cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
@@ -54,13 +51,9 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
54# Check atomic headers are up-to-date 51# Check atomic headers are up-to-date
55 52
56always += old-atomics 53always += old-atomics
57targets += old-atomics
58 54
59quiet_cmd_atomics = CALL $< 55quiet_cmd_atomics = CALL $<
60 cmd_atomics = $(CONFIG_SHELL) $< 56 cmd_atomics = $(CONFIG_SHELL) $<
61 57
62old-atomics: scripts/atomic/check-atomics.sh FORCE 58old-atomics: scripts/atomic/check-atomics.sh FORCE
63 $(call cmd,atomics) 59 $(call cmd,atomics)
64
65# Keep these three files during make clean
66no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)
diff --git a/Makefile b/Makefile
index 2fa7cfa6fca3..656a8c95789d 100644
--- a/Makefile
+++ b/Makefile
@@ -230,6 +230,8 @@ endif
230 230
231export KBUILD_CHECKSRC KBUILD_EXTMOD 231export KBUILD_CHECKSRC KBUILD_EXTMOD
232 232
233extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
234
233ifeq ($(abs_srctree),$(abs_objtree)) 235ifeq ($(abs_srctree),$(abs_objtree))
234 # building in the source tree 236 # building in the source tree
235 srctree := . 237 srctree := .
@@ -271,52 +273,62 @@ no-dot-config-targets := $(clean-targets) \
271 %asm-generic kernelversion %src-pkg 273 %asm-generic kernelversion %src-pkg
272no-sync-config-targets := $(no-dot-config-targets) install %install \ 274no-sync-config-targets := $(no-dot-config-targets) install %install \
273 kernelrelease 275 kernelrelease
276single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
274 277
275config-targets := 0 278config-build :=
276mixed-targets := 0 279mixed-build :=
277dot-config := 1 280need-config := 1
278may-sync-config := 1 281may-sync-config := 1
282single-build :=
279 283
280ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) 284ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
281 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) 285 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
282 dot-config := 0 286 need-config :=
283 endif 287 endif
284endif 288endif
285 289
286ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) 290ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
287 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) 291 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
288 may-sync-config := 0 292 may-sync-config :=
289 endif 293 endif
290endif 294endif
291 295
292ifneq ($(KBUILD_EXTMOD),) 296ifneq ($(KBUILD_EXTMOD),)
293 may-sync-config := 0 297 may-sync-config :=
294endif 298endif
295 299
296ifeq ($(KBUILD_EXTMOD),) 300ifeq ($(KBUILD_EXTMOD),)
297 ifneq ($(filter config %config,$(MAKECMDGOALS)),) 301 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
298 config-targets := 1 302 config-build := 1
299 ifneq ($(words $(MAKECMDGOALS)),1) 303 ifneq ($(words $(MAKECMDGOALS)),1)
300 mixed-targets := 1 304 mixed-build := 1
301 endif 305 endif
302 endif 306 endif
303endif 307endif
304 308
309# We cannot build single targets and the others at the same time
310ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
311 single-build := 1
312 ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
313 mixed-build := 1
314 endif
315endif
316
305# For "make -j clean all", "make -j mrproper defconfig all", etc. 317# For "make -j clean all", "make -j mrproper defconfig all", etc.
306ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),) 318ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
307 ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),) 319 ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
308 mixed-targets := 1 320 mixed-build := 1
309 endif 321 endif
310endif 322endif
311 323
312# install and modules_install need also be processed one by one 324# install and modules_install need also be processed one by one
313ifneq ($(filter install,$(MAKECMDGOALS)),) 325ifneq ($(filter install,$(MAKECMDGOALS)),)
314 ifneq ($(filter modules_install,$(MAKECMDGOALS)),) 326 ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
315 mixed-targets := 1 327 mixed-build := 1
316 endif 328 endif
317endif 329endif
318 330
319ifeq ($(mixed-targets),1) 331ifdef mixed-build
320# =========================================================================== 332# ===========================================================================
321# We're called with mixed targets (*config and build targets). 333# We're called with mixed targets (*config and build targets).
322# Handle them one by one. 334# Handle them one by one.
@@ -332,7 +344,7 @@ __build_one_by_one:
332 $(MAKE) -f $(srctree)/Makefile $$i; \ 344 $(MAKE) -f $(srctree)/Makefile $$i; \
333 done 345 done
334 346
335else 347else # !mixed-build
336 348
337include scripts/Kbuild.include 349include scripts/Kbuild.include
338 350
@@ -392,9 +404,7 @@ KCONFIG_CONFIG ?= .config
392export KCONFIG_CONFIG 404export KCONFIG_CONFIG
393 405
394# SHELL used by kbuild 406# SHELL used by kbuild
395CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 407CONFIG_SHELL := sh
396 else if [ -x /bin/bash ]; then echo /bin/bash; \
397 else echo sh; fi ; fi)
398 408
399HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null) 409HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
400HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null) 410HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
@@ -431,6 +441,7 @@ PYTHON = python
431PYTHON2 = python2 441PYTHON2 = python2
432PYTHON3 = python3 442PYTHON3 = python3
433CHECK = sparse 443CHECK = sparse
444BASH = bash
434 445
435CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ 446CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
436 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) 447 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
@@ -470,12 +481,13 @@ KBUILD_AFLAGS_KERNEL :=
470KBUILD_CFLAGS_KERNEL := 481KBUILD_CFLAGS_KERNEL :=
471KBUILD_AFLAGS_MODULE := -DMODULE 482KBUILD_AFLAGS_MODULE := -DMODULE
472KBUILD_CFLAGS_MODULE := -DMODULE 483KBUILD_CFLAGS_MODULE := -DMODULE
473KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds 484KBUILD_LDFLAGS_MODULE :=
485export KBUILD_LDS_MODULE := $(srctree)/scripts/module-common.lds
474KBUILD_LDFLAGS := 486KBUILD_LDFLAGS :=
475GCC_PLUGINS_CFLAGS := 487GCC_PLUGINS_CFLAGS :=
476CLANG_FLAGS := 488CLANG_FLAGS :=
477 489
478export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC 490export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
479export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK INSTALLKERNEL 491export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK INSTALLKERNEL
480export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX 492export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
481export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE 493export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
@@ -506,6 +518,7 @@ scripts_basic:
506 $(Q)rm -f .tmp_quiet_recordmcount 518 $(Q)rm -f .tmp_quiet_recordmcount
507 519
508PHONY += outputmakefile 520PHONY += outputmakefile
521# Before starting out-of-tree build, make sure the source tree is clean.
509# outputmakefile generates a Makefile in the output directory, if using a 522# outputmakefile generates a Makefile in the output directory, if using a
510# separate output directory. This allows convenient use of make in the 523# separate output directory. This allows convenient use of make in the
511# output directory. 524# output directory.
@@ -513,6 +526,15 @@ PHONY += outputmakefile
513# ignore whole output directory 526# ignore whole output directory
514outputmakefile: 527outputmakefile:
515ifdef building_out_of_srctree 528ifdef building_out_of_srctree
529 $(Q)if [ -f $(srctree)/.config -o \
530 -d $(srctree)/include/config -o \
531 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
532 echo >&2 "***"; \
533 echo >&2 "*** The source tree is not clean, please run 'make$(if $(findstring command line, $(origin ARCH)), ARCH=$(ARCH)) mrproper'"; \
534 echo >&2 "*** in $(abs_srctree)";\
535 echo >&2 "***"; \
536 false; \
537 fi
516 $(Q)ln -fsn $(srctree) source 538 $(Q)ln -fsn $(srctree) source
517 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) 539 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
518 $(Q)test -e .gitignore || \ 540 $(Q)test -e .gitignore || \
@@ -544,7 +566,7 @@ endif
544# and from include/config/auto.conf.cmd to detect the compiler upgrade. 566# and from include/config/auto.conf.cmd to detect the compiler upgrade.
545CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1) 567CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1)
546 568
547ifeq ($(config-targets),1) 569ifdef config-build
548# =========================================================================== 570# ===========================================================================
549# *config targets only - make sure prerequisites are updated, and descend 571# *config targets only - make sure prerequisites are updated, and descend
550# in scripts/kconfig to make the *config target 572# in scripts/kconfig to make the *config target
@@ -555,13 +577,13 @@ ifeq ($(config-targets),1)
555include arch/$(SRCARCH)/Makefile 577include arch/$(SRCARCH)/Makefile
556export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT 578export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
557 579
558config: scripts_basic outputmakefile FORCE 580config: outputmakefile scripts_basic FORCE
559 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 581 $(Q)$(MAKE) $(build)=scripts/kconfig $@
560 582
561%config: scripts_basic outputmakefile FORCE 583%config: outputmakefile scripts_basic FORCE
562 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 584 $(Q)$(MAKE) $(build)=scripts/kconfig $@
563 585
564else 586else #!config-build
565# =========================================================================== 587# ===========================================================================
566# Build targets only - this includes vmlinux, arch specific targets, clean 588# Build targets only - this includes vmlinux, arch specific targets, clean
567# targets and others. In general all targets except *config targets. 589# targets and others. In general all targets except *config targets.
@@ -604,7 +626,7 @@ endif
604 626
605export KBUILD_MODULES KBUILD_BUILTIN 627export KBUILD_MODULES KBUILD_BUILTIN
606 628
607ifeq ($(dot-config),1) 629ifdef need-config
608include include/config/auto.conf 630include include/config/auto.conf
609endif 631endif
610 632
@@ -645,15 +667,10 @@ RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc
645export RETPOLINE_CFLAGS 667export RETPOLINE_CFLAGS
646export RETPOLINE_VDSO_CFLAGS 668export RETPOLINE_VDSO_CFLAGS
647 669
648# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
649# values of the respective KBUILD_* variables
650ARCH_CPPFLAGS :=
651ARCH_AFLAGS :=
652ARCH_CFLAGS :=
653include arch/$(SRCARCH)/Makefile 670include arch/$(SRCARCH)/Makefile
654 671
655ifeq ($(dot-config),1) 672ifdef need-config
656ifeq ($(may-sync-config),1) 673ifdef may-sync-config
657# Read in dependencies to all Kconfig* files, make sure to run syncconfig if 674# Read in dependencies to all Kconfig* files, make sure to run syncconfig if
658# changes are detected. This should be included after arch/$(SRCARCH)/Makefile 675# changes are detected. This should be included after arch/$(SRCARCH)/Makefile
659# because some architectures define CROSS_COMPILE there. 676# because some architectures define CROSS_COMPILE there.
@@ -676,7 +693,7 @@ $(KCONFIG_CONFIG):
676# The syncconfig should be executed only once to make all the targets. 693# The syncconfig should be executed only once to make all the targets.
677%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG) 694%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
678 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig 695 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
679else 696else # !may-sync-config
680# External modules and some install targets need include/generated/autoconf.h 697# External modules and some install targets need include/generated/autoconf.h
681# and include/config/auto.conf but do not care if they are up-to-date. 698# and include/config/auto.conf but do not care if they are up-to-date.
682# Use auto.conf to trigger the test 699# Use auto.conf to trigger the test
@@ -692,7 +709,7 @@ include/config/auto.conf:
692 /bin/false) 709 /bin/false)
693 710
694endif # may-sync-config 711endif # may-sync-config
695endif # $(dot-config) 712endif # need-config
696 713
697KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) 714KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
698KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) 715KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
@@ -700,10 +717,12 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
700KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) 717KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
701KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) 718KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
702 719
703ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 720ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
704KBUILD_CFLAGS += -Os 721KBUILD_CFLAGS += -O2
705else 722else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
706KBUILD_CFLAGS += -O2 723KBUILD_CFLAGS += -O3
724else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
725KBUILD_CFLAGS += -Os
707endif 726endif
708 727
709ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED 728ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED
@@ -751,6 +770,11 @@ else
751# These warnings generated too much noise in a regular build. 770# These warnings generated too much noise in a regular build.
752# Use make W=1 to enable them (see scripts/Makefile.extrawarn) 771# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
753KBUILD_CFLAGS += -Wno-unused-but-set-variable 772KBUILD_CFLAGS += -Wno-unused-but-set-variable
773
774# Warn about unmarked fall-throughs in switch statement.
775# Disabled for clang while comment to attribute conversion happens and
776# https://github.com/ClangBuiltLinux/linux/issues/636 is discussed.
777KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
754endif 778endif
755 779
756KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) 780KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
@@ -845,9 +869,6 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
845# warn about C99 declaration after statement 869# warn about C99 declaration after statement
846KBUILD_CFLAGS += -Wdeclaration-after-statement 870KBUILD_CFLAGS += -Wdeclaration-after-statement
847 871
848# Warn about unmarked fall-throughs in switch statement.
849KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
850
851# Variable Length Arrays (VLAs) should not be used anywhere in the kernel 872# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
852KBUILD_CFLAGS += -Wvla 873KBUILD_CFLAGS += -Wvla
853 874
@@ -900,11 +921,10 @@ include scripts/Makefile.kasan
900include scripts/Makefile.extrawarn 921include scripts/Makefile.extrawarn
901include scripts/Makefile.ubsan 922include scripts/Makefile.ubsan
902 923
903# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the 924# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
904# last assignments 925KBUILD_CPPFLAGS += $(KCPPFLAGS)
905KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS) 926KBUILD_AFLAGS += $(KAFLAGS)
906KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS) 927KBUILD_CFLAGS += $(KCFLAGS)
907KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS)
908 928
909KBUILD_LDFLAGS_MODULE += --build-id 929KBUILD_LDFLAGS_MODULE += --build-id
910LDFLAGS_vmlinux += --build-id 930LDFLAGS_vmlinux += --build-id
@@ -1007,7 +1027,7 @@ endif
1007 1027
1008PHONY += prepare0 1028PHONY += prepare0
1009 1029
1010export MODORDER := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order 1030export MODORDER := $(extmod-prefix)modules.order
1011 1031
1012ifeq ($(KBUILD_EXTMOD),) 1032ifeq ($(KBUILD_EXTMOD),)
1013core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ 1033core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
@@ -1020,6 +1040,9 @@ vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \
1020 $(patsubst %/,%,$(filter %/, $(init-) $(core-) \ 1040 $(patsubst %/,%,$(filter %/, $(init-) $(core-) \
1021 $(drivers-) $(net-) $(libs-) $(virt-)))) 1041 $(drivers-) $(net-) $(libs-) $(virt-))))
1022 1042
1043build-dirs := $(vmlinux-dirs)
1044clean-dirs := $(vmlinux-alldirs)
1045
1023init-y := $(patsubst %/, %/built-in.a, $(init-y)) 1046init-y := $(patsubst %/, %/built-in.a, $(init-y))
1024core-y := $(patsubst %/, %/built-in.a, $(core-y)) 1047core-y := $(patsubst %/, %/built-in.a, $(core-y))
1025drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) 1048drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y))
@@ -1042,7 +1065,7 @@ vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
1042# Recurse until adjust_autoksyms.sh is satisfied 1065# Recurse until adjust_autoksyms.sh is satisfied
1043PHONY += autoksyms_recursive 1066PHONY += autoksyms_recursive
1044ifdef CONFIG_TRIM_UNUSED_KSYMS 1067ifdef CONFIG_TRIM_UNUSED_KSYMS
1045autoksyms_recursive: $(vmlinux-deps) modules.order 1068autoksyms_recursive: descend modules.order
1046 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ 1069 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
1047 "$(MAKE) -f $(srctree)/Makefile vmlinux" 1070 "$(MAKE) -f $(srctree)/Makefile vmlinux"
1048endif 1071endif
@@ -1074,17 +1097,7 @@ targets := vmlinux
1074 1097
1075# The actual objects are generated when descending, 1098# The actual objects are generated when descending,
1076# make sure no implicit rule kicks in 1099# make sure no implicit rule kicks in
1077$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; 1100$(sort $(vmlinux-deps)): descend ;
1078
1079# Handle descending into subdirectories listed in $(vmlinux-dirs)
1080# Preset locale variables to speed up the build process. Limit locale
1081# tweaks to this spot to avoid wrong language settings when running
1082# make menuconfig etc.
1083# Error messages still appears in the original language
1084
1085PHONY += $(vmlinux-dirs)
1086$(vmlinux-dirs): prepare
1087 $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1
1088 1101
1089filechk_kernel.release = \ 1102filechk_kernel.release = \
1090 echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" 1103 echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
@@ -1106,24 +1119,9 @@ scripts: scripts_basic scripts_dtc
1106# archprepare is used in arch Makefiles and when processed asm symlink, 1119# archprepare is used in arch Makefiles and when processed asm symlink,
1107# version.h and scripts_basic is processed / created. 1120# version.h and scripts_basic is processed / created.
1108 1121
1109PHONY += prepare archprepare prepare3 1122PHONY += prepare archprepare
1110 1123
1111# prepare3 is used to check if we are building in a separate output directory, 1124archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
1112# and if so do:
1113# 1) Check that make has not been executed in the kernel src $(srctree)
1114prepare3: include/config/kernel.release
1115ifdef building_out_of_srctree
1116 @$(kecho) ' Using $(srctree) as source for kernel'
1117 $(Q)if [ -f $(srctree)/.config -o \
1118 -d $(srctree)/include/config -o \
1119 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
1120 echo >&2 " $(srctree) is not clean, please run 'make ARCH=$(ARCH) mrproper'"; \
1121 echo >&2 " in the '$(srctree)' directory.";\
1122 /bin/false; \
1123 fi;
1124endif
1125
1126archprepare: archheaders archscripts scripts prepare3 outputmakefile \
1127 asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h 1125 asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h
1128 1126
1129prepare0: archprepare 1127prepare0: archprepare
@@ -1248,7 +1246,7 @@ kselftest-merge:
1248 $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!)) 1246 $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!))
1249 $(Q)find $(srctree)/tools/testing/selftests -name config | \ 1247 $(Q)find $(srctree)/tools/testing/selftests -name config | \
1250 xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config 1248 xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
1251 +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 1249 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1252 1250
1253# --------------------------------------------------------------------------- 1251# ---------------------------------------------------------------------------
1254# Devicetree files 1252# Devicetree files
@@ -1259,11 +1257,11 @@ endif
1259 1257
1260ifneq ($(dtstree),) 1258ifneq ($(dtstree),)
1261 1259
1262%.dtb: prepare3 scripts_dtc 1260%.dtb: include/config/kernel.release scripts_dtc
1263 $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ 1261 $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
1264 1262
1265PHONY += dtbs dtbs_install dt_binding_check 1263PHONY += dtbs dtbs_install dt_binding_check
1266dtbs dtbs_check: prepare3 scripts_dtc 1264dtbs dtbs_check: include/config/kernel.release scripts_dtc
1267 $(Q)$(MAKE) $(build)=$(dtstree) 1265 $(Q)$(MAKE) $(build)=$(dtstree)
1268 1266
1269dtbs_check: export CHECK_DTBS=1 1267dtbs_check: export CHECK_DTBS=1
@@ -1302,17 +1300,16 @@ all: modules
1302 1300
1303PHONY += modules 1301PHONY += modules
1304modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules.builtin 1302modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules.builtin
1305 @$(kecho) ' Building modules, stage 2.';
1306 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1303 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1307 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh 1304 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh
1308 1305
1309modules.order: $(vmlinux-dirs) 1306modules.order: descend
1310 $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@ 1307 $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
1311 1308
1312modbuiltin-dirs := $(addprefix _modbuiltin_, $(vmlinux-dirs)) 1309modbuiltin-dirs := $(addprefix _modbuiltin_, $(build-dirs))
1313 1310
1314modules.builtin: $(modbuiltin-dirs) 1311modules.builtin: $(modbuiltin-dirs)
1315 $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@ 1312 $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
1316 1313
1317PHONY += $(modbuiltin-dirs) 1314PHONY += $(modbuiltin-dirs)
1318# tristate.conf is not included from this Makefile. Add it as a prerequisite 1315# tristate.conf is not included from this Makefile. Add it as a prerequisite
@@ -1385,12 +1382,14 @@ CLEAN_FILES += modules.builtin.modinfo
1385 1382
1386# Directories & files removed with 'make mrproper' 1383# Directories & files removed with 'make mrproper'
1387MRPROPER_DIRS += include/config include/generated \ 1384MRPROPER_DIRS += include/config include/generated \
1388 arch/$(SRCARCH)/include/generated .tmp_objdiff 1385 arch/$(SRCARCH)/include/generated .tmp_objdiff \
1386 debian/ snap/ tar-install/
1389MRPROPER_FILES += .config .config.old .version \ 1387MRPROPER_FILES += .config .config.old .version \
1390 Module.symvers \ 1388 Module.symvers \
1391 signing_key.pem signing_key.priv signing_key.x509 \ 1389 signing_key.pem signing_key.priv signing_key.x509 \
1392 x509.genkey extra_certificates signing_key.x509.keyid \ 1390 x509.genkey extra_certificates signing_key.x509.keyid \
1393 signing_key.x509.signer vmlinux-gdb.py 1391 signing_key.x509.signer vmlinux-gdb.py \
1392 *.spec
1394 1393
1395# Directories & files removed with 'make distclean' 1394# Directories & files removed with 'make distclean'
1396DISTCLEAN_DIRS += 1395DISTCLEAN_DIRS +=
@@ -1400,11 +1399,8 @@ DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
1400# 1399#
1401clean: rm-dirs := $(CLEAN_DIRS) 1400clean: rm-dirs := $(CLEAN_DIRS)
1402clean: rm-files := $(CLEAN_FILES) 1401clean: rm-files := $(CLEAN_FILES)
1403clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs))
1404 1402
1405PHONY += $(clean-dirs) clean archclean vmlinuxclean 1403PHONY += archclean vmlinuxclean
1406$(clean-dirs):
1407 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1408 1404
1409vmlinuxclean: 1405vmlinuxclean:
1410 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean 1406 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
@@ -1445,13 +1441,11 @@ distclean: mrproper
1445 1441
1446# Packaging of the kernel to various formats 1442# Packaging of the kernel to various formats
1447# --------------------------------------------------------------------------- 1443# ---------------------------------------------------------------------------
1448package-dir := scripts/package
1449 1444
1450%src-pkg: FORCE 1445%src-pkg: FORCE
1451 $(Q)$(MAKE) $(build)=$(package-dir) $@ 1446 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1452%pkg: include/config/kernel.release FORCE 1447%pkg: include/config/kernel.release FORCE
1453 $(Q)$(MAKE) $(build)=$(package-dir) $@ 1448 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1454
1455 1449
1456# Brief documentation of the typical targets used 1450# Brief documentation of the typical targets used
1457# --------------------------------------------------------------------------- 1451# ---------------------------------------------------------------------------
@@ -1525,7 +1519,7 @@ help:
1525 @echo ' or "cd tools; make help"' 1519 @echo ' or "cd tools; make help"'
1526 @echo '' 1520 @echo ''
1527 @echo 'Kernel packaging:' 1521 @echo 'Kernel packaging:'
1528 @$(MAKE) $(build)=$(package-dir) help 1522 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1529 @echo '' 1523 @echo ''
1530 @echo 'Documentation targets:' 1524 @echo 'Documentation targets:'
1531 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp 1525 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
@@ -1550,7 +1544,7 @@ help:
1550 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK (sparse by default)' 1544 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK (sparse by default)'
1551 @echo ' make C=2 [targets] Force check of all c source with $$CHECK' 1545 @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
1552 @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' 1546 @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
1553 @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' 1547 @echo ' make W=n [targets] Enable extra build checks, n=1,2,3 where'
1554 @echo ' 1: warnings which may be relevant and do not occur too often' 1548 @echo ' 1: warnings which may be relevant and do not occur too often'
1555 @echo ' 2: warnings which occur quite often but may still be relevant' 1549 @echo ' 2: warnings which occur quite often but may still be relevant'
1556 @echo ' 3: more obscure warnings, can most likely be ignored' 1550 @echo ' 3: more obscure warnings, can most likely be ignored'
@@ -1579,7 +1573,7 @@ $(help-board-dirs): help-%:
1579DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \ 1573DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
1580 linkcheckdocs dochelp refcheckdocs 1574 linkcheckdocs dochelp refcheckdocs
1581PHONY += $(DOC_TARGETS) 1575PHONY += $(DOC_TARGETS)
1582$(DOC_TARGETS): scripts_basic FORCE 1576$(DOC_TARGETS):
1583 $(Q)$(MAKE) $(build)=Documentation $@ 1577 $(Q)$(MAKE) $(build)=Documentation $@
1584 1578
1585# Misc 1579# Misc
@@ -1624,13 +1618,9 @@ $(objtree)/Module.symvers:
1624 echo " is missing; modules will have no dependencies and modversions."; \ 1618 echo " is missing; modules will have no dependencies and modversions."; \
1625 echo ) 1619 echo )
1626 1620
1627module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) 1621build-dirs := $(KBUILD_EXTMOD)
1628PHONY += $(module-dirs) modules 1622PHONY += modules
1629$(module-dirs): prepare $(objtree)/Module.symvers 1623modules: descend $(objtree)/Module.symvers
1630 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) need-modorder=1
1631
1632modules: $(module-dirs)
1633 @$(kecho) ' Building modules, stage 2.';
1634 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1624 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1635 1625
1636PHONY += modules_install 1626PHONY += modules_install
@@ -1646,14 +1636,13 @@ PHONY += _emodinst_post
1646_emodinst_post: _emodinst_ 1636_emodinst_post: _emodinst_
1647 $(call cmd,depmod) 1637 $(call cmd,depmod)
1648 1638
1649clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) 1639clean-dirs := $(KBUILD_EXTMOD)
1650
1651PHONY += $(clean-dirs) clean
1652$(clean-dirs):
1653 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1654
1655clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers 1640clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
1656 1641
1642PHONY += /
1643/:
1644 @echo >&2 '"$(MAKE) /" is no longer supported. Please use "$(MAKE) ./" instead.'
1645
1657PHONY += help 1646PHONY += help
1658help: 1647help:
1659 @echo ' Building external modules.' 1648 @echo ' Building external modules.'
@@ -1667,6 +1656,21 @@ help:
1667PHONY += prepare 1656PHONY += prepare
1668endif # KBUILD_EXTMOD 1657endif # KBUILD_EXTMOD
1669 1658
1659# Handle descending into subdirectories listed in $(build-dirs)
1660# Preset locale variables to speed up the build process. Limit locale
1661# tweaks to this spot to avoid wrong language settings when running
1662# make menuconfig etc.
1663# Error messages still appears in the original language
1664PHONY += descend $(build-dirs)
1665descend: $(build-dirs)
1666$(build-dirs): prepare
1667 $(Q)$(MAKE) $(build)=$@ single-build=$(single-build) need-builtin=1 need-modorder=1
1668
1669clean-dirs := $(addprefix _clean_, $(clean-dirs))
1670PHONY += $(clean-dirs) clean
1671$(clean-dirs):
1672 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1673
1670clean: $(clean-dirs) 1674clean: $(clean-dirs)
1671 $(call cmd,rmdirs) 1675 $(call cmd,rmdirs)
1672 $(call cmd,rmfiles) 1676 $(call cmd,rmfiles)
@@ -1688,7 +1692,7 @@ clean: $(clean-dirs)
1688# Generate tags for editors 1692# Generate tags for editors
1689# --------------------------------------------------------------------------- 1693# ---------------------------------------------------------------------------
1690quiet_cmd_tags = GEN $@ 1694quiet_cmd_tags = GEN $@
1691 cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@ 1695 cmd_tags = $(BASH) $(srctree)/scripts/tags.sh $@
1692 1696
1693tags TAGS cscope gtags: FORCE 1697tags TAGS cscope gtags: FORCE
1694 $(call cmd,tags) 1698 $(call cmd,tags)
@@ -1709,7 +1713,7 @@ versioncheck:
1709 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl 1713 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
1710 1714
1711coccicheck: 1715coccicheck:
1712 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@ 1716 $(Q)$(BASH) $(srctree)/scripts/$@
1713 1717
1714namespacecheck: 1718namespacecheck:
1715 $(PERL) $(srctree)/scripts/namespace.pl 1719 $(PERL) $(srctree)/scripts/namespace.pl
@@ -1757,45 +1761,47 @@ tools/%: FORCE
1757 1761
1758# Single targets 1762# Single targets
1759# --------------------------------------------------------------------------- 1763# ---------------------------------------------------------------------------
1760# Single targets are compatible with: 1764# To build individual files in subdirectories, you can do like this:
1761# - build with mixed source and output 1765#
1762# - build with separate output dir 'make O=...' 1766# make foo/bar/baz.s
1763# - external modules
1764# 1767#
1765# target-dir => where to store outputfile 1768# The supported suffixes for single-target are listed in 'single-targets'
1766# build-dir => directory in kernel source tree to use 1769#
1767 1770# To build only under specific subdirectories, you can do like this:
1768build-target = $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD)/)$@ 1771#
1769build-dir = $(patsubst %/,%,$(dir $(build-target))) 1772# make foo/bar/baz/
1770 1773
1771%.i: prepare FORCE 1774ifdef single-build
1772 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1775
1773%.ll: prepare FORCE 1776single-all := $(filter $(single-targets), $(MAKECMDGOALS))
1774 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1777
1775%.lst: prepare FORCE 1778# .ko is special because modpost is needed
1776 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1779single-ko := $(sort $(filter %.ko, $(single-all)))
1777%.o: prepare FORCE 1780single-no-ko := $(sort $(patsubst %.ko,%.mod, $(single-all)))
1778 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1781
1779%.s: prepare FORCE 1782$(single-ko): single_modpost
1780 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1783 @:
1781%.symtypes: prepare FORCE 1784$(single-no-ko): descend
1782 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1785 @:
1786
1783ifeq ($(KBUILD_EXTMOD),) 1787ifeq ($(KBUILD_EXTMOD),)
1784# For the single build of an in-tree module, use a temporary file to avoid 1788# For the single build of in-tree modules, use a temporary file to avoid
1785# the situation of modules_install installing an invalid modules.order. 1789# the situation of modules_install installing an invalid modules.order.
1786%.ko: MODORDER := .modules.tmp 1790MODORDER := .modules.tmp
1787endif 1791endif
1788%.ko: prepare FORCE 1792
1789 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target:.ko=.mod) 1793PHONY += single_modpost
1790 $(Q)echo $(build-target) > $(MODORDER) 1794single_modpost: $(single-no-ko)
1795 $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER)
1791 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1796 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1792 1797
1793# Modules 1798KBUILD_MODULES := 1
1794PHONY += /
1795/: ./
1796 1799
1797%/: prepare FORCE 1800export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko))
1798 $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) need-modorder=1 1801
1802single-build = $(if $(filter-out $@/, $(single-no-ko)),1)
1803
1804endif
1799 1805
1800# FIXME Should go into a make.lib or something 1806# FIXME Should go into a make.lib or something
1801# =========================================================================== 1807# ===========================================================================
@@ -1816,9 +1822,9 @@ existing-targets := $(wildcard $(sort $(targets)))
1816 1822
1817-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 1823-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
1818 1824
1819endif # ifeq ($(config-targets),1) 1825endif # config-targets
1820endif # ifeq ($(mixed-targets),1) 1826endif # mixed-build
1821endif # need-sub-make 1827endif # need-sub-make
1822 1828
1823PHONY += FORCE 1829PHONY += FORCE
1824FORCE: 1830FORCE:
diff --git a/arch/Kconfig b/arch/Kconfig
index c4b2afa138ca..f2a3dc80d46b 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -292,6 +292,13 @@ config ARCH_32BIT_OFF_T
292 still support 32-bit off_t. This option is enabled for all such 292 still support 32-bit off_t. This option is enabled for all such
293 architectures explicitly. 293 architectures explicitly.
294 294
295config HAVE_ASM_MODVERSIONS
296 bool
297 help
298 This symbol should be selected by an architecure if it provides
299 <asm/asm-prototypes.h> to support the module versioning for symbols
300 exported from assembly code.
301
295config HAVE_REGS_AND_STACK_ACCESS_API 302config HAVE_REGS_AND_STACK_ACCESS_API
296 bool 303 bool
297 help 304 help
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index f7b19b813a70..ef179033a7c2 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -11,6 +11,7 @@ config ALPHA
11 select PCI_DOMAINS if PCI 11 select PCI_DOMAINS if PCI
12 select PCI_SYSCALL if PCI 12 select PCI_SYSCALL if PCI
13 select HAVE_AOUT 13 select HAVE_AOUT
14 select HAVE_ASM_MODVERSIONS
14 select HAVE_IDE 15 select HAVE_IDE
15 select HAVE_OPROFILE 16 select HAVE_OPROFILE
16 select HAVE_PCSPKR_PLATFORM 17 select HAVE_PCSPKR_PLATFORM
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index ee6d1184c2b1..f1c44cccf8d6 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -48,14 +48,6 @@ endif
48cfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI) 48cfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI)
49cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables $(cfi) 49cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables $(cfi)
50 50
51ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
52# Generic build system uses -O2, we want -O3
53# Note: No need to add to cflags-y as that happens anyways
54#
55# Disable the false maybe-uninitialized warings gcc spits out at -O3
56ARCH_CFLAGS += -O3 $(call cc-disable-warning,maybe-uninitialized,)
57endif
58
59# small data is default for elf32 tool-chain. If not usable, disable it 51# small data is default for elf32 tool-chain. If not usable, disable it
60# This also allows repurposing GP as scratch reg to gcc reg allocator 52# This also allows repurposing GP as scratch reg to gcc reg allocator
61disable_small_data := y 53disable_small_data := y
diff --git a/arch/arc/configs/axs101_defconfig b/arch/arc/configs/axs101_defconfig
index e31a8ebc3ecc..0016149f9583 100644
--- a/arch/arc/configs/axs101_defconfig
+++ b/arch/arc/configs/axs101_defconfig
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
9# CONFIG_UTS_NS is not set 9# CONFIG_UTS_NS is not set
10# CONFIG_PID_NS is not set 10# CONFIG_PID_NS is not set
11CONFIG_BLK_DEV_INITRD=y 11CONFIG_BLK_DEV_INITRD=y
12CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
12CONFIG_EMBEDDED=y 13CONFIG_EMBEDDED=y
13CONFIG_PERF_EVENTS=y 14CONFIG_PERF_EVENTS=y
14# CONFIG_VM_EVENT_COUNTERS is not set 15# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/axs103_defconfig b/arch/arc/configs/axs103_defconfig
index e0e8567f0d75..5b031582a1cf 100644
--- a/arch/arc/configs/axs103_defconfig
+++ b/arch/arc/configs/axs103_defconfig
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
9# CONFIG_UTS_NS is not set 9# CONFIG_UTS_NS is not set
10# CONFIG_PID_NS is not set 10# CONFIG_PID_NS is not set
11CONFIG_BLK_DEV_INITRD=y 11CONFIG_BLK_DEV_INITRD=y
12CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
12CONFIG_EMBEDDED=y 13CONFIG_EMBEDDED=y
13CONFIG_PERF_EVENTS=y 14CONFIG_PERF_EVENTS=y
14# CONFIG_VM_EVENT_COUNTERS is not set 15# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/axs103_smp_defconfig b/arch/arc/configs/axs103_smp_defconfig
index fcbc952bc75b..d4eec39e0112 100644
--- a/arch/arc/configs/axs103_smp_defconfig
+++ b/arch/arc/configs/axs103_smp_defconfig
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
9# CONFIG_UTS_NS is not set 9# CONFIG_UTS_NS is not set
10# CONFIG_PID_NS is not set 10# CONFIG_PID_NS is not set
11CONFIG_BLK_DEV_INITRD=y 11CONFIG_BLK_DEV_INITRD=y
12CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
12CONFIG_EMBEDDED=y 13CONFIG_EMBEDDED=y
13CONFIG_PERF_EVENTS=y 14CONFIG_PERF_EVENTS=y
14# CONFIG_VM_EVENT_COUNTERS is not set 15# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/haps_hs_defconfig b/arch/arc/configs/haps_hs_defconfig
index 436f2135bdc1..47ff8a97e42d 100644
--- a/arch/arc/configs/haps_hs_defconfig
+++ b/arch/arc/configs/haps_hs_defconfig
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
10# CONFIG_UTS_NS is not set 10# CONFIG_UTS_NS is not set
11# CONFIG_PID_NS is not set 11# CONFIG_PID_NS is not set
12CONFIG_BLK_DEV_INITRD=y 12CONFIG_BLK_DEV_INITRD=y
13CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
13CONFIG_EXPERT=y 14CONFIG_EXPERT=y
14CONFIG_PERF_EVENTS=y 15CONFIG_PERF_EVENTS=y
15# CONFIG_COMPAT_BRK is not set 16# CONFIG_COMPAT_BRK is not set
diff --git a/arch/arc/configs/haps_hs_smp_defconfig b/arch/arc/configs/haps_hs_smp_defconfig
index 33a787c375e2..9685fd5f57a4 100644
--- a/arch/arc/configs/haps_hs_smp_defconfig
+++ b/arch/arc/configs/haps_hs_smp_defconfig
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
10# CONFIG_UTS_NS is not set 10# CONFIG_UTS_NS is not set
11# CONFIG_PID_NS is not set 11# CONFIG_PID_NS is not set
12CONFIG_BLK_DEV_INITRD=y 12CONFIG_BLK_DEV_INITRD=y
13CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
13CONFIG_EMBEDDED=y 14CONFIG_EMBEDDED=y
14CONFIG_PERF_EVENTS=y 15CONFIG_PERF_EVENTS=y
15# CONFIG_VM_EVENT_COUNTERS is not set 16# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/hsdk_defconfig b/arch/arc/configs/hsdk_defconfig
index 403125d9c9a3..9b9a74444ce2 100644
--- a/arch/arc/configs/hsdk_defconfig
+++ b/arch/arc/configs/hsdk_defconfig
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
9# CONFIG_PID_NS is not set 9# CONFIG_PID_NS is not set
10CONFIG_BLK_DEV_INITRD=y 10CONFIG_BLK_DEV_INITRD=y
11CONFIG_BLK_DEV_RAM=y 11CONFIG_BLK_DEV_RAM=y
12CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
12CONFIG_EMBEDDED=y 13CONFIG_EMBEDDED=y
13CONFIG_PERF_EVENTS=y 14CONFIG_PERF_EVENTS=y
14# CONFIG_VM_EVENT_COUNTERS is not set 15# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/nps_defconfig b/arch/arc/configs/nps_defconfig
index f0a077c00efa..5978d4d7d5b0 100644
--- a/arch/arc/configs/nps_defconfig
+++ b/arch/arc/configs/nps_defconfig
@@ -6,6 +6,7 @@ CONFIG_HIGH_RES_TIMERS=y
6CONFIG_IKCONFIG=y 6CONFIG_IKCONFIG=y
7CONFIG_IKCONFIG_PROC=y 7CONFIG_IKCONFIG_PROC=y
8CONFIG_BLK_DEV_INITRD=y 8CONFIG_BLK_DEV_INITRD=y
9CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
9CONFIG_SYSCTL_SYSCALL=y 10CONFIG_SYSCTL_SYSCALL=y
10# CONFIG_EPOLL is not set 11# CONFIG_EPOLL is not set
11# CONFIG_SIGNALFD is not set 12# CONFIG_SIGNALFD is not set
diff --git a/arch/arc/configs/nsim_700_defconfig b/arch/arc/configs/nsim_700_defconfig
index de398c7b10b3..2b9b11474640 100644
--- a/arch/arc/configs/nsim_700_defconfig
+++ b/arch/arc/configs/nsim_700_defconfig
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
10# CONFIG_UTS_NS is not set 10# CONFIG_UTS_NS is not set
11# CONFIG_PID_NS is not set 11# CONFIG_PID_NS is not set
12CONFIG_BLK_DEV_INITRD=y 12CONFIG_BLK_DEV_INITRD=y
13CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
13CONFIG_KALLSYMS_ALL=y 14CONFIG_KALLSYMS_ALL=y
14CONFIG_EMBEDDED=y 15CONFIG_EMBEDDED=y
15CONFIG_PERF_EVENTS=y 16CONFIG_PERF_EVENTS=y
diff --git a/arch/arc/configs/nsim_hs_defconfig b/arch/arc/configs/nsim_hs_defconfig
index 2dbd34a9ff07..bab3dd255841 100644
--- a/arch/arc/configs/nsim_hs_defconfig
+++ b/arch/arc/configs/nsim_hs_defconfig
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
10# CONFIG_UTS_NS is not set 10# CONFIG_UTS_NS is not set
11# CONFIG_PID_NS is not set 11# CONFIG_PID_NS is not set
12CONFIG_BLK_DEV_INITRD=y 12CONFIG_BLK_DEV_INITRD=y
13CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
13CONFIG_KALLSYMS_ALL=y 14CONFIG_KALLSYMS_ALL=y
14CONFIG_EMBEDDED=y 15CONFIG_EMBEDDED=y
15CONFIG_PERF_EVENTS=y 16CONFIG_PERF_EVENTS=y
diff --git a/arch/arc/configs/nsim_hs_smp_defconfig b/arch/arc/configs/nsim_hs_smp_defconfig
index c7135f1e2583..90d2d50fb8dc 100644
--- a/arch/arc/configs/nsim_hs_smp_defconfig
+++ b/arch/arc/configs/nsim_hs_smp_defconfig
@@ -8,6 +8,7 @@ CONFIG_NAMESPACES=y
8# CONFIG_UTS_NS is not set 8# CONFIG_UTS_NS is not set
9# CONFIG_PID_NS is not set 9# CONFIG_PID_NS is not set
10CONFIG_BLK_DEV_INITRD=y 10CONFIG_BLK_DEV_INITRD=y
11CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
11CONFIG_KALLSYMS_ALL=y 12CONFIG_KALLSYMS_ALL=y
12CONFIG_EMBEDDED=y 13CONFIG_EMBEDDED=y
13CONFIG_PERF_EVENTS=y 14CONFIG_PERF_EVENTS=y
diff --git a/arch/arc/configs/nsimosci_defconfig b/arch/arc/configs/nsimosci_defconfig
index 385a71d3c478..5dd470b6609e 100644
--- a/arch/arc/configs/nsimosci_defconfig
+++ b/arch/arc/configs/nsimosci_defconfig
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
10# CONFIG_UTS_NS is not set 10# CONFIG_UTS_NS is not set
11# CONFIG_PID_NS is not set 11# CONFIG_PID_NS is not set
12CONFIG_BLK_DEV_INITRD=y 12CONFIG_BLK_DEV_INITRD=y
13CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
13CONFIG_KALLSYMS_ALL=y 14CONFIG_KALLSYMS_ALL=y
14CONFIG_EMBEDDED=y 15CONFIG_EMBEDDED=y
15CONFIG_PERF_EVENTS=y 16CONFIG_PERF_EVENTS=y
diff --git a/arch/arc/configs/nsimosci_hs_defconfig b/arch/arc/configs/nsimosci_hs_defconfig
index 248a2c3bdc12..3532e86f7bff 100644
--- a/arch/arc/configs/nsimosci_hs_defconfig
+++ b/arch/arc/configs/nsimosci_hs_defconfig
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
10# CONFIG_UTS_NS is not set 10# CONFIG_UTS_NS is not set
11# CONFIG_PID_NS is not set 11# CONFIG_PID_NS is not set
12CONFIG_BLK_DEV_INITRD=y 12CONFIG_BLK_DEV_INITRD=y
13CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
13CONFIG_KALLSYMS_ALL=y 14CONFIG_KALLSYMS_ALL=y
14CONFIG_EMBEDDED=y 15CONFIG_EMBEDDED=y
15CONFIG_PERF_EVENTS=y 16CONFIG_PERF_EVENTS=y
diff --git a/arch/arc/configs/nsimosci_hs_smp_defconfig b/arch/arc/configs/nsimosci_hs_smp_defconfig
index 1a4bc7b660fb..d90448bee064 100644
--- a/arch/arc/configs/nsimosci_hs_smp_defconfig
+++ b/arch/arc/configs/nsimosci_hs_smp_defconfig
@@ -8,6 +8,7 @@ CONFIG_IKCONFIG_PROC=y
8# CONFIG_UTS_NS is not set 8# CONFIG_UTS_NS is not set
9# CONFIG_PID_NS is not set 9# CONFIG_PID_NS is not set
10CONFIG_BLK_DEV_INITRD=y 10CONFIG_BLK_DEV_INITRD=y
11CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
11CONFIG_PERF_EVENTS=y 12CONFIG_PERF_EVENTS=y
12# CONFIG_COMPAT_BRK is not set 13# CONFIG_COMPAT_BRK is not set
13CONFIG_KPROBES=y 14CONFIG_KPROBES=y
diff --git a/arch/arc/configs/tb10x_defconfig b/arch/arc/configs/tb10x_defconfig
index dc739bd093e3..3a138f8c7299 100644
--- a/arch/arc/configs/tb10x_defconfig
+++ b/arch/arc/configs/tb10x_defconfig
@@ -14,6 +14,7 @@ CONFIG_INITRAMFS_SOURCE="../tb10x-rootfs.cpio"
14CONFIG_INITRAMFS_ROOT_UID=2100 14CONFIG_INITRAMFS_ROOT_UID=2100
15CONFIG_INITRAMFS_ROOT_GID=501 15CONFIG_INITRAMFS_ROOT_GID=501
16# CONFIG_RD_GZIP is not set 16# CONFIG_RD_GZIP is not set
17CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
17CONFIG_SYSCTL_SYSCALL=y 18CONFIG_SYSCTL_SYSCALL=y
18CONFIG_KALLSYMS_ALL=y 19CONFIG_KALLSYMS_ALL=y
19# CONFIG_AIO is not set 20# CONFIG_AIO is not set
diff --git a/arch/arc/configs/vdk_hs38_defconfig b/arch/arc/configs/vdk_hs38_defconfig
index 0c3b21416819..d7c858df520c 100644
--- a/arch/arc/configs/vdk_hs38_defconfig
+++ b/arch/arc/configs/vdk_hs38_defconfig
@@ -4,6 +4,7 @@ CONFIG_HIGH_RES_TIMERS=y
4CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
5CONFIG_IKCONFIG_PROC=y 5CONFIG_IKCONFIG_PROC=y
6CONFIG_BLK_DEV_INITRD=y 6CONFIG_BLK_DEV_INITRD=y
7CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
7CONFIG_EMBEDDED=y 8CONFIG_EMBEDDED=y
8CONFIG_PERF_EVENTS=y 9CONFIG_PERF_EVENTS=y
9# CONFIG_VM_EVENT_COUNTERS is not set 10# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/vdk_hs38_smp_defconfig b/arch/arc/configs/vdk_hs38_smp_defconfig
index f9ad9d3ee702..015c1d43889e 100644
--- a/arch/arc/configs/vdk_hs38_smp_defconfig
+++ b/arch/arc/configs/vdk_hs38_smp_defconfig
@@ -4,6 +4,7 @@ CONFIG_HIGH_RES_TIMERS=y
4CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
5CONFIG_IKCONFIG_PROC=y 5CONFIG_IKCONFIG_PROC=y
6CONFIG_BLK_DEV_INITRD=y 6CONFIG_BLK_DEV_INITRD=y
7CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
7CONFIG_EMBEDDED=y 8CONFIG_EMBEDDED=y
8CONFIG_PERF_EVENTS=y 9CONFIG_PERF_EVENTS=y
9# CONFIG_VM_EVENT_COUNTERS is not set 10# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index f9002e44f18f..be2fc3e79434 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -17,7 +17,7 @@ KBUILD_LDFLAGS_MODULE += --be8
17endif 17endif
18 18
19ifeq ($(CONFIG_ARM_MODULE_PLTS),y) 19ifeq ($(CONFIG_ARM_MODULE_PLTS),y)
20KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm/kernel/module.lds 20KBUILD_LDS_MODULE += $(srctree)/arch/arm/kernel/module.lds
21endif 21endif
22 22
23GZFLAGS :=-9 23GZFLAGS :=-9
diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
index 531e59f5be9c..b76b75bd9e00 100644
--- a/arch/arm/kvm/Makefile
+++ b/arch/arm/kvm/Makefile
@@ -8,13 +8,14 @@ ifeq ($(plus_virt),+virt)
8 plus_virt_def := -DREQUIRES_VIRT=1 8 plus_virt_def := -DREQUIRES_VIRT=1
9endif 9endif
10 10
11KVM := ../../../virt/kvm
12
11ccflags-y += -I $(srctree)/$(src) -I $(srctree)/virt/kvm/arm/vgic 13ccflags-y += -I $(srctree)/$(src) -I $(srctree)/virt/kvm/arm/vgic
12CFLAGS_arm.o := $(plus_virt_def) 14CFLAGS_$(KVM)/arm/arm.o := $(plus_virt_def)
13 15
14AFLAGS_init.o := -Wa,-march=armv7-a$(plus_virt) 16AFLAGS_init.o := -Wa,-march=armv7-a$(plus_virt)
15AFLAGS_interrupts.o := -Wa,-march=armv7-a$(plus_virt) 17AFLAGS_interrupts.o := -Wa,-march=armv7-a$(plus_virt)
16 18
17KVM := ../../../virt/kvm
18kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o $(KVM)/vfio.o 19kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o $(KVM)/vfio.o
19 20
20obj-$(CONFIG_KVM_ARM_HOST) += hyp/ 21obj-$(CONFIG_KVM_ARM_HOST) += hyp/
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 835a1509882b..5e919afa3f62 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -134,6 +134,7 @@ config ARM64
134 select HAVE_ARCH_TRANSPARENT_HUGEPAGE 134 select HAVE_ARCH_TRANSPARENT_HUGEPAGE
135 select HAVE_ARCH_VMAP_STACK 135 select HAVE_ARCH_VMAP_STACK
136 select HAVE_ARM_SMCCC 136 select HAVE_ARM_SMCCC
137 select HAVE_ASM_MODVERSIONS
137 select HAVE_EBPF_JIT 138 select HAVE_EBPF_JIT
138 select HAVE_C_RECORDMCOUNT 139 select HAVE_C_RECORDMCOUNT
139 select HAVE_CMPXCHG_DOUBLE 140 select HAVE_CMPXCHG_DOUBLE
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index f843d298792d..84a3d502c5a5 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -108,7 +108,7 @@ endif
108CHECKFLAGS += -D__aarch64__ 108CHECKFLAGS += -D__aarch64__
109 109
110ifeq ($(CONFIG_ARM64_MODULE_PLTS),y) 110ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
111KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds 111KBUILD_LDS_MODULE += $(srctree)/arch/arm64/kernel/module.lds
112endif 112endif
113 113
114# Default value 114# Default value
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 9711cf730929..685a3df126ca 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -19,6 +19,7 @@ config IA64
19 select PCI_DOMAINS if PCI 19 select PCI_DOMAINS if PCI
20 select PCI_MSI 20 select PCI_MSI
21 select PCI_SYSCALL if PCI 21 select PCI_SYSCALL if PCI
22 select HAVE_ASM_MODVERSIONS
22 select HAVE_UNSTABLE_SCHED_CLOCK 23 select HAVE_UNSTABLE_SCHED_CLOCK
23 select HAVE_EXIT_THREAD 24 select HAVE_EXIT_THREAD
24 select HAVE_IDE 25 select HAVE_IDE
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index e0bb2b6aaa35..32240000dc0c 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -20,7 +20,7 @@ CHECKFLAGS += -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__
20 20
21OBJCOPYFLAGS := --strip-all 21OBJCOPYFLAGS := --strip-all
22LDFLAGS_vmlinux := -static 22LDFLAGS_vmlinux := -static
23KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds 23KBUILD_LDS_MODULE += $(srctree)/arch/ia64/module.lds
24KBUILD_AFLAGS_KERNEL := -mconstant-gp 24KBUILD_AFLAGS_KERNEL := -mconstant-gp
25EXTRA := 25EXTRA :=
26 26
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 935599893d3e..6663f1741798 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -12,6 +12,7 @@ config M68K
12 select DMA_DIRECT_REMAP if HAS_DMA && MMU && !COLDFIRE 12 select DMA_DIRECT_REMAP if HAS_DMA && MMU && !COLDFIRE
13 select HAVE_IDE 13 select HAVE_IDE
14 select HAVE_AOUT if MMU 14 select HAVE_AOUT if MMU
15 select HAVE_ASM_MODVERSIONS
15 select HAVE_DEBUG_BUGVERBOSE 16 select HAVE_DEBUG_BUGVERBOSE
16 select GENERIC_IRQ_SHOW 17 select GENERIC_IRQ_SHOW
17 select GENERIC_ATOMIC64 18 select GENERIC_ATOMIC64
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 482513b9af2c..5d9288384096 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -73,7 +73,7 @@ KBUILD_AFLAGS += -D__uClinux__
73endif 73endif
74 74
75KBUILD_LDFLAGS := -m m68kelf 75KBUILD_LDFLAGS := -m m68kelf
76KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds 76KBUILD_LDS_MODULE += $(srctree)/arch/m68k/kernel/module.lds
77 77
78ifdef CONFIG_SUN3 78ifdef CONFIG_SUN3
79LDFLAGS_vmlinux = -N 79LDFLAGS_vmlinux = -N
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index aff1cadeea43..904c096fa4da 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -44,6 +44,7 @@ config MIPS
44 select HAVE_ARCH_SECCOMP_FILTER 44 select HAVE_ARCH_SECCOMP_FILTER
45 select HAVE_ARCH_TRACEHOOK 45 select HAVE_ARCH_TRACEHOOK
46 select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES && 64BIT 46 select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES && 64BIT
47 select HAVE_ASM_MODVERSIONS
47 select HAVE_EBPF_JIT if (!CPU_MICROMIPS) 48 select HAVE_EBPF_JIT if (!CPU_MICROMIPS)
48 select HAVE_CONTEXT_TRACKING 49 select HAVE_CONTEXT_TRACKING
49 select HAVE_COPY_THREAD_TLS 50 select HAVE_COPY_THREAD_TLS
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index 3ce4dd578370..528bd73d530a 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -160,7 +160,7 @@ targets += vmlinux.lzo.itb
160quiet_cmd_itb-image = ITB $@ 160quiet_cmd_itb-image = ITB $@
161 cmd_itb-image = \ 161 cmd_itb-image = \
162 env PATH="$(objtree)/scripts/dtc:$(PATH)" \ 162 env PATH="$(objtree)/scripts/dtc:$(PATH)" \
163 $(CONFIG_SHELL) $(MKIMAGE) \ 163 $(BASH) $(MKIMAGE) \
164 -D "-I dts -O dtb -p 500 \ 164 -D "-I dts -O dtb -p 500 \
165 --include $(objtree)/arch/mips \ 165 --include $(objtree)/arch/mips \
166 --warning no-unit_address_vs_reg" \ 166 --warning no-unit_address_vs_reg" \
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 3b77d729057f..36b834f1c933 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -60,7 +60,7 @@ KBUILD_CFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY=1 \
60 -DFTRACE_PATCHABLE_FUNCTION_SIZE=$(NOP_COUNT) 60 -DFTRACE_PATCHABLE_FUNCTION_SIZE=$(NOP_COUNT)
61 61
62CC_FLAGS_FTRACE := -fpatchable-function-entry=$(NOP_COUNT),$(shell echo $$(($(NOP_COUNT)-1))) 62CC_FLAGS_FTRACE := -fpatchable-function-entry=$(NOP_COUNT),$(shell echo $$(($(NOP_COUNT)-1)))
63KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/parisc/kernel/module.lds 63KBUILD_LDS_MODULE += $(srctree)/arch/parisc/kernel/module.lds
64endif 64endif
65 65
66OBJCOPY_FLAGS =-O binary -R .note -R .comment -S 66OBJCOPY_FLAGS =-O binary -R .note -R .comment -S
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 891cd23f9c8b..19ee5f155a08 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -177,6 +177,7 @@ config PPC
177 select HAVE_ARCH_NVRAM_OPS 177 select HAVE_ARCH_NVRAM_OPS
178 select HAVE_ARCH_SECCOMP_FILTER 178 select HAVE_ARCH_SECCOMP_FILTER
179 select HAVE_ARCH_TRACEHOOK 179 select HAVE_ARCH_TRACEHOOK
180 select HAVE_ASM_MODVERSIONS
180 select HAVE_C_RECORDMCOUNT 181 select HAVE_C_RECORDMCOUNT
181 select HAVE_CBPF_JIT if !PPC64 182 select HAVE_CBPF_JIT if !PPC64
182 select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13) 183 select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 403f7e193833..37990dd105dc 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -65,7 +65,7 @@ UTS_MACHINE := $(subst $(space),,$(machine-y))
65ifdef CONFIG_PPC32 65ifdef CONFIG_PPC32
66KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o 66KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
67else 67else
68KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/powerpc/kernel/module.lds 68KBUILD_LDS_MODULE += $(srctree)/arch/powerpc/kernel/module.lds
69ifeq ($(call ld-ifversion, -ge, 225000000, y),y) 69ifeq ($(call ld-ifversion, -ge, 225000000, y),y)
70# Have the linker provide sfpr if possible. 70# Have the linker provide sfpr if possible.
71# There is a corresponding test in arch/powerpc/lib/Makefile 71# There is a corresponding test in arch/powerpc/lib/Makefile
diff --git a/arch/powerpc/Makefile.postlink b/arch/powerpc/Makefile.postlink
index 83f8e5ba2722..134f12f89b92 100644
--- a/arch/powerpc/Makefile.postlink
+++ b/arch/powerpc/Makefile.postlink
@@ -18,7 +18,7 @@ quiet_cmd_relocs_check = CHKREL $@
18ifdef CONFIG_PPC_BOOK3S_64 18ifdef CONFIG_PPC_BOOK3S_64
19 cmd_relocs_check = \ 19 cmd_relocs_check = \
20 $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@" ; \ 20 $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@" ; \
21 $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/unrel_branch_check.sh "$(OBJDUMP)" "$@" 21 $(BASH) $(srctree)/arch/powerpc/tools/unrel_branch_check.sh "$(OBJDUMP)" "$@"
22else 22else
23 cmd_relocs_check = \ 23 cmd_relocs_check = \
24 $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@" 24 $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@"
diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
index 160bef0d553d..78bab17b1396 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -33,7 +33,7 @@ OBJ="$2"
33 33
34ERROR=0 34ERROR=0
35 35
36function check_section() 36check_section()
37{ 37{
38 file=$1 38 file=$1
39 section=$2 39 section=$2
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 1211543c330c..71d29fb4008a 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -31,6 +31,7 @@ config RISCV
31 select GENERIC_SMP_IDLE_THREAD 31 select GENERIC_SMP_IDLE_THREAD
32 select GENERIC_ATOMIC64 if !64BIT 32 select GENERIC_ATOMIC64 if !64BIT
33 select HAVE_ARCH_AUDITSYSCALL 33 select HAVE_ARCH_AUDITSYSCALL
34 select HAVE_ASM_MODVERSIONS
34 select HAVE_MEMBLOCK_NODE_MAP 35 select HAVE_MEMBLOCK_NODE_MAP
35 select HAVE_DMA_CONTIGUOUS 36 select HAVE_DMA_CONTIGUOUS
36 select HAVE_FUTEX_CMPXCHG if FUTEX 37 select HAVE_FUTEX_CMPXCHG if FUTEX
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 4f0a3d2018d2..f5e914210245 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -52,7 +52,7 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y)
52 KBUILD_CFLAGS += -mcmodel=medany 52 KBUILD_CFLAGS += -mcmodel=medany
53endif 53endif
54ifeq ($(CONFIG_MODULE_SECTIONS),y) 54ifeq ($(CONFIG_MODULE_SECTIONS),y)
55 KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/riscv/kernel/module.lds 55 KBUILD_LDS_MODULE += $(srctree)/arch/riscv/kernel/module.lds
56endif 56endif
57ifeq ($(CONFIG_PERF_EVENTS),y) 57ifeq ($(CONFIG_PERF_EVENTS),y)
58 KBUILD_CFLAGS += -fno-omit-frame-pointer 58 KBUILD_CFLAGS += -fno-omit-frame-pointer
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 8c5b05d91106..ea5eac00b327 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -132,6 +132,7 @@ config S390
132 select HAVE_ARCH_TRACEHOOK 132 select HAVE_ARCH_TRACEHOOK
133 select HAVE_ARCH_TRANSPARENT_HUGEPAGE 133 select HAVE_ARCH_TRANSPARENT_HUGEPAGE
134 select HAVE_ARCH_VMAP_STACK 134 select HAVE_ARCH_VMAP_STACK
135 select HAVE_ASM_MODVERSIONS
135 select HAVE_EBPF_JIT if PACK_STACK && HAVE_MARCH_Z196_FEATURES 136 select HAVE_EBPF_JIT if PACK_STACK && HAVE_MARCH_Z196_FEATURES
136 select HAVE_CMPXCHG_DOUBLE 137 select HAVE_CMPXCHG_DOUBLE
137 select HAVE_CMPXCHG_LOCAL 138 select HAVE_CMPXCHG_LOCAL
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 7926a2e11bdc..fbc1aecf0f94 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -17,6 +17,7 @@ config SPARC
17 select ARCH_MIGHT_HAVE_PC_SERIO 17 select ARCH_MIGHT_HAVE_PC_SERIO
18 select OF 18 select OF
19 select OF_PROMTREE 19 select OF_PROMTREE
20 select HAVE_ASM_MODVERSIONS
20 select HAVE_IDE 21 select HAVE_IDE
21 select HAVE_OPROFILE 22 select HAVE_OPROFILE
22 select HAVE_ARCH_KGDB if !SMP || SPARC64 23 select HAVE_ARCH_KGDB if !SMP || SPARC64
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 3c3adfc486f2..fec6b4ca2b6e 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -9,6 +9,7 @@ config UML
9 select ARCH_NO_PREEMPT 9 select ARCH_NO_PREEMPT
10 select HAVE_ARCH_AUDITSYSCALL 10 select HAVE_ARCH_AUDITSYSCALL
11 select HAVE_ARCH_SECCOMP_FILTER 11 select HAVE_ARCH_SECCOMP_FILTER
12 select HAVE_ASM_MODVERSIONS
12 select HAVE_UID16 13 select HAVE_UID16
13 select HAVE_FUTEX_CMPXCHG if FUTEX 14 select HAVE_FUTEX_CMPXCHG if FUTEX
14 select HAVE_DEBUG_KMEMLEAK 15 select HAVE_DEBUG_KMEMLEAK
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 4195f44c6a09..c28ab5c01879 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -147,6 +147,7 @@ config X86
147 select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD if X86_64 147 select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD if X86_64
148 select HAVE_ARCH_VMAP_STACK if X86_64 148 select HAVE_ARCH_VMAP_STACK if X86_64
149 select HAVE_ARCH_WITHIN_STACK_FRAMES 149 select HAVE_ARCH_WITHIN_STACK_FRAMES
150 select HAVE_ASM_MODVERSIONS
150 select HAVE_CMPXCHG_DOUBLE 151 select HAVE_CMPXCHG_DOUBLE
151 select HAVE_CMPXCHG_LOCAL 152 select HAVE_CMPXCHG_LOCAL
152 select HAVE_CONTEXT_TRACKING if X86_64 153 select HAVE_CONTEXT_TRACKING if X86_64
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 8df549138193..0f2154106d01 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -89,6 +89,7 @@ $(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS
89# 89#
90CFLAGS_REMOVE_vdso-note.o = -pg 90CFLAGS_REMOVE_vdso-note.o = -pg
91CFLAGS_REMOVE_vclock_gettime.o = -pg 91CFLAGS_REMOVE_vclock_gettime.o = -pg
92CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg
92CFLAGS_REMOVE_vgetcpu.o = -pg 93CFLAGS_REMOVE_vgetcpu.o = -pg
93CFLAGS_REMOVE_vvar.o = -pg 94CFLAGS_REMOVE_vvar.o = -pg
94 95
@@ -128,7 +129,7 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE
128$(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE 129$(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
129 $(call if_changed,vdso_and_check) 130 $(call if_changed,vdso_and_check)
130 131
131CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) 132CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds)
132VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1 133VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
133 134
134targets += vdso32/vdso32.lds 135targets += vdso32/vdso32.lds
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/Makefile b/drivers/gpu/drm/amd/display/dc/calcs/Makefile
index 16614d73a5fc..985633c08a26 100644
--- a/drivers/gpu/drm/amd/display/dc/calcs/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/calcs/Makefile
@@ -36,9 +36,9 @@ ifdef CONFIG_CC_IS_CLANG
36calcs_ccflags += -msse2 36calcs_ccflags += -msse2
37endif 37endif
38 38
39CFLAGS_dcn_calcs.o := $(calcs_ccflags) 39CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calcs.o := $(calcs_ccflags)
40CFLAGS_dcn_calc_auto.o := $(calcs_ccflags) 40CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calc_auto.o := $(calcs_ccflags)
41CFLAGS_dcn_calc_math.o := $(calcs_ccflags) -Wno-tautological-compare 41CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calc_math.o := $(calcs_ccflags) -Wno-tautological-compare
42 42
43BW_CALCS = dce_calcs.o bw_fixed.o custom_float.o 43BW_CALCS = dce_calcs.o bw_fixed.o custom_float.o
44 44
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile
index f57a3b281408..ddb8d5649e79 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile
@@ -16,10 +16,10 @@ else ifneq ($(call cc-option, -mstack-alignment=16),)
16 cc_stack_align := -mstack-alignment=16 16 cc_stack_align := -mstack-alignment=16
17endif 17endif
18 18
19CFLAGS_dcn20_resource.o := -mhard-float -msse $(cc_stack_align) 19CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse $(cc_stack_align)
20 20
21ifdef CONFIG_CC_IS_CLANG 21ifdef CONFIG_CC_IS_CLANG
22CFLAGS_dcn20_resource.o += -msse2 22CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -msse2
23endif 23endif
24 24
25AMD_DAL_DCN20 = $(addprefix $(AMDDALPATH)/dc/dcn20/,$(DCN20)) 25AMD_DAL_DCN20 = $(addprefix $(AMDDALPATH)/dc/dcn20/,$(DCN20))
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
index b2b39090fb57..8cd9de8b1a7a 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
@@ -3,7 +3,7 @@
3 3
4DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o 4DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o
5 5
6CFLAGS_dcn21_resource.o := -mhard-float -msse -mpreferred-stack-boundary=4 6CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -msse -mpreferred-stack-boundary=4
7 7
8AMD_DAL_DCN21 = $(addprefix $(AMDDALPATH)/dc/dcn21/,$(DCN21)) 8AMD_DAL_DCN21 = $(addprefix $(AMDDALPATH)/dc/dcn21/,$(DCN21))
9 9
diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile
index af2a864a6da0..5b2a65b42403 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile
@@ -36,25 +36,22 @@ ifdef CONFIG_CC_IS_CLANG
36dml_ccflags += -msse2 36dml_ccflags += -msse2
37endif 37endif
38 38
39CFLAGS_display_mode_lib.o := $(dml_ccflags) 39CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o := $(dml_ccflags)
40 40
41ifdef CONFIG_DRM_AMD_DC_DCN2_0 41ifdef CONFIG_DRM_AMD_DC_DCN2_0
42CFLAGS_display_mode_vba.o := $(dml_ccflags) 42CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_vba.o := $(dml_ccflags)
43CFLAGS_display_mode_vba_20.o := $(dml_ccflags) 43CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o := $(dml_ccflags)
44CFLAGS_display_rq_dlg_calc_20.o := $(dml_ccflags) 44CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20.o := $(dml_ccflags)
45CFLAGS_display_mode_vba_20v2.o := $(dml_ccflags) 45CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20v2.o := $(dml_ccflags)
46CFLAGS_display_rq_dlg_calc_20v2.o := $(dml_ccflags) 46CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20v2.o := $(dml_ccflags)
47endif 47endif
48ifdef CONFIG_DRM_AMD_DC_DCN2_1 48ifdef CONFIG_DRM_AMD_DC_DCN2_1
49CFLAGS_display_mode_vba_21.o := $(dml_ccflags) 49CFLAGS_$(AMDDALPATH)/dc/dml/dcn21/display_mode_vba_21.o := $(dml_ccflags)
50CFLAGS_display_rq_dlg_calc_21.o := $(dml_ccflags) 50CFLAGS_$(AMDDALPATH)/dc/dml/dcn21/display_rq_dlg_calc_21.o := $(dml_ccflags)
51endif 51endif
52ifdef CONFIG_DRM_AMD_DCN3AG 52CFLAGS_$(AMDDALPATH)/dc/dml/dml1_display_rq_dlg_calc.o := $(dml_ccflags)
53CFLAGS_display_mode_vba_3ag.o := $(dml_ccflags) 53CFLAGS_$(AMDDALPATH)/dc/dml/display_rq_dlg_helpers.o := $(dml_ccflags)
54endif 54CFLAGS_$(AMDDALPATH)/dc/dml/dml_common_defs.o := $(dml_ccflags)
55CFLAGS_dml1_display_rq_dlg_calc.o := $(dml_ccflags)
56CFLAGS_display_rq_dlg_helpers.o := $(dml_ccflags)
57CFLAGS_dml_common_defs.o := $(dml_ccflags)
58 55
59DML = display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_calc.o \ 56DML = display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_calc.o \
60 dml_common_defs.o 57 dml_common_defs.o
diff --git a/drivers/gpu/drm/amd/display/dc/dsc/Makefile b/drivers/gpu/drm/amd/display/dc/dsc/Makefile
index 17db603f2d1f..b456cd23c6fa 100644
--- a/drivers/gpu/drm/amd/display/dc/dsc/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dsc/Makefile
@@ -13,10 +13,9 @@ ifdef CONFIG_CC_IS_CLANG
13dsc_ccflags += -msse2 13dsc_ccflags += -msse2
14endif 14endif
15 15
16CFLAGS_rc_calc.o := $(dsc_ccflags) 16CFLAGS_$(AMDDALPATH)/dc/dsc/rc_calc.o := $(dsc_ccflags)
17CFLAGS_rc_calc_dpi.o := $(dsc_ccflags) 17CFLAGS_$(AMDDALPATH)/dc/dsc/rc_calc_dpi.o := $(dsc_ccflags)
18CFLAGS_codec_main_amd.o := $(dsc_ccflags) 18CFLAGS_$(AMDDALPATH)/dc/dsc/dc_dsc.o := $(dsc_ccflags)
19CFLAGS_dc_dsc.o := $(dsc_ccflags)
20 19
21DSC = dc_dsc.o rc_calc.o rc_calc_dpi.o 20DSC = dc_dsc.o rc_calc.o rc_calc_dpi.o
22 21
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 658b930d34a8..2587ea834f06 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -26,7 +26,7 @@ subdir-ccflags-$(CONFIG_DRM_I915_WERROR) += -Werror
26 26
27# Fine grained warnings disable 27# Fine grained warnings disable
28CFLAGS_i915_pci.o = $(call cc-disable-warning, override-init) 28CFLAGS_i915_pci.o = $(call cc-disable-warning, override-init)
29CFLAGS_intel_fbdev.o = $(call cc-disable-warning, override-init) 29CFLAGS_display/intel_fbdev.o = $(call cc-disable-warning, override-init)
30 30
31subdir-ccflags-y += \ 31subdir-ccflags-y += \
32 $(call as-instr,movntdqa (%eax)$(comma)%xmm0,-DCONFIG_AS_MOVNTDQA) 32 $(call as-instr,movntdqa (%eax)$(comma)%xmm0,-DCONFIG_AS_MOVNTDQA)
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/Makefile b/drivers/net/ethernet/aquantia/atlantic/hw_atl/Makefile
deleted file mode 100644
index 805fa28f391a..000000000000
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0
2# kbuild requires Makefile in a directory to build individual objects
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/accel/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/accel/Makefile
deleted file mode 100644
index c78512eed8d7..000000000000
--- a/drivers/net/ethernet/mellanox/mlx5/core/accel/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0-only
2subdir-ccflags-y += -I$(src)/..
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/diag/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/diag/Makefile
deleted file mode 100644
index c78512eed8d7..000000000000
--- a/drivers/net/ethernet/mellanox/mlx5/core/diag/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0-only
2subdir-ccflags-y += -I$(src)/..
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/en/Makefile
deleted file mode 100644
index c78512eed8d7..000000000000
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0-only
2subdir-ccflags-y += -I$(src)/..
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/Makefile
deleted file mode 100644
index 5ee42991900a..000000000000
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/Makefile
+++ /dev/null
@@ -1 +0,0 @@
1subdir-ccflags-y += -I$(src)/../..
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/Makefile
deleted file mode 100644
index c78512eed8d7..000000000000
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0-only
2subdir-ccflags-y += -I$(src)/..
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/fpga/Makefile
deleted file mode 100644
index c78512eed8d7..000000000000
--- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0-only
2subdir-ccflags-y += -I$(src)/..
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/Makefile
deleted file mode 100644
index c78512eed8d7..000000000000
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0-only
2subdir-ccflags-y += -I$(src)/..
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/lib/Makefile
deleted file mode 100644
index c78512eed8d7..000000000000
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0-only
2subdir-ccflags-y += -I$(src)/..
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/Makefile b/drivers/net/ethernet/netronome/nfp/bpf/Makefile
deleted file mode 100644
index 805fa28f391a..000000000000
--- a/drivers/net/ethernet/netronome/nfp/bpf/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0
2# kbuild requires Makefile in a directory to build individual objects
diff --git a/drivers/net/ethernet/netronome/nfp/flower/Makefile b/drivers/net/ethernet/netronome/nfp/flower/Makefile
deleted file mode 100644
index 805fa28f391a..000000000000
--- a/drivers/net/ethernet/netronome/nfp/flower/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0
2# kbuild requires Makefile in a directory to build individual objects
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/Makefile b/drivers/net/ethernet/netronome/nfp/nfpcore/Makefile
deleted file mode 100644
index 805fa28f391a..000000000000
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0
2# kbuild requires Makefile in a directory to build individual objects
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000/Makefile b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000/Makefile
deleted file mode 100644
index 805fa28f391a..000000000000
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0
2# kbuild requires Makefile in a directory to build individual objects
diff --git a/drivers/net/ethernet/netronome/nfp/nic/Makefile b/drivers/net/ethernet/netronome/nfp/nic/Makefile
deleted file mode 100644
index 805fa28f391a..000000000000
--- a/drivers/net/ethernet/netronome/nfp/nic/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1# SPDX-License-Identifier: GPL-2.0
2# kbuild requires Makefile in a directory to build individual objects
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 599c27b56c29..b056a40116da 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -130,10 +130,6 @@ struct ftrace_likely_data {
130 130
131/* 131/*
132 * Force always-inline if the user requests it so via the .config. 132 * Force always-inline if the user requests it so via the .config.
133 * GCC does not warn about unused static inline functions for
134 * -Wunused-function. This turns out to avoid the need for complex #ifdef
135 * directives. Suppress the warning in clang as well by using "unused"
136 * function attribute, which is redundant but not harmful for gcc.
137 * Prefer gnu_inline, so that extern inline functions do not emit an 133 * Prefer gnu_inline, so that extern inline functions do not emit an
138 * externally visible function. This makes extern inline behave as per gnu89 134 * externally visible function. This makes extern inline behave as per gnu89
139 * semantics rather than c99. This prevents multiple symbol definition errors 135 * semantics rather than c99. This prevents multiple symbol definition errors
@@ -144,16 +140,28 @@ struct ftrace_likely_data {
144 */ 140 */
145#if !defined(CONFIG_OPTIMIZE_INLINING) 141#if !defined(CONFIG_OPTIMIZE_INLINING)
146#define inline inline __attribute__((__always_inline__)) __gnu_inline \ 142#define inline inline __attribute__((__always_inline__)) __gnu_inline \
147 __maybe_unused notrace 143 __inline_maybe_unused notrace
148#else 144#else
149#define inline inline __gnu_inline \ 145#define inline inline __gnu_inline \
150 __maybe_unused notrace 146 __inline_maybe_unused notrace
151#endif 147#endif
152 148
153#define __inline__ inline 149#define __inline__ inline
154#define __inline inline 150#define __inline inline
155 151
156/* 152/*
153 * GCC does not warn about unused static inline functions for -Wunused-function.
154 * Suppress the warning in clang as well by using __maybe_unused, but enable it
155 * for W=1 build. This will allow clang to find unused functions. Remove the
156 * __inline_maybe_unused entirely after fixing most of -Wunused-function warnings.
157 */
158#ifdef KBUILD_EXTRA_WARN1
159#define __inline_maybe_unused
160#else
161#define __inline_maybe_unused __maybe_unused
162#endif
163
164/*
157 * Rather then using noinline to prevent stack consumption, use 165 * Rather then using noinline to prevent stack consumption, use
158 * noinline_for_stack instead. For documentation reasons. 166 * noinline_for_stack instead. For documentation reasons.
159 */ 167 */
diff --git a/include/linux/export.h b/include/linux/export.h
index fd8711ed9ac4..7d8c112a8b61 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -18,9 +18,6 @@ extern struct module __this_module;
18#define THIS_MODULE ((struct module *)0) 18#define THIS_MODULE ((struct module *)0)
19#endif 19#endif
20 20
21#ifdef CONFIG_MODULES
22
23#if defined(__KERNEL__) && !defined(__GENKSYMS__)
24#ifdef CONFIG_MODVERSIONS 21#ifdef CONFIG_MODVERSIONS
25/* Mark the CRC weak since genksyms apparently decides not to 22/* Mark the CRC weak since genksyms apparently decides not to
26 * generate a checksums for some symbols */ 23 * generate a checksums for some symbols */
@@ -74,6 +71,12 @@ struct kernel_symbol {
74}; 71};
75#endif 72#endif
76 73
74#ifdef __GENKSYMS__
75
76#define ___EXPORT_SYMBOL(sym, sec) __GENKSYMS_EXPORT_SYMBOL(sym)
77
78#else
79
77/* For every exported symbol, place a struct in the __ksymtab section */ 80/* For every exported symbol, place a struct in the __ksymtab section */
78#define ___EXPORT_SYMBOL(sym, sec) \ 81#define ___EXPORT_SYMBOL(sym, sec) \
79 extern typeof(sym) sym; \ 82 extern typeof(sym) sym; \
@@ -83,7 +86,9 @@ struct kernel_symbol {
83 = #sym; \ 86 = #sym; \
84 __KSYMTAB_ENTRY(sym, sec) 87 __KSYMTAB_ENTRY(sym, sec)
85 88
86#if defined(__DISABLE_EXPORTS) 89#endif
90
91#if !defined(CONFIG_MODULES) || defined(__DISABLE_EXPORTS)
87 92
88/* 93/*
89 * Allow symbol exports to be disabled completely so that C code may 94 * Allow symbol exports to be disabled completely so that C code may
@@ -117,37 +122,22 @@ struct kernel_symbol {
117#define __cond_export_sym_0(sym, sec) /* nothing */ 122#define __cond_export_sym_0(sym, sec) /* nothing */
118 123
119#else 124#else
120#define __EXPORT_SYMBOL ___EXPORT_SYMBOL
121#endif
122 125
123#define EXPORT_SYMBOL(sym) \ 126#define __EXPORT_SYMBOL(sym, sec) ___EXPORT_SYMBOL(sym, sec)
124 __EXPORT_SYMBOL(sym, "")
125 127
126#define EXPORT_SYMBOL_GPL(sym) \ 128#endif /* CONFIG_MODULES */
127 __EXPORT_SYMBOL(sym, "_gpl")
128
129#define EXPORT_SYMBOL_GPL_FUTURE(sym) \
130 __EXPORT_SYMBOL(sym, "_gpl_future")
131 129
130#define EXPORT_SYMBOL(sym) __EXPORT_SYMBOL(sym, "")
131#define EXPORT_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_gpl")
132#define EXPORT_SYMBOL_GPL_FUTURE(sym) __EXPORT_SYMBOL(sym, "_gpl_future")
132#ifdef CONFIG_UNUSED_SYMBOLS 133#ifdef CONFIG_UNUSED_SYMBOLS
133#define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") 134#define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
134#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl") 135#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
135#else 136#else
136#define EXPORT_UNUSED_SYMBOL(sym) 137#define EXPORT_UNUSED_SYMBOL(sym)
137#define EXPORT_UNUSED_SYMBOL_GPL(sym) 138#define EXPORT_UNUSED_SYMBOL_GPL(sym)
138#endif 139#endif
139 140
140#endif /* __GENKSYMS__ */
141
142#else /* !CONFIG_MODULES... */
143
144#define EXPORT_SYMBOL(sym)
145#define EXPORT_SYMBOL_GPL(sym)
146#define EXPORT_SYMBOL_GPL_FUTURE(sym)
147#define EXPORT_UNUSED_SYMBOL(sym)
148#define EXPORT_UNUSED_SYMBOL_GPL(sym)
149
150#endif /* CONFIG_MODULES */
151#endif /* !__ASSEMBLY__ */ 141#endif /* !__ASSEMBLY__ */
152 142
153#endif /* _LINUX_EXPORT_H */ 143#endif /* _LINUX_EXPORT_H */
diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
index bae807eb2933..9aced11e9000 100644
--- a/include/linux/vermagic.h
+++ b/include/linux/vermagic.h
@@ -9,6 +9,8 @@
9#endif 9#endif
10#ifdef CONFIG_PREEMPT 10#ifdef CONFIG_PREEMPT
11#define MODULE_VERMAGIC_PREEMPT "preempt " 11#define MODULE_VERMAGIC_PREEMPT "preempt "
12#elif defined(CONFIG_PREEMPT_RT)
13#define MODULE_VERMAGIC_PREEMPT "preempt_rt "
12#else 14#else
13#define MODULE_VERMAGIC_PREEMPT "" 15#define MODULE_VERMAGIC_PREEMPT ""
14#endif 16#endif
diff --git a/init/Kconfig b/init/Kconfig
index ec1021fd3371..f4534c58342d 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1234,20 +1234,26 @@ choice
1234 default CC_OPTIMIZE_FOR_PERFORMANCE 1234 default CC_OPTIMIZE_FOR_PERFORMANCE
1235 1235
1236config CC_OPTIMIZE_FOR_PERFORMANCE 1236config CC_OPTIMIZE_FOR_PERFORMANCE
1237 bool "Optimize for performance" 1237 bool "Optimize for performance (-O2)"
1238 help 1238 help
1239 This is the default optimization level for the kernel, building 1239 This is the default optimization level for the kernel, building
1240 with the "-O2" compiler flag for best performance and most 1240 with the "-O2" compiler flag for best performance and most
1241 helpful compile-time warnings. 1241 helpful compile-time warnings.
1242 1242
1243config CC_OPTIMIZE_FOR_SIZE 1243config CC_OPTIMIZE_FOR_PERFORMANCE_O3
1244 bool "Optimize for size" 1244 bool "Optimize more for performance (-O3)"
1245 depends on ARC
1245 imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives 1246 imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
1246 help 1247 help
1247 Enabling this option will pass "-Os" instead of "-O2" to 1248 Choosing this option will pass "-O3" to your compiler to optimize
1248 your compiler resulting in a smaller kernel. 1249 the kernel yet more for performance.
1249 1250
1250 If unsure, say N. 1251config CC_OPTIMIZE_FOR_SIZE
1252 bool "Optimize for size (-Os)"
1253 imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
1254 help
1255 Choosing this option will pass "-Os" to your compiler resulting
1256 in a smaller kernel.
1251 1257
1252endchoice 1258endchoice
1253 1259
@@ -2014,6 +2020,14 @@ config MODVERSIONS
2014 make them incompatible with the kernel you are running. If 2020 make them incompatible with the kernel you are running. If
2015 unsure, say N. 2021 unsure, say N.
2016 2022
2023config ASM_MODVERSIONS
2024 bool
2025 default HAVE_ASM_MODVERSIONS && MODVERSIONS
2026 help
2027 This enables module versioning for exported symbols also from
2028 assembly. This can be enabled only when the target architecture
2029 supports it.
2030
2017config MODULE_REL_CRCS 2031config MODULE_REL_CRCS
2018 bool 2032 bool
2019 depends on MODVERSIONS 2033 depends on MODVERSIONS
diff --git a/init/Makefile b/init/Makefile
index a3e5ce2bcf08..6246a06364d0 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -33,5 +33,6 @@ $(obj)/version.o: include/generated/compile.h
33silent_chk_compile.h = : 33silent_chk_compile.h = :
34include/generated/compile.h: FORCE 34include/generated/compile.h: FORCE
35 @$($(quiet)chk_compile.h) 35 @$($(quiet)chk_compile.h)
36 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \ 36 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
37 "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(KBUILD_CFLAGS)" 37 "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" \
38 "$(CONFIG_PREEMPT_RT)" "$(CC) $(KBUILD_CFLAGS)"
diff --git a/kernel/Makefile b/kernel/Makefile
index 48c5376d290a..25f9d83d1bbf 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -127,7 +127,7 @@ $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
127$(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz 127$(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz
128 128
129quiet_cmd_genikh = CHK $(obj)/kheaders_data.tar.xz 129quiet_cmd_genikh = CHK $(obj)/kheaders_data.tar.xz
130cmd_genikh = $(CONFIG_SHELL) $(srctree)/kernel/gen_kheaders.sh $@ 130 cmd_genikh = $(BASH) $(srctree)/kernel/gen_kheaders.sh $@
131$(obj)/kheaders_data.tar.xz: FORCE 131$(obj)/kheaders_data.tar.xz: FORCE
132 $(call cmd,genikh) 132 $(call cmd,genikh)
133 133
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index 4bbf4fc163a2..d4adfbe42690 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -35,5 +35,8 @@ ld-option = $(success,$(LD) -v $(1))
35$(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found) 35$(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
36$(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found) 36$(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found)
37 37
38# Fail if the linker is gold as it's not capable of linking the kernel proper
39$(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported)
40
38# gcc version including patch level 41# gcc version including patch level
39gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) 42gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))
diff --git a/scripts/Makefile b/scripts/Makefile
index 16bcb8087899..c42891e10ba3 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -36,4 +36,4 @@ subdir-$(CONFIG_MODVERSIONS) += genksyms
36subdir-$(CONFIG_SECURITY_SELINUX) += selinux 36subdir-$(CONFIG_SECURITY_SELINUX) += selinux
37 37
38# Let clean descend into subdirs 38# Let clean descend into subdirs
39subdir- += basic dtc gdb kconfig mod package 39subdir- += basic dtc gdb kconfig mod
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 2f66ed388d1c..f72aba64d611 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -52,7 +52,7 @@ ifndef obj
52$(warning kbuild: Makefile.build is included improperly) 52$(warning kbuild: Makefile.build is included improperly)
53endif 53endif
54 54
55ifeq ($(MAKECMDGOALS)$(need-modorder),) 55ifeq ($(need-modorder),)
56ifneq ($(obj-m),) 56ifneq ($(obj-m),)
57$(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.) 57$(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.)
58$(warning You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.) 58$(warning You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.)
@@ -76,11 +76,6 @@ endif
76 76
77mod-targets := $(patsubst %.o, %.mod, $(obj-m)) 77mod-targets := $(patsubst %.o, %.mod, $(obj-m))
78 78
79__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
80 $(if $(KBUILD_MODULES),$(obj-m) $(mod-targets) $(modorder-target)) \
81 $(subdir-ym) $(always)
82 @:
83
84# Linus' kernel sanity checking tool 79# Linus' kernel sanity checking tool
85ifeq ($(KBUILD_CHECKSRC),1) 80ifeq ($(KBUILD_CHECKSRC),1)
86 quiet_cmd_checksrc = CHECK $< 81 quiet_cmd_checksrc = CHECK $<
@@ -90,23 +85,13 @@ else ifeq ($(KBUILD_CHECKSRC),2)
90 cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< 85 cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
91endif 86endif
92 87
93ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) 88ifneq ($(KBUILD_EXTRA_WARN),)
94 cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< 89 cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $<
95endif 90endif
96 91
97# Compile C sources (.c) 92# Compile C sources (.c)
98# --------------------------------------------------------------------------- 93# ---------------------------------------------------------------------------
99 94
100# Default is built-in, unless we know otherwise
101$(foreach x, i ll lst o s symtypes, $(patsubst %.o,%.$(x),$(real-obj-m))): \
102 part-of-module := y
103
104modkern_cflags = \
105 $(if $(part-of-module), \
106 $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
107 $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
108quiet_modtag = $(if $(part-of-module),[M], )
109
110quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ 95quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
111 cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< 96 cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
112 97
@@ -310,11 +295,6 @@ $(obj)/%.h.s: $(src)/%.h FORCE
310# Compile assembler sources (.S) 295# Compile assembler sources (.S)
311# --------------------------------------------------------------------------- 296# ---------------------------------------------------------------------------
312 297
313modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
314
315$(real-obj-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
316$(real-obj-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
317
318# .S file exports must have their C prototypes defined in asm/asm-prototypes.h 298# .S file exports must have their C prototypes defined in asm/asm-prototypes.h
319# or a file that it includes, in order to get versioned symbols. We build a 299# or a file that it includes, in order to get versioned symbols. We build a
320# dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from 300# dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from
@@ -356,11 +336,7 @@ $(obj)/%.s: $(src)/%.S FORCE
356quiet_cmd_as_o_S = AS $(quiet_modtag) $@ 336quiet_cmd_as_o_S = AS $(quiet_modtag) $@
357 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< 337 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
358 338
359ifdef CONFIG_MODVERSIONS 339ifdef CONFIG_ASM_MODVERSIONS
360
361ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h)
362
363ifneq ($(ASM_PROTOTYPES),)
364 340
365# versioning matches the C process described above, with difference that 341# versioning matches the C process described above, with difference that
366# we parse asm-prototypes.h C header to get function definitions. 342# we parse asm-prototypes.h C header to get function definitions.
@@ -376,7 +352,6 @@ cmd_modversions_S = \
376 rm -f $(@D)/.tmp_$(@F:.o=.ver); \ 352 rm -f $(@D)/.tmp_$(@F:.o=.ver); \
377 fi 353 fi
378endif 354endif
379endif
380 355
381$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE 356$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
382 $(call if_changed_rule,as_o_S) 357 $(call if_changed_rule,as_o_S)
@@ -395,9 +370,9 @@ $(obj)/%.lds: $(src)/%.lds.S FORCE
395 370
396# ASN.1 grammar 371# ASN.1 grammar
397# --------------------------------------------------------------------------- 372# ---------------------------------------------------------------------------
398quiet_cmd_asn1_compiler = ASN.1 $@ 373quiet_cmd_asn1_compiler = ASN.1 $(basename $@).[ch]
399 cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \ 374 cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \
400 $(subst .h,.c,$@) $(subst .c,.h,$@) 375 $(basename $@).c $(basename $@).h
401 376
402$(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler 377$(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
403 $(call cmd,asn1_compiler) 378 $(call cmd,asn1_compiler)
@@ -489,12 +464,50 @@ targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
489 $(call intermediate_targets, .lex.o, .lex.c) \ 464 $(call intermediate_targets, .lex.o, .lex.c) \
490 $(call intermediate_targets, .tab.o, .tab.c .tab.h) 465 $(call intermediate_targets, .tab.o, .tab.c .tab.h)
491 466
467# Build
468# ---------------------------------------------------------------------------
469
470ifdef single-build
471
472curdir-single := $(sort $(foreach x, $(KBUILD_SINGLE_TARGETS), \
473 $(if $(filter $(x) $(basename $(x)).o, $(targets)), $(x))))
474
475# Handle single targets without any rule: show "Nothing to be done for ..." or
476# "No rule to make target ..." depending on whether the target exists.
477unknown-single := $(filter-out $(addsuffix /%, $(subdir-ym)), \
478 $(filter $(obj)/%, \
479 $(filter-out $(curdir-single), \
480 $(KBUILD_SINGLE_TARGETS))))
481
482__build: $(curdir-single) $(subdir-ym)
483ifneq ($(unknown-single),)
484 $(Q)$(MAKE) -f /dev/null $(unknown-single)
485endif
486 @:
487
488ifeq ($(curdir-single),)
489# Nothing to do in this directory. Do not include any .*.cmd file for speed-up
490targets :=
491else
492targets += $(curdir-single)
493endif
494
495else
496
497__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
498 $(if $(KBUILD_MODULES),$(obj-m) $(mod-targets) $(modorder-target)) \
499 $(subdir-ym) $(always)
500 @:
501
502endif
503
492# Descending 504# Descending
493# --------------------------------------------------------------------------- 505# ---------------------------------------------------------------------------
494 506
495PHONY += $(subdir-ym) 507PHONY += $(subdir-ym)
496$(subdir-ym): 508$(subdir-ym):
497 $(Q)$(MAKE) $(build)=$@ \ 509 $(Q)$(MAKE) $(build)=$@ \
510 $(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \
498 need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),1) \ 511 need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),1) \
499 need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1)) 512 need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1))
500 513
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 0b80e3207b20..e367eb95c5c0 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -17,17 +17,8 @@ include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-di
17# Figure out what we need to build from the various variables 17# Figure out what we need to build from the various variables
18# ========================================================================== 18# ==========================================================================
19 19
20__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) 20subdir-ymn := $(sort $(subdir-y) $(subdir-m) $(subdir-) \
21subdir-y += $(__subdir-y) 21 $(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m) $(obj-))))
22__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
23subdir-m += $(__subdir-m)
24__subdir- := $(patsubst %/,%,$(filter %/, $(obj-)))
25subdir- += $(__subdir-)
26
27# Subdirectories we need to descend into
28
29subdir-ym := $(sort $(subdir-y) $(subdir-m))
30subdir-ymn := $(sort $(subdir-ym) $(subdir-))
31 22
32# Add subdir path 23# Add subdir path
33 24
@@ -52,26 +43,14 @@ __clean-files := $(wildcard \
52 $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \ 43 $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \
53 $(filter $(objtree)/%, $(__clean-files))) 44 $(filter $(objtree)/%, $(__clean-files)))
54 45
55# same as clean-files
56
57__clean-dirs := $(wildcard \
58 $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(clean-dirs))) \
59 $(filter $(objtree)/%, $(clean-dirs)))
60
61# ========================================================================== 46# ==========================================================================
62 47
63quiet_cmd_clean = CLEAN $(obj) 48quiet_cmd_clean = CLEAN $(obj)
64 cmd_clean = rm -f $(__clean-files) 49 cmd_clean = rm -rf $(__clean-files)
65quiet_cmd_cleandir = CLEAN $(__clean-dirs)
66 cmd_cleandir = rm -rf $(__clean-dirs)
67
68 50
69__clean: $(subdir-ymn) 51__clean: $(subdir-ymn)
70ifneq ($(strip $(__clean-files)),) 52ifneq ($(strip $(__clean-files)),)
71 +$(call cmd,clean) 53 $(call cmd,clean)
72endif
73ifneq ($(strip $(__clean-dirs)),)
74 +$(call cmd,cleandir)
75endif 54endif
76 @: 55 @:
77 56
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index a74ce2e3c33e..ecddf83ac142 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -1,74 +1,91 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2# ========================================================================== 2# ==========================================================================
3#
4# make W=... settings 3# make W=... settings
5# 4#
6# W=1 - warnings that may be relevant and does not occur too often 5# There are three warning groups enabled by W=1, W=2, W=3.
7# W=2 - warnings that occur quite often but may still be relevant 6# They are independent, and can be combined like W=12 or W=123.
8# W=3 - the more obscure warnings, can most likely be ignored
9#
10# $(call cc-option, -W...) handles gcc -W.. options which
11# are not supported by all versions of the compiler
12# ========================================================================== 7# ==========================================================================
13 8
14KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) 9KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
15 10
11# backward compatibility
12KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
13
16ifeq ("$(origin W)", "command line") 14ifeq ("$(origin W)", "command line")
17 export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W) 15 KBUILD_EXTRA_WARN := $(W)
18endif 16endif
19 17
20ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS 18export KBUILD_EXTRA_WARN
21warning- := $(empty) 19
22 20#
23warning-1 := -Wextra -Wunused -Wno-unused-parameter 21# W=1 - warnings which may be relevant and do not occur too often
24warning-1 += -Wmissing-declarations 22#
25warning-1 += -Wmissing-format-attribute 23ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
26warning-1 += -Wmissing-prototypes 24
27warning-1 += -Wold-style-definition 25KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
28warning-1 += -Wmissing-include-dirs 26KBUILD_CFLAGS += -Wmissing-declarations
29warning-1 += $(call cc-option, -Wunused-but-set-variable) 27KBUILD_CFLAGS += -Wmissing-format-attribute
30warning-1 += $(call cc-option, -Wunused-const-variable) 28KBUILD_CFLAGS += -Wmissing-prototypes
31warning-1 += $(call cc-option, -Wpacked-not-aligned) 29KBUILD_CFLAGS += -Wold-style-definition
32warning-1 += $(call cc-option, -Wstringop-truncation) 30KBUILD_CFLAGS += -Wmissing-include-dirs
31KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
32KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
33KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
34KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
33# The following turn off the warnings enabled by -Wextra 35# The following turn off the warnings enabled by -Wextra
34warning-1 += -Wno-missing-field-initializers 36KBUILD_CFLAGS += -Wno-missing-field-initializers
35warning-1 += -Wno-sign-compare 37KBUILD_CFLAGS += -Wno-sign-compare
36 38
37warning-2 += -Wcast-align 39KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
38warning-2 += -Wdisabled-optimization
39warning-2 += -Wnested-externs
40warning-2 += -Wshadow
41warning-2 += $(call cc-option, -Wlogical-op)
42warning-2 += -Wmissing-field-initializers
43warning-2 += -Wsign-compare
44warning-2 += $(call cc-option, -Wmaybe-uninitialized)
45warning-2 += $(call cc-option, -Wunused-macros)
46
47warning-3 := -Wbad-function-cast
48warning-3 += -Wcast-qual
49warning-3 += -Wconversion
50warning-3 += -Wpacked
51warning-3 += -Wpadded
52warning-3 += -Wpointer-arith
53warning-3 += -Wredundant-decls
54warning-3 += -Wswitch-default
55warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
56
57warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
58warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
59warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
60
61ifeq ("$(strip $(warning))","")
62 $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
63endif
64 40
65KBUILD_CFLAGS += $(warning)
66else 41else
67 42
43# Some diagnostics enabled by default are noisy.
44# Suppress them by using -Wno... except for W=1.
45
68ifdef CONFIG_CC_IS_CLANG 46ifdef CONFIG_CC_IS_CLANG
69KBUILD_CFLAGS += -Wno-initializer-overrides 47KBUILD_CFLAGS += -Wno-initializer-overrides
70KBUILD_CFLAGS += -Wno-format 48KBUILD_CFLAGS += -Wno-format
71KBUILD_CFLAGS += -Wno-sign-compare 49KBUILD_CFLAGS += -Wno-sign-compare
72KBUILD_CFLAGS += -Wno-format-zero-length 50KBUILD_CFLAGS += -Wno-format-zero-length
73endif 51endif
52
53endif
54
55#
56# W=2 - warnings which occur quite often but may still be relevant
57#
58ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
59
60KBUILD_CFLAGS += -Wcast-align
61KBUILD_CFLAGS += -Wdisabled-optimization
62KBUILD_CFLAGS += -Wnested-externs
63KBUILD_CFLAGS += -Wshadow
64KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
65KBUILD_CFLAGS += -Wmissing-field-initializers
66KBUILD_CFLAGS += -Wsign-compare
67KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
68KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
69
70KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2
71
72endif
73
74#
75# W=3 - more obscure warnings, can most likely be ignored
76#
77ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),)
78
79KBUILD_CFLAGS += -Wbad-function-cast
80KBUILD_CFLAGS += -Wcast-qual
81KBUILD_CFLAGS += -Wconversion
82KBUILD_CFLAGS += -Wpacked
83KBUILD_CFLAGS += -Wpadded
84KBUILD_CFLAGS += -Wpointer-arith
85KBUILD_CFLAGS += -Wredundant-decls
86KBUILD_CFLAGS += -Wswitch-default
87KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
88
89KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3
90
74endif 91endif
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 2208ebbd8c4c..4c51c95d40f4 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -1,4 +1,21 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2
3# LEX
4# ---------------------------------------------------------------------------
5quiet_cmd_flex = LEX $@
6 cmd_flex = $(LEX) -o$@ -L $<
7
8$(obj)/%.lex.c: $(src)/%.l FORCE
9 $(call if_changed,flex)
10
11# YACC
12# ---------------------------------------------------------------------------
13quiet_cmd_bison = YACC $(basename $@).[ch]
14 cmd_bison = $(YACC) -o $(basename $@).c --defines=$(basename $@).h -t -l $<
15
16$(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
17 $(call if_changed,bison)
18
2# ========================================================================== 19# ==========================================================================
3# Building binaries on the host system 20# Building binaries on the host system
4# Binaries are used during the compilation of the kernel, for example 21# Binaries are used during the compilation of the kernel, for example
@@ -63,9 +80,9 @@ host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
63# Handle options to gcc. Support building with separate output directory 80# Handle options to gcc. Support building with separate output directory
64 81
65_hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ 82_hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
66 $(HOSTCFLAGS_$(basetarget).o) 83 $(HOSTCFLAGS_$(target-stem).o)
67_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ 84_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
68 $(HOSTCXXFLAGS_$(basetarget).o) 85 $(HOSTCXXFLAGS_$(target-stem).o)
69 86
70# $(objtree)/$(obj) for including generated headers from checkin source files 87# $(objtree)/$(obj) for including generated headers from checkin source files
71ifeq ($(KBUILD_EXTMOD),) 88ifeq ($(KBUILD_EXTMOD),)
@@ -85,7 +102,7 @@ hostcxx_flags = -Wp,-MD,$(depfile) $(_hostcxx_flags)
85# host-csingle -> Executable 102# host-csingle -> Executable
86quiet_cmd_host-csingle = HOSTCC $@ 103quiet_cmd_host-csingle = HOSTCC $@
87 cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(KBUILD_HOSTLDFLAGS) -o $@ $< \ 104 cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(KBUILD_HOSTLDFLAGS) -o $@ $< \
88 $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) 105 $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
89$(host-csingle): $(obj)/%: $(src)/%.c FORCE 106$(host-csingle): $(obj)/%: $(src)/%.c FORCE
90 $(call if_changed_dep,host-csingle) 107 $(call if_changed_dep,host-csingle)
91 108
@@ -93,8 +110,8 @@ $(host-csingle): $(obj)/%: $(src)/%.c FORCE
93# host-cmulti -> executable 110# host-cmulti -> executable
94quiet_cmd_host-cmulti = HOSTLD $@ 111quiet_cmd_host-cmulti = HOSTLD $@
95 cmd_host-cmulti = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ \ 112 cmd_host-cmulti = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ \
96 $(addprefix $(obj)/,$($(@F)-objs)) \ 113 $(addprefix $(obj)/, $($(target-stem)-objs)) \
97 $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) 114 $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
98$(host-cmulti): FORCE 115$(host-cmulti): FORCE
99 $(call if_changed,host-cmulti) 116 $(call if_changed,host-cmulti)
100$(call multi_depend, $(host-cmulti), , -objs) 117$(call multi_depend, $(host-cmulti), , -objs)
@@ -111,8 +128,8 @@ $(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE
111quiet_cmd_host-cxxmulti = HOSTLD $@ 128quiet_cmd_host-cxxmulti = HOSTLD $@
112 cmd_host-cxxmulti = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -o $@ \ 129 cmd_host-cxxmulti = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -o $@ \
113 $(foreach o,objs cxxobjs,\ 130 $(foreach o,objs cxxobjs,\
114 $(addprefix $(obj)/,$($(@F)-$(o)))) \ 131 $(addprefix $(obj)/, $($(target-stem)-$(o)))) \
115 $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) 132 $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
116$(host-cxxmulti): FORCE 133$(host-cxxmulti): FORCE
117 $(call if_changed,host-cxxmulti) 134 $(call if_changed,host-cxxmulti)
118$(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs) 135$(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs)
@@ -144,8 +161,8 @@ $(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
144# *.o -> .so shared library (host-cshlib) 161# *.o -> .so shared library (host-cshlib)
145quiet_cmd_host-cshlib = HOSTLLD -shared $@ 162quiet_cmd_host-cshlib = HOSTLLD -shared $@
146 cmd_host-cshlib = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \ 163 cmd_host-cshlib = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \
147 $(addprefix $(obj)/,$($(@F:.so=-objs))) \ 164 $(addprefix $(obj)/, $($(target-stem)-objs)) \
148 $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) 165 $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem).so)
149$(host-cshlib): FORCE 166$(host-cshlib): FORCE
150 $(call if_changed,host-cshlib) 167 $(call if_changed,host-cshlib)
151$(call multi_depend, $(host-cshlib), .so, -objs) 168$(call multi_depend, $(host-cshlib), .so, -objs)
@@ -154,8 +171,8 @@ $(call multi_depend, $(host-cshlib), .so, -objs)
154# *.o -> .so shared library (host-cxxshlib) 171# *.o -> .so shared library (host-cxxshlib)
155quiet_cmd_host-cxxshlib = HOSTLLD -shared $@ 172quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
156 cmd_host-cxxshlib = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \ 173 cmd_host-cxxshlib = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \
157 $(addprefix $(obj)/,$($(@F:.so=-objs))) \ 174 $(addprefix $(obj)/, $($(target-stem)-objs)) \
158 $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) 175 $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem).so)
159$(host-cxxshlib): FORCE 176$(host-cxxshlib): FORCE
160 $(call if_changed,host-cxxshlib) 177 $(call if_changed,host-cxxshlib)
161$(call multi_depend, $(host-cxxshlib), .so, -objs) 178$(call multi_depend, $(host-cxxshlib), .so, -objs)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 41c50f9461e5..4a0cdd6f5909 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -41,9 +41,9 @@ obj-m := $(filter-out %/, $(obj-m))
41# Subdirectories we need to descend into 41# Subdirectories we need to descend into
42subdir-ym := $(sort $(subdir-y) $(subdir-m)) 42subdir-ym := $(sort $(subdir-y) $(subdir-m))
43 43
44# if $(foo-objs), $(foo-y), or $(foo-m) exists, foo.o is a composite object 44# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
45multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) 45multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m))))
46multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m)))) 46multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m))))
47multi-used := $(multi-used-y) $(multi-used-m) 47multi-used := $(multi-used-y) $(multi-used-m)
48 48
49# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to 49# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
@@ -52,8 +52,8 @@ subdir-obj-y := $(filter %/built-in.a, $(obj-y))
52 52
53# Replace multi-part objects by their individual parts, 53# Replace multi-part objects by their individual parts,
54# including built-in.a from subdirectories 54# including built-in.a from subdirectories
55real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) 55real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
56real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) 56real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
57 57
58# DTB 58# DTB
59# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built 59# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
@@ -101,6 +101,9 @@ modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\
101 101
102modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) 102modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
103 103
104# target with $(obj)/ and its suffix stripped
105target-stem = $(basename $(patsubst $(obj)/%,%,$@))
106
104# These flags are needed for modversions and compiling, so we define them here 107# These flags are needed for modversions and compiling, so we define them here
105# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will 108# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
106# end up in (or would, if it gets compiled in) 109# end up in (or would, if it gets compiled in)
@@ -109,12 +112,12 @@ basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
109modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) 112modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname))
110 113
111orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ 114orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
112 $(ccflags-y) $(CFLAGS_$(basetarget).o) 115 $(ccflags-y) $(CFLAGS_$(target-stem).o)
113_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) 116_c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), $(orig_c_flags))
114orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ 117orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \
115 $(asflags-y) $(AFLAGS_$(basetarget).o) 118 $(asflags-y) $(AFLAGS_$(target-stem).o)
116_a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags)) 119_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), $(orig_a_flags))
117_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) 120_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds)
118 121
119# 122#
120# Enable gcov profiling flags for a file, directory or for all files depending 123# Enable gcov profiling flags for a file, directory or for all files depending
@@ -159,6 +162,18 @@ _cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
159endif 162endif
160endif 163endif
161 164
165part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y)
166quiet_modtag = $(if $(part-of-module),[M], )
167
168modkern_cflags = \
169 $(if $(part-of-module), \
170 $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
171 $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
172
173modkern_aflags = $(if $(part-of-module), \
174 $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \
175 $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))
176
162c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 177c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
163 -include $(srctree)/include/linux/compiler_types.h \ 178 -include $(srctree)/include/linux/compiler_types.h \
164 $(_c_flags) $(modkern_cflags) \ 179 $(_c_flags) $(modkern_cflags) \
@@ -187,28 +202,6 @@ $(foreach m, $(notdir $1), \
187 $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))) 202 $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
188endef 203endef
189 204
190# LEX
191# ---------------------------------------------------------------------------
192quiet_cmd_flex = LEX $@
193 cmd_flex = $(LEX) -o$@ -L $<
194
195$(obj)/%.lex.c: $(src)/%.l FORCE
196 $(call if_changed,flex)
197
198# YACC
199# ---------------------------------------------------------------------------
200quiet_cmd_bison = YACC $@
201 cmd_bison = $(YACC) -o$@ -t -l $<
202
203$(obj)/%.tab.c: $(src)/%.y FORCE
204 $(call if_changed,bison)
205
206quiet_cmd_bison_h = YACC $@
207 cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l $<
208
209$(obj)/%.tab.h: $(src)/%.y FORCE
210 $(call if_changed,bison_h)
211
212# Shipped files 205# Shipped files
213# =========================================================================== 206# ===========================================================================
214 207
@@ -258,7 +251,7 @@ quiet_cmd_gzip = GZIP $@
258DTC ?= $(objtree)/scripts/dtc/dtc 251DTC ?= $(objtree)/scripts/dtc/dtc
259 252
260# Disable noisy checks by default 253# Disable noisy checks by default
261ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) 254ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
262DTC_FLAGS += -Wno-unit_address_vs_reg \ 255DTC_FLAGS += -Wno-unit_address_vs_reg \
263 -Wno-unit_address_format \ 256 -Wno-unit_address_format \
264 -Wno-avoid_unnecessary_addr_size \ 257 -Wno-avoid_unnecessary_addr_size \
@@ -269,7 +262,7 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \
269 -Wno-pci_device_reg 262 -Wno-pci_device_reg
270endif 263endif
271 264
272ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) 265ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),)
273DTC_FLAGS += -Wnode_name_chars_strict \ 266DTC_FLAGS += -Wnode_name_chars_strict \
274 -Wproperty_name_chars_strict 267 -Wproperty_name_chars_strict
275endif 268endif
@@ -374,7 +367,7 @@ UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
374UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)' 367UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
375 368
376quiet_cmd_uimage = UIMAGE $@ 369quiet_cmd_uimage = UIMAGE $@
377 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \ 370 cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
378 -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \ 371 -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
379 -T $(UIMAGE_TYPE) \ 372 -T $(UIMAGE_TYPE) \
380 -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \ 373 -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal
new file mode 100644
index 000000000000..411c1e600e7d
--- /dev/null
+++ b/scripts/Makefile.modfinal
@@ -0,0 +1,60 @@
1# SPDX-License-Identifier: GPL-2.0-only
2# ===========================================================================
3# Module final link
4# ===========================================================================
5
6PHONY := __modfinal
7__modfinal:
8
9include $(srctree)/scripts/Kbuild.include
10
11# for c_flags
12include $(srctree)/scripts/Makefile.lib
13
14# find all modules listed in modules.order
15modules := $(sort $(shell cat $(MODORDER)))
16
17__modfinal: $(modules)
18 @:
19
20# modname and part-of-module are set to make c_flags define proper module flags
21modname = $(notdir $(@:.mod.o=))
22part-of-module = y
23
24quiet_cmd_cc_o_c = CC [M] $@
25 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
26
27%.mod.o: %.mod.c FORCE
28 $(call if_changed_dep,cc_o_c)
29
30ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
31
32quiet_cmd_ld_ko_o = LD [M] $@
33 cmd_ld_ko_o = \
34 $(LD) -r $(KBUILD_LDFLAGS) \
35 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
36 $(addprefix -T , $(KBUILD_LDS_MODULE)) \
37 -o $@ $(filter %.o, $^); \
38 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
39
40$(modules): %.ko: %.o %.mod.o $(KBUILD_LDS_MODULE) FORCE
41 +$(call if_changed,ld_ko_o)
42
43targets += $(modules) $(modules:.ko=.mod.o)
44
45# Add FORCE to the prequisites of a target to force it to be always rebuilt.
46# ---------------------------------------------------------------------------
47
48PHONY += FORCE
49FORCE:
50
51# Read all saved command lines and dependencies for the $(targets) we
52# may be building above, using $(if_changed{,_dep}). As an
53# optimization, we don't need to read them if the target does not
54# exist, we will rebuild anyway in that case.
55
56existing-targets := $(wildcard $(sort $(targets)))
57
58-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
59
60.PHONY: $(PHONY)
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 26e6574ecd08..9800a3988f23 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -15,15 +15,13 @@
15# 2) modpost is then used to 15# 2) modpost is then used to
16# 3) create one <module>.mod.c file pr. module 16# 3) create one <module>.mod.c file pr. module
17# 4) create one Module.symvers file with CRC for all exported symbols 17# 4) create one Module.symvers file with CRC for all exported symbols
18# 5) compile all <module>.mod.c files
19# 6) final link of the module to a <module.ko> file
20 18
21# Step 3 is used to place certain information in the module's ELF 19# Step 3 is used to place certain information in the module's ELF
22# section, including information such as: 20# section, including information such as:
23# Version magic (see include/linux/vermagic.h for full details) 21# Version magic (see include/linux/vermagic.h for full details)
24# - Kernel release 22# - Kernel release
25# - SMP is CONFIG_SMP 23# - SMP is CONFIG_SMP
26# - PREEMPT is CONFIG_PREEMPT 24# - PREEMPT is CONFIG_PREEMPT[_RT]
27# - GCC Version 25# - GCC Version
28# Module info 26# Module info
29# - Module version (MODULE_VERSION) 27# - Module version (MODULE_VERSION)
@@ -60,13 +58,10 @@ MODPOST = scripts/mod/modpost \
60 58
61ifdef MODPOST_VMLINUX 59ifdef MODPOST_VMLINUX
62 60
63__modpost: vmlinux.o 61quiet_cmd_modpost = MODPOST vmlinux.o
62 cmd_modpost = $(MODPOST) vmlinux.o
64 63
65quiet_cmd_modpost = MODPOST $@ 64__modpost:
66 cmd_modpost = $(MODPOST) $@
67
68PHONY += vmlinux.o
69vmlinux.o:
70 $(call cmd,modpost) 65 $(call cmd,modpost)
71 66
72else 67else
@@ -83,73 +78,22 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
83 $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile) 78 $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
84endif 79endif
85 80
86include scripts/Makefile.lib 81MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux)
87 82
88# find all modules listed in modules.order 83# find all modules listed in modules.order
89modules := $(sort $(shell cat $(MODORDER))) 84modules := $(sort $(shell cat $(MODORDER)))
90 85
91# Stop after building .o files if NOFINAL is set. Makes compile tests quicker 86# Read out modules.order instead of expanding $(modules) to pass in modpost.
92__modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) 87# Otherwise, allmodconfig would fail with "Argument list too long".
93 @:
94
95MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux)
96
97# We can go over command line length here, so be careful.
98quiet_cmd_modpost = MODPOST $(words $(modules)) modules 88quiet_cmd_modpost = MODPOST $(words $(modules)) modules
99 cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) 89 cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST)
100 90
101PHONY += modules-modpost 91__modpost:
102modules-modpost: 92 @$(kecho) ' Building modules, stage 2.'
103 $(call cmd,modpost) 93 $(call cmd,modpost)
104 94ifneq ($(KBUILD_MODPOST_NOFINAL),1)
105# Declare generated files as targets for modpost 95 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
106$(modules:.ko=.mod.c): modules-modpost 96endif
107
108# Step 5), compile all *.mod.c files
109
110# modname is set to make c_flags define KBUILD_MODNAME
111modname = $(notdir $(@:.mod.o=))
112
113quiet_cmd_cc_o_c = CC $@
114 cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \
115 -c -o $@ $<
116
117$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
118 $(call if_changed_dep,cc_o_c)
119
120targets += $(modules:.ko=.mod.o)
121
122ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
123
124# Step 6), final link of the modules with optional arch pass after final link
125quiet_cmd_ld_ko_o = LD [M] $@
126 cmd_ld_ko_o = \
127 $(LD) -r $(KBUILD_LDFLAGS) \
128 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
129 -o $@ $(real-prereqs) ; \
130 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
131
132$(modules): %.ko :%.o %.mod.o FORCE
133 +$(call if_changed,ld_ko_o)
134
135targets += $(modules)
136
137
138# Add FORCE to the prequisites of a target to force it to be always rebuilt.
139# ---------------------------------------------------------------------------
140
141PHONY += FORCE
142
143FORCE:
144
145# Read all saved command lines and dependencies for the $(targets) we
146# may be building above, using $(if_changed{,_dep}). As an
147# optimization, we don't need to read them if the target does not
148# exist, we will rebuild anyway in that case.
149
150existing-targets := $(wildcard $(sort $(targets)))
151
152-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
153 97
154endif 98endif
155 99
diff --git a/scripts/package/Makefile b/scripts/Makefile.package
index ca7f46b562a4..56eadcc48d46 100644
--- a/scripts/package/Makefile
+++ b/scripts/Makefile.package
@@ -1,6 +1,7 @@
1# SPDX-License-Identifier: GPL-2.0-only 1# SPDX-License-Identifier: GPL-2.0-only
2# Makefile for the different targets used to generate full packages of a kernel 2# Makefile for the different targets used to generate full packages of a kernel
3# It uses the generic clean infrastructure of kbuild 3
4include $(srctree)/scripts/Kbuild.include
4 5
5# RPM target 6# RPM target
6# --------------------------------------------------------------------------- 7# ---------------------------------------------------------------------------
@@ -50,7 +51,8 @@ rm -f $(objtree)/.scmversion
50 51
51# rpm-pkg 52# rpm-pkg
52# --------------------------------------------------------------------------- 53# ---------------------------------------------------------------------------
53rpm-pkg: FORCE 54PHONY += rpm-pkg
55rpm-pkg:
54 $(MAKE) clean 56 $(MAKE) clean
55 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec 57 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
56 $(call cmd,src_tar,$(KERNELPATH),kernel.spec) 58 $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
@@ -59,15 +61,15 @@ rpm-pkg: FORCE
59 61
60# binrpm-pkg 62# binrpm-pkg
61# --------------------------------------------------------------------------- 63# ---------------------------------------------------------------------------
62binrpm-pkg: FORCE 64PHONY += binrpm-pkg
65binrpm-pkg:
63 $(MAKE) -f $(srctree)/Makefile 66 $(MAKE) -f $(srctree)/Makefile
64 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec 67 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
65 +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ 68 +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
66 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec 69 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
67 70
68clean-files += $(objtree)/*.spec 71PHONY += deb-pkg
69 72deb-pkg:
70deb-pkg: FORCE
71 $(MAKE) clean 73 $(MAKE) clean
72 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian 74 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
73 $(call cmd,src_tar,$(KDEB_SOURCENAME)) 75 $(call cmd,src_tar,$(KDEB_SOURCENAME))
@@ -75,18 +77,19 @@ deb-pkg: FORCE
75 mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz 77 mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
76 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc 78 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc
77 79
78bindeb-pkg: FORCE 80PHONY += bindeb-pkg
81bindeb-pkg:
79 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian 82 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
80 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc 83 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
81 84
82intdeb-pkg: FORCE 85PHONY += intdeb-pkg
86intdeb-pkg:
83 +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 87 +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
84 88
85clean-dirs += $(objtree)/debian/
86
87# snap-pkg 89# snap-pkg
88# --------------------------------------------------------------------------- 90# ---------------------------------------------------------------------------
89snap-pkg: FORCE 91PHONY += snap-pkg
92snap-pkg:
90 rm -rf $(objtree)/snap 93 rm -rf $(objtree)/snap
91 mkdir $(objtree)/snap 94 mkdir $(objtree)/snap
92 $(MAKE) clean 95 $(MAKE) clean
@@ -98,17 +101,14 @@ snap-pkg: FORCE
98 cd $(objtree)/snap && \ 101 cd $(objtree)/snap && \
99 snapcraft --target-arch=$(UTS_MACHINE) 102 snapcraft --target-arch=$(UTS_MACHINE)
100 103
101clean-dirs += $(objtree)/snap/
102
103# tarball targets 104# tarball targets
104# --------------------------------------------------------------------------- 105# ---------------------------------------------------------------------------
105tar%pkg: FORCE 106tar-pkgs := tar-pkg targz-pkg tarbz2-pkg tarxz-pkg
107PHONY += $(tar-pkgs)
108$(tar-pkgs):
106 $(MAKE) -f $(srctree)/Makefile 109 $(MAKE) -f $(srctree)/Makefile
107 +$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ 110 +$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
108 111
109clean-dirs += $(objtree)/tar-install/
110
111
112# perf-pkg - generate a source tarball with perf source 112# perf-pkg - generate a source tarball with perf source
113# --------------------------------------------------------------------------- 113# ---------------------------------------------------------------------------
114 114
@@ -133,12 +133,15 @@ $(if $(findstring xz,$@),xz, \
133$(error unknown target $@)))) \ 133$(error unknown target $@)))) \
134 -f -9 $(perf-tar).tar) 134 -f -9 $(perf-tar).tar)
135 135
136perf-%pkg: FORCE 136perf-tar-pkgs := perf-tar-src-pkg perf-targz-src-pkg perf-tarbz2-src-pkg perf-tarxz-src-pkg
137PHONY += $(perf-tar-pkgs)
138$(perf-tar-pkgs):
137 $(call cmd,perf_tar) 139 $(call cmd,perf_tar)
138 140
139# Help text displayed when executing 'make help' 141# Help text displayed when executing 'make help'
140# --------------------------------------------------------------------------- 142# ---------------------------------------------------------------------------
141help: FORCE 143PHONY += help
144help:
142 @echo ' rpm-pkg - Build both source and binary RPM kernel packages' 145 @echo ' rpm-pkg - Build both source and binary RPM kernel packages'
143 @echo ' binrpm-pkg - Build only the binary kernel RPM package' 146 @echo ' binrpm-pkg - Build only the binary kernel RPM package'
144 @echo ' deb-pkg - Build both source and binary deb kernel packages' 147 @echo ' deb-pkg - Build both source and binary deb kernel packages'
@@ -152,3 +155,5 @@ help: FORCE
152 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball' 155 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
153 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball' 156 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
154 @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball' 157 @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'
158
159.PHONY: $(PHONY)
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
index 548aeb592806..7c9cb80d097b 100644
--- a/scripts/basic/Makefile
+++ b/scripts/basic/Makefile
@@ -1,16 +1,6 @@
1# SPDX-License-Identifier: GPL-2.0-only 1# SPDX-License-Identifier: GPL-2.0-only
2### 2#
3# This Makefile lists the most basic programs used during the build process. 3# fixdep: used to generate dependency information during build process
4# The programs listed herein are what are needed to do the basic stuff,
5# such as fix file dependencies.
6# This initial step is needed to avoid files to be recompiled
7# when kernel configuration changes (which is what happens when
8# .config is included by main Makefile.
9# ---------------------------------------------------------------------------
10# fixdep: Used to generate dependency information during build process
11 4
12hostprogs-y := fixdep 5hostprogs-y := fixdep
13always := $(hostprogs-y) 6always := $(hostprogs-y)
14
15# fixdep is needed to compile other host programs
16$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
index 66c314bc5933..78629f515e78 100644
--- a/scripts/genksyms/Makefile
+++ b/scripts/genksyms/Makefile
@@ -12,22 +12,15 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o
12# 12#
13# Just in case, run "$(YACC) --version" without suppressing stderr 13# Just in case, run "$(YACC) --version" without suppressing stderr
14# so that 'bison: not found' will be displayed if it is missing. 14# so that 'bison: not found' will be displayed if it is missing.
15ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) 15ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
16 16
17quiet_cmd_bison_no_warn = $(quiet_cmd_bison) 17quiet_cmd_bison_no_warn = $(quiet_cmd_bison)
18 cmd_bison_no_warn = $(YACC) --version >/dev/null; \ 18 cmd_bison_no_warn = $(YACC) --version >/dev/null; \
19 $(cmd_bison) 2>/dev/null 19 $(cmd_bison) 2>/dev/null
20 20
21$(obj)/parse.tab.c: $(src)/parse.y FORCE 21$(obj)/pars%.tab.c $(obj)/pars%.tab.h: $(src)/pars%.y FORCE
22 $(call if_changed,bison_no_warn) 22 $(call if_changed,bison_no_warn)
23 23
24quiet_cmd_bison_h_no_warn = $(quiet_cmd_bison_h)
25 cmd_bison_h_no_warn = $(YACC) --version >/dev/null; \
26 $(cmd_bison_h) 2>/dev/null
27
28$(obj)/parse.tab.h: $(src)/parse.y FORCE
29 $(call if_changed,bison_h_no_warn)
30
31endif 24endif
32 25
33# -I needed for generated C source (shipped source) 26# -I needed for generated C source (shipped source)
diff --git a/scripts/genksyms/keywords.c b/scripts/genksyms/keywords.c
index c586d32dd2c3..7a85c4e21175 100644
--- a/scripts/genksyms/keywords.c
+++ b/scripts/genksyms/keywords.c
@@ -3,11 +3,7 @@ static struct resword {
3 const char *name; 3 const char *name;
4 int token; 4 int token;
5} keywords[] = { 5} keywords[] = {
6 { "EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW }, 6 { "__GENKSYMS_EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW },
7 { "EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW },
8 { "EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW },
9 { "EXPORT_UNUSED_SYMBOL", EXPORT_SYMBOL_KEYW },
10 { "EXPORT_UNUSED_SYMBOL_GPL", EXPORT_SYMBOL_KEYW },
11 { "__asm", ASM_KEYW }, 7 { "__asm", ASM_KEYW },
12 { "__asm__", ASM_KEYW }, 8 { "__asm__", ASM_KEYW },
13 { "__attribute", ATTRIBUTE_KEYW }, 9 { "__attribute", ATTRIBUTE_KEYW },
diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l
index d29c774f51b6..e265c5d96861 100644
--- a/scripts/genksyms/lex.l
+++ b/scripts/genksyms/lex.l
@@ -1,25 +1,13 @@
1/* Lexical analysis for genksyms. 1/* SPDX-License-Identifier: GPL-2.0-or-later */
2 Copyright 1996, 1997 Linux International. 2/*
3 3 * Lexical analysis for genksyms.
4 New implementation contributed by Richard Henderson <rth@tamu.edu> 4 * Copyright 1996, 1997 Linux International.
5 Based on original work by Bjorn Ekwall <bj0rn@blox.se> 5 *
6 6 * New implementation contributed by Richard Henderson <rth@tamu.edu>
7 Taken from Linux modutils 2.4.22. 7 * Based on original work by Bjorn Ekwall <bj0rn@blox.se>
8 8 *
9 This program is free software; you can redistribute it and/or modify it 9 * Taken from Linux modutils 2.4.22.
10 under the terms of the GNU General Public License as published by the 10 */
11 Free Software Foundation; either version 2 of the License, or (at your
12 option) any later version.
13
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23 11
24%{ 12%{
25 13
diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y
index 1ebcf52cd0f9..e22b42245bcc 100644
--- a/scripts/genksyms/parse.y
+++ b/scripts/genksyms/parse.y
@@ -1,25 +1,13 @@
1/* C global declaration parser for genksyms. 1/* SPDX-License-Identifier: GPL-2.0-or-later */
2 Copyright 1996, 1997 Linux International. 2/*
3 3 * C global declaration parser for genksyms.
4 New implementation contributed by Richard Henderson <rth@tamu.edu> 4 * Copyright 1996, 1997 Linux International.
5 Based on original work by Bjorn Ekwall <bj0rn@blox.se> 5 *
6 6 * New implementation contributed by Richard Henderson <rth@tamu.edu>
7 This file is part of the Linux modutils. 7 * Based on original work by Bjorn Ekwall <bj0rn@blox.se>
8 8 *
9 This program is free software; you can redistribute it and/or modify it 9 * This file is part of the Linux modutils.
10 under the terms of the GNU General Public License as published by the 10 */
11 Free Software Foundation; either version 2 of the License, or (at your
12 option) any later version.
13
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23 11
24%{ 12%{
25 13
diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index bbaf29386995..a07668a5c36b 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -41,5 +41,77 @@ sed -E -e '
41scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE 41scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
42[ $? -gt 1 ] && exit 1 42[ $? -gt 1 ] && exit 1
43 43
44# Remove /* ... */ style comments, and find CONFIG_ references in code
45configs=$(sed -e '
46:comment
47 s:/\*[^*][^*]*:/*:
48 s:/\*\*\**\([^/]\):/*\1:
49 t comment
50 s:/\*\*/: :
51 t comment
52 /\/\*/! b check
53 N
54 b comment
55:print
56 P
57 D
58:check
59 s:^\(CONFIG_[[:alnum:]_]*\):\1\n:
60 t print
61 s:^[[:alnum:]_][[:alnum:]_]*::
62 s:^[^[:alnum:]_][^[:alnum:]_]*::
63 t check
64 d
65' $OUTFILE)
66
67# The entries in the following list are not warned.
68# Please do not add a new entry. This list is only for existing ones.
69# The list will be reduced gradually, and deleted eventually. (hopefully)
70#
71# The format is <file-name>:<CONFIG-option> in each line.
72config_leak_ignores="
73arch/alpha/include/uapi/asm/setup.h:CONFIG_ALPHA_LEGACY_START_ADDRESS
74arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K
75arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K
76arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
77arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
78arch/hexagon/include/uapi/asm/ptrace.h:CONFIG_HEXAGON_ARCH_VERSION
79arch/hexagon/include/uapi/asm/user.h:CONFIG_HEXAGON_ARCH_VERSION
80arch/ia64/include/uapi/asm/cmpxchg.h:CONFIG_IA64_DEBUG_CMPXCHG
81arch/m68k/include/uapi/asm/ptrace.h:CONFIG_COLDFIRE
82arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
83arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
84arch/sh/include/uapi/asm/ptrace.h:CONFIG_CPU_SH5
85arch/sh/include/uapi/asm/sigcontext.h:CONFIG_CPU_SH5
86arch/sh/include/uapi/asm/stat.h:CONFIG_CPU_SH5
87arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
88arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64
89arch/x86/include/uapi/asm/mman.h:CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
90include/uapi/asm-generic/fcntl.h:CONFIG_64BIT
91include/uapi/linux/atmdev.h:CONFIG_COMPAT
92include/uapi/linux/elfcore.h:CONFIG_BINFMT_ELF_FDPIC
93include/uapi/linux/eventpoll.h:CONFIG_PM_SLEEP
94include/uapi/linux/hw_breakpoint.h:CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
95include/uapi/linux/pktcdvd.h:CONFIG_CDROM_PKTCDVD_WCACHE
96include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS
97"
98
99for c in $configs
100do
101 warn=1
102
103 for ignore in $config_leak_ignores
104 do
105 if echo "$INFILE:$c" | grep -q "$ignore$"; then
106 warn=
107 break
108 fi
109 done
110
111 if [ "$warn" = 1 ]; then
112 echo "warning: $INFILE: leak $c to user-space" >&2
113 fi
114done
115
44rm -f $TMPFILE 116rm -f $TMPFILE
45trap - EXIT 117trap - EXIT
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 7656e1137b6b..ef2f2336c469 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -114,7 +114,7 @@ testconfig: $(obj)/conf
114 $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 114 $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
115 -o cache_dir=$(abspath $(obj)/tests/.cache) \ 115 -o cache_dir=$(abspath $(obj)/tests/.cache) \
116 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) 116 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
117clean-dirs += tests/.cache 117clean-files += tests/.cache
118 118
119# Help text used by make help 119# Help text used by make help
120help: 120help:
@@ -166,15 +166,15 @@ $(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
166 166
167# mconf: Used for the menuconfig target based on lxdialog 167# mconf: Used for the menuconfig target based on lxdialog
168hostprogs-y += mconf 168hostprogs-y += mconf
169lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o 169lxdialog := $(addprefix lxdialog/, \
170mconf-objs := mconf.o $(addprefix lxdialog/, $(lxdialog)) $(common-objs) 170 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
171mconf-objs := mconf.o $(lxdialog) $(common-objs)
171 172
172HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs) 173HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
173$(foreach f, mconf.o $(lxdialog), \ 174$(foreach f, mconf.o $(lxdialog), \
174 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags))) 175 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
175 176
176$(obj)/mconf.o: $(obj)/mconf-cfg 177$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
177$(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/mconf-cfg
178 178
179# qconf: Used for the xconfig target based on Qt 179# qconf: Used for the xconfig target based on Qt
180hostprogs-y += qconf 180hostprogs-y += qconf
diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
index d924c51d28b7..63c8565206a4 100755
--- a/scripts/kconfig/merge_config.sh
+++ b/scripts/kconfig/merge_config.sh
@@ -13,12 +13,12 @@
13# Copyright (c) 2009-2010 Wind River Systems, Inc. 13# Copyright (c) 2009-2010 Wind River Systems, Inc.
14# Copyright 2011 Linaro 14# Copyright 2011 Linaro
15 15
16set -e
17
16clean_up() { 18clean_up() {
17 rm -f $TMP_FILE 19 rm -f $TMP_FILE
18 rm -f $MERGE_FILE 20 rm -f $MERGE_FILE
19 exit
20} 21}
21trap clean_up HUP INT TERM
22 22
23usage() { 23usage() {
24 echo "Usage: $0 [OPTIONS] [CONFIG [...]]" 24 echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
@@ -110,6 +110,9 @@ TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX)
110MERGE_FILE=$(mktemp ./.merge_tmp.config.XXXXXXXXXX) 110MERGE_FILE=$(mktemp ./.merge_tmp.config.XXXXXXXXXX)
111 111
112echo "Using $INITFILE as base" 112echo "Using $INITFILE as base"
113
114trap clean_up EXIT
115
113cat $INITFILE > $TMP_FILE 116cat $INITFILE > $TMP_FILE
114 117
115# Merge files, printing warnings on overridden values 118# Merge files, printing warnings on overridden values
@@ -155,7 +158,6 @@ if [ "$RUNMAKE" = "false" ]; then
155 echo "#" 158 echo "#"
156 echo "# merged configuration written to $KCONFIG_CONFIG (needs make)" 159 echo "# merged configuration written to $KCONFIG_CONFIG (needs make)"
157 echo "#" 160 echo "#"
158 clean_up
159 exit 161 exit
160fi 162fi
161 163
@@ -177,7 +179,7 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET
177for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do 179for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
178 180
179 REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) 181 REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
180 ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG") 182 ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG" || true)
181 if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then 183 if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then
182 echo "Value requested for $CFG not in final .config" 184 echo "Value requested for $CFG not in final .config"
183 echo "Requested value: $REQUESTED_VAL" 185 echo "Requested value: $REQUESTED_VAL"
@@ -185,5 +187,3 @@ for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
185 echo "" 187 echo ""
186 fi 188 fi
187done 189done
188
189clean_up
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 8c59970a09dc..06495379fcd8 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -64,6 +64,8 @@ vmlinux_link()
64 local output=${1} 64 local output=${1}
65 local objects 65 local objects
66 66
67 info LD ${output}
68
67 # skip output file argument 69 # skip output file argument
68 shift 70 shift
69 71
@@ -157,6 +159,18 @@ kallsyms()
157 ${CC} ${aflags} -c -o ${2} ${afile} 159 ${CC} ${aflags} -c -o ${2} ${afile}
158} 160}
159 161
162# Perform one step in kallsyms generation, including temporary linking of
163# vmlinux.
164kallsyms_step()
165{
166 kallsymso_prev=${kallsymso}
167 kallsymso=.tmp_kallsyms${1}.o
168 kallsyms_vmlinux=.tmp_vmlinux${1}
169
170 vmlinux_link ${kallsyms_vmlinux} "${kallsymso_prev}" ${btf_vmlinux_bin_o}
171 kallsyms ${kallsyms_vmlinux} ${kallsymso}
172}
173
160# Create map file with all symbols from ${1} 174# Create map file with all symbols from ${1}
161# See mksymap for additional details 175# See mksymap for additional details
162mksysmap() 176mksysmap()
@@ -243,6 +257,7 @@ if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then
243fi 257fi
244 258
245kallsymso="" 259kallsymso=""
260kallsymso_prev=""
246kallsyms_vmlinux="" 261kallsyms_vmlinux=""
247if [ -n "${CONFIG_KALLSYMS}" ]; then 262if [ -n "${CONFIG_KALLSYMS}" ]; then
248 263
@@ -269,32 +284,19 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
269 # a) Verify that the System.map from vmlinux matches the map from 284 # a) Verify that the System.map from vmlinux matches the map from
270 # ${kallsymso}. 285 # ${kallsymso}.
271 286
272 kallsymso=.tmp_kallsyms2.o 287 kallsyms_step 1
273 kallsyms_vmlinux=.tmp_vmlinux2 288 kallsyms_step 2
274
275 # step 1
276 vmlinux_link .tmp_vmlinux1 ${btf_vmlinux_bin_o}
277 kallsyms .tmp_vmlinux1 .tmp_kallsyms1.o
278
279 # step 2
280 vmlinux_link .tmp_vmlinux2 .tmp_kallsyms1.o ${btf_vmlinux_bin_o}
281 kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o
282 289
283 # step 3 290 # step 3
284 size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" .tmp_kallsyms1.o) 291 size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev})
285 size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" .tmp_kallsyms2.o) 292 size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
286 293
287 if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then 294 if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
288 kallsymso=.tmp_kallsyms3.o 295 kallsyms_step 3
289 kallsyms_vmlinux=.tmp_vmlinux3
290
291 vmlinux_link .tmp_vmlinux3 .tmp_kallsyms2.o ${btf_vmlinux_bin_o}
292 kallsyms .tmp_vmlinux3 .tmp_kallsyms3.o
293 fi 296 fi
294fi 297fi
295 298
296info LD vmlinux 299vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o}
297vmlinux_link vmlinux "${kallsymso}" "${btf_vmlinux_bin_o}"
298 300
299if [ -n "${CONFIG_BUILDTIME_EXTABLE_SORT}" ]; then 301if [ -n "${CONFIG_BUILDTIME_EXTABLE_SORT}" ]; then
300 info SORTEX vmlinux 302 info SORTEX vmlinux
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index 2339f86126cb..d1d757c6edf4 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -5,7 +5,8 @@ TARGET=$1
5ARCH=$2 5ARCH=$2
6SMP=$3 6SMP=$3
7PREEMPT=$4 7PREEMPT=$4
8CC=$5 8PREEMPT_RT=$5
9CC=$6
9 10
10vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; } 11vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
11 12
@@ -53,6 +54,7 @@ UTS_VERSION="#$VERSION"
53CONFIG_FLAGS="" 54CONFIG_FLAGS=""
54if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi 55if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi
55if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi 56if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi
57if [ -n "$PREEMPT_RT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT_RT"; fi
56UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP" 58UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP"
57 59
58# Truncate to maximum length 60# Truncate to maximum length
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
index 4d0faebb1719..1cb174751429 100755
--- a/scripts/mkmakefile
+++ b/scripts/mkmakefile
@@ -12,6 +12,6 @@ if [ "${quiet}" != "silent_" ]; then
12fi 12fi
13 13
14cat << EOF > Makefile 14cat << EOF > Makefile
15# Automatically generated by $(realpath $0): don't edit 15# Automatically generated by $0: don't edit
16include $(realpath $1/Makefile) 16include $1/Makefile
17EOF 17EOF
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index e17a29ae2e97..c91eba751804 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -36,6 +36,11 @@ typedef uint16_t __u16;
36typedef unsigned char __u8; 36typedef unsigned char __u8;
37typedef struct { 37typedef struct {
38 __u8 b[16]; 38 __u8 b[16];
39} guid_t;
40
41/* backwards compatibility, don't use in new code */
42typedef struct {
43 __u8 b[16];
39} uuid_le; 44} uuid_le;
40typedef struct { 45typedef struct {
41 __u8 b[16]; 46 __u8 b[16];
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index f277e116e0eb..820eed87fb43 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -169,6 +169,7 @@ struct symbol {
169 unsigned int kernel:1; /* 1 if symbol is from kernel 169 unsigned int kernel:1; /* 1 if symbol is from kernel
170 * (only for external modules) **/ 170 * (only for external modules) **/
171 unsigned int preloaded:1; /* 1 if symbol from Module.symvers, or crc */ 171 unsigned int preloaded:1; /* 1 if symbol from Module.symvers, or crc */
172 unsigned int is_static:1; /* 1 if symbol is not global */
172 enum export export; /* Type of export */ 173 enum export export; /* Type of export */
173 char name[0]; 174 char name[0];
174}; 175};
@@ -201,6 +202,7 @@ static struct symbol *alloc_symbol(const char *name, unsigned int weak,
201 strcpy(s->name, name); 202 strcpy(s->name, name);
202 s->weak = weak; 203 s->weak = weak;
203 s->next = next; 204 s->next = next;
205 s->is_static = 1;
204 return s; 206 return s;
205} 207}
206 208
@@ -795,9 +797,9 @@ static int match(const char *sym, const char * const pat[])
795 797
796 /* "*foo*" */ 798 /* "*foo*" */
797 if (*p == '*' && *endp == '*') { 799 if (*p == '*' && *endp == '*') {
798 char *here, *bare = strndup(p + 1, strlen(p) - 2); 800 char *bare = NOFAIL(strndup(p + 1, strlen(p) - 2));
801 char *here = strstr(sym, bare);
799 802
800 here = strstr(sym, bare);
801 free(bare); 803 free(bare);
802 if (here != NULL) 804 if (here != NULL)
803 return 1; 805 return 1;
@@ -1980,6 +1982,21 @@ static void read_symbols(const char *modname)
1980 handle_modversions(mod, &info, sym, symname); 1982 handle_modversions(mod, &info, sym, symname);
1981 handle_moddevtable(mod, &info, sym, symname); 1983 handle_moddevtable(mod, &info, sym, symname);
1982 } 1984 }
1985
1986 // check for static EXPORT_SYMBOL_* functions && global vars
1987 for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
1988 unsigned char bind = ELF_ST_BIND(sym->st_info);
1989
1990 if (bind == STB_GLOBAL || bind == STB_WEAK) {
1991 struct symbol *s =
1992 find_symbol(remove_dot(info.strtab +
1993 sym->st_name));
1994
1995 if (s)
1996 s->is_static = 0;
1997 }
1998 }
1999
1983 if (!is_vmlinux(modname) || vmlinux_section_warnings) 2000 if (!is_vmlinux(modname) || vmlinux_section_warnings)
1984 check_sec_ref(mod, modname, &info); 2001 check_sec_ref(mod, modname, &info);
1985 2002
@@ -2159,7 +2176,7 @@ static void add_header(struct buffer *b, struct module *mod)
2159 buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n"); 2176 buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n");
2160 buf_printf(b, "\n"); 2177 buf_printf(b, "\n");
2161 buf_printf(b, "__visible struct module __this_module\n"); 2178 buf_printf(b, "__visible struct module __this_module\n");
2162 buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n"); 2179 buf_printf(b, "__section(.gnu.linkonce.this_module) = {\n");
2163 buf_printf(b, "\t.name = KBUILD_MODNAME,\n"); 2180 buf_printf(b, "\t.name = KBUILD_MODNAME,\n");
2164 if (mod->has_init) 2181 if (mod->has_init)
2165 buf_printf(b, "\t.init = init_module,\n"); 2182 buf_printf(b, "\t.init = init_module,\n");
@@ -2213,8 +2230,7 @@ static int add_versions(struct buffer *b, struct module *mod)
2213 2230
2214 buf_printf(b, "\n"); 2231 buf_printf(b, "\n");
2215 buf_printf(b, "static const struct modversion_info ____versions[]\n"); 2232 buf_printf(b, "static const struct modversion_info ____versions[]\n");
2216 buf_printf(b, "__used\n"); 2233 buf_printf(b, "__used __section(__versions) = {\n");
2217 buf_printf(b, "__attribute__((section(\"__versions\"))) = {\n");
2218 2234
2219 for (s = mod->unres; s; s = s->next) { 2235 for (s = mod->unres; s; s = s->next) {
2220 if (!s->module) 2236 if (!s->module)
@@ -2250,10 +2266,7 @@ static void add_depends(struct buffer *b, struct module *mod)
2250 s->module->seen = is_vmlinux(s->module->name); 2266 s->module->seen = is_vmlinux(s->module->name);
2251 2267
2252 buf_printf(b, "\n"); 2268 buf_printf(b, "\n");
2253 buf_printf(b, "static const char __module_depends[]\n"); 2269 buf_printf(b, "MODULE_INFO(depends, \"");
2254 buf_printf(b, "__used\n");
2255 buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
2256 buf_printf(b, "\"depends=");
2257 for (s = mod->unres; s; s = s->next) { 2270 for (s = mod->unres; s; s = s->next) {
2258 const char *p; 2271 const char *p;
2259 if (!s->module) 2272 if (!s->module)
@@ -2271,7 +2284,7 @@ static void add_depends(struct buffer *b, struct module *mod)
2271 buf_printf(b, "%s%s", first ? "" : ",", p); 2284 buf_printf(b, "%s%s", first ? "" : ",", p);
2272 first = 0; 2285 first = 0;
2273 } 2286 }
2274 buf_printf(b, "\";\n"); 2287 buf_printf(b, "\");\n");
2275} 2288}
2276 2289
2277static void add_srcversion(struct buffer *b, struct module *mod) 2290static void add_srcversion(struct buffer *b, struct module *mod)
@@ -2369,6 +2382,7 @@ static void read_dump(const char *fname, unsigned int kernel)
2369 s = sym_add_exported(symname, mod, export_no(export)); 2382 s = sym_add_exported(symname, mod, export_no(export));
2370 s->kernel = kernel; 2383 s->kernel = kernel;
2371 s->preloaded = 1; 2384 s->preloaded = 1;
2385 s->is_static = 0;
2372 sym_update_crc(symname, mod, crc, export_no(export)); 2386 sym_update_crc(symname, mod, crc, export_no(export));
2373 } 2387 }
2374 release_file(file, size); 2388 release_file(file, size);
@@ -2425,6 +2439,7 @@ int main(int argc, char **argv)
2425 char *dump_write = NULL, *files_source = NULL; 2439 char *dump_write = NULL, *files_source = NULL;
2426 int opt; 2440 int opt;
2427 int err; 2441 int err;
2442 int n;
2428 struct ext_sym_list *extsym_iter; 2443 struct ext_sym_list *extsym_iter;
2429 struct ext_sym_list *extsym_start = NULL; 2444 struct ext_sym_list *extsym_start = NULL;
2430 2445
@@ -2520,6 +2535,19 @@ int main(int argc, char **argv)
2520 if (sec_mismatch_count && sec_mismatch_fatal) 2535 if (sec_mismatch_count && sec_mismatch_fatal)
2521 fatal("modpost: Section mismatches detected.\n" 2536 fatal("modpost: Section mismatches detected.\n"
2522 "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n"); 2537 "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n");
2538 for (n = 0; n < SYMBOL_HASH_SIZE; n++) {
2539 struct symbol *s = symbolhash[n];
2540
2541 while (s) {
2542 if (s->is_static)
2543 warn("\"%s\" [%s] is a static %s\n",
2544 s->name, s->module->name,
2545 export_str(s->export));
2546
2547 s = s->next;
2548 }
2549 }
2550
2523 free(buf.p); 2551 free(buf.p);
2524 2552
2525 return err; 2553 return err;
diff --git a/usr/include/Makefile b/usr/include/Makefile
index 1fb6abe29b2f..05c71ef42f51 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -115,6 +115,4 @@ header-test-y += $(filter-out $(header-test-), \
115 $(patsubst $(obj)/%,%, $(wildcard \ 115 $(patsubst $(obj)/%,%, $(wildcard \
116 $(addprefix $(obj)/, *.h */*.h */*/*.h */*/*/*.h)))) 116 $(addprefix $(obj)/, *.h */*.h */*/*.h */*/*/*.h))))
117 117
118# For GNU Make <= 4.2.1, $(wildcard $(obj)/*/) matches to not only directories 118clean-files += $(filter-out Makefile, $(notdir $(wildcard $(obj)/*)))
119# but also regular files. Use $(filter %/, ...) just in case.
120clean-dirs += $(patsubst $(obj)/%/,%,$(filter %/, $(wildcard $(obj)/*/)))