History

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 ...

Linus Torvalds committed 7 years ago

Commit d7b08272 parents 574cc45 77564a496 files · +763 −686Browse files

Unified · Split

96 files
  1. .gitignore +1 −1
  2. Documentation/kbuild/kbuild.rst +9 −19
  3. Documentation/kbuild/makefiles.rst +25 −42
  4. Kbuild +0 −7
  5. Makefile +151 −145
  6. arch/Kconfig +7 −0
  7. arch/alpha/Kconfig +1 −0
  8. arch/arc/Makefile +0 −8
  9. arch/arc/configs/axs101_defconfig +1 −0
  10. arch/arc/configs/axs103_defconfig +1 −0
  11. arch/arc/configs/axs103_smp_defconfig +1 −0
  12. arch/arc/configs/haps_hs_defconfig +1 −0
  13. arch/arc/configs/haps_hs_smp_defconfig +1 −0
  14. arch/arc/configs/hsdk_defconfig +1 −0
  15. arch/arc/configs/nps_defconfig +1 −0
  16. arch/arc/configs/nsim_700_defconfig +1 −0
  17. arch/arc/configs/nsim_hs_defconfig +1 −0
  18. arch/arc/configs/nsim_hs_smp_defconfig +1 −0
  19. arch/arc/configs/nsimosci_defconfig +1 −0
  20. arch/arc/configs/nsimosci_hs_defconfig +1 −0
  21. arch/arc/configs/nsimosci_hs_smp_defconfig +1 −0
  22. arch/arc/configs/tb10x_defconfig +1 −0
  23. arch/arc/configs/vdk_hs38_defconfig +1 −0
  24. arch/arc/configs/vdk_hs38_smp_defconfig +1 −0
  25. arch/arm/Makefile +1 −1
  26. arch/arm/kvm/Makefile +3 −2
  27. arch/arm64/Kconfig +1 −0
  28. arch/arm64/Makefile +1 −1
  29. arch/ia64/Kconfig +1 −0
  30. arch/ia64/Makefile +1 −1
  31. arch/m68k/Kconfig +1 −0
  32. arch/m68k/Makefile +1 −1
  33. arch/mips/Kconfig +1 −0
  34. arch/mips/boot/Makefile +1 −1
  35. arch/parisc/Makefile +1 −1
  36. arch/powerpc/Kconfig +1 −0
  37. arch/powerpc/Makefile +1 −1
  38. arch/powerpc/Makefile.postlink +1 −1
  39. arch/powerpc/kernel/prom_init_check.sh +1 −1
  40. arch/riscv/Kconfig +1 −0
  41. arch/riscv/Makefile +1 −1
  42. arch/s390/Kconfig +1 −0
  43. arch/sparc/Kconfig +1 −0
  44. arch/um/Kconfig +1 −0
  45. arch/x86/Kconfig +1 −0
  46. arch/x86/entry/vdso/Makefile +2 −1
  47. drivers/gpu/drm/amd/display/dc/calcs/Makefile +3 −3
  48. drivers/gpu/drm/amd/display/dc/dcn20/Makefile +2 −2
  49. drivers/gpu/drm/amd/display/dc/dcn21/Makefile +1 −1
  50. drivers/gpu/drm/amd/display/dc/dml/Makefile +11 −14
  51. drivers/gpu/drm/amd/display/dc/dsc/Makefile +3 −4
  52. drivers/gpu/drm/i915/Makefile +1 −1
  53. drivers/net/ethernet/aquantia/atlantic/hw_atl/Makefile +0 −2
  54. drivers/net/ethernet/mellanox/mlx5/core/accel/Makefile +0 −2
  55. drivers/net/ethernet/mellanox/mlx5/core/diag/Makefile +0 −2
  56. drivers/net/ethernet/mellanox/mlx5/core/en/Makefile +0 −2
  57. drivers/net/ethernet/mellanox/mlx5/core/en/xsk/Makefile +0 −1
  58. drivers/net/ethernet/mellanox/mlx5/core/en_accel/Makefile +0 −2
  59. drivers/net/ethernet/mellanox/mlx5/core/fpga/Makefile +0 −2
  60. drivers/net/ethernet/mellanox/mlx5/core/ipoib/Makefile +0 −2
  61. drivers/net/ethernet/mellanox/mlx5/core/lib/Makefile +0 −2
  62. drivers/net/ethernet/netronome/nfp/bpf/Makefile +0 −2
  63. drivers/net/ethernet/netronome/nfp/flower/Makefile +0 −2
  64. drivers/net/ethernet/netronome/nfp/nfpcore/Makefile +0 −2
  65. drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000/Makefile +0 −2
  66. drivers/net/ethernet/netronome/nfp/nic/Makefile +0 −2
  67. include/linux/compiler_types.h +14 −6
  68. include/linux/export.h +16 −26
  69. include/linux/vermagic.h +2 −0
  70. init/Kconfig +20 −6
  71. init/Makefile +3 −2
  72. kernel/Makefile +1 −1
  73. scripts/Kconfig.include +3 −0
  74. scripts/Makefile +1 −1
  75. scripts/Makefile.build +43 −30
  76. scripts/Makefile.clean +5 −26
  77. scripts/Makefile.extrawarn +69 −52
  78. scripts/Makefile.host +28 −11
  79. scripts/Makefile.lib +28 −35
  80. scripts/Makefile.modfinal +60 −0
  81. scripts/Makefile.modpost +12 −68
  82. scripts/Makefile.package +24 −19
  83. scripts/basic/Makefile +2 −12
  84. scripts/genksyms/Makefile +2 −9
  85. scripts/genksyms/keywords.c +1 −5
  86. scripts/genksyms/lex.l +10 −22
  87. scripts/genksyms/parse.y +10 −22
  88. scripts/headers_install.sh +72 −0
  89. scripts/kconfig/Makefile +5 −5
  90. scripts/kconfig/merge_config.sh +6 −6
  91. scripts/link-vmlinux.sh +21 −19
  92. scripts/mkcompile_h +3 −1
  93. scripts/mkmakefile +2 −2
  94. scripts/mod/file2alias.c +5 −0
  95. scripts/mod/modpost.c +38 −10
  96. usr/include/Makefile +1 −3
.gitignore+1−1
@@ -34,7 +34,6 @@ · 33 unmodified lines
3434 *.mod.c
3535 *.o
3636 *.o.*
37−*.order
3837 *.patch
3938 *.s
4039 *.so
@@ -46,6 +45,7 @@ · 5 unmodified lines
4645 *.xz
4746 Module.symvers
4847 modules.builtin
48+modules.order
4949
5050 #
5151 # Top-level generic files
Documentation/kbuild/kbuild.rst+9−19
@@ -105,6 +105,15 @@ The output directory can also be specified using "O=...". · 104 unmodified lines
105105
106106 Setting "O=..." takes precedence over KBUILD_OUTPUT.
107107
108+KBUILD_EXTRA_WARN
109+-----------------
110+Specify the extra build checks. The same value can be assigned by passing
111+W=... from the command line.
112+
113+See `make help` for the list of the supported values.
114+
115+Setting "W=..." takes precedence over KBUILD_EXTRA_WARN.
116+
108117 KBUILD_DEBARCH
109118 --------------
110119 For 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.:: · 130 unmodified lines
241250
242251 $ make ALLSOURCE_ARCHS=all tags
243252
244−KBUILD_ENABLE_EXTRA_GCC_CHECKS
245−------------------------------
246−If enabled over the make command line with "W=1", it turns on additional
247−gcc -W... options for more extensive build-time checking.
248−
249253 KBUILD_BUILD_TIMESTAMP
250254 ----------------------
251255 Setting this to a date string overrides the timestamp used in the
@@ -258,17 +262,3 @@ KBUILD_BUILD_USER, KBUILD_BUILD_HOST · 6 unmodified lines
258262 These two variables allow to override the user@host string displayed during
259263 boot and in /proc/version. The default value is the output of the commands
260264 whoami and host, respectively.
261−
262−KBUILD_LDS
263−----------
264−The linker script with full path. Assigned by the top-level Makefile.
265−
266−KBUILD_VMLINUX_OBJS
267−-------------------
268−All object files for vmlinux. They are linked to vmlinux in the same
269−order as listed in KBUILD_VMLINUX_OBJS.
270−
271−KBUILD_VMLINUX_LIBS
272−-------------------
273−All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS
274−together specify all the object files used to link vmlinux.
Documentation/kbuild/makefiles.rst+25−42
@@ -471,21 +471,6 @@ more details, with real examples. · 470 unmodified lines
471471 The second argument is optional, and if supplied will be used
472472 if first argument is not supported.
473473
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−
489474 as-instr
490475 as-instr checks if the assembler reports a specific instruction
491476 and then outputs either option1 or option2
@@ -765,7 +750,8 @@ Files matching the patterns "*.[oas]", "*.ko", plus some additional files · 273 unmodified lines
765750 generated by kbuild are deleted all over the kernel src tree when
766751 "make clean" is executed.
767752
768−Additional files can be specified in kbuild makefiles by use of $(clean-files).
753+Additional files or directories can be specified in kbuild makefiles by use of
754+$(clean-files).
769755
770756 Example::
771757
@@ -776,23 +762,8 @@ When executing "make clean", the file "crc32table.h" will be deleted. · 4 unmodified lines
776762 Kbuild will assume files to be in the same relative directory as the
777763 Makefile, except if prefixed with $(objtree).
778764
779−To delete a directory hierarchy use:
780−
781− Example::
782−
783− #scripts/package/Makefile
784− clean-dirs := $(objtree)/debian/
785−
786−This will delete the directory debian in the toplevel directory, including all
787−subdirectories.
788−
789−To exclude certain files from make clean, use the $(no-clean-files) variable.
790−This 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)
765+To exclude certain files or directories from make clean, use the
766+$(no-clean-files) variable.
796767
797768 Usually kbuild descends down in subdirectories due to "obj-* := dir/",
798769 but in the architecture makefiles where the kbuild infrastructure
@@ -988,13 +959,25 @@ When kbuild executes, the following steps are followed (roughly): · 189 unmodified lines
988959 $(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic
989960 mode) if this option is supported by $(AR).
990961
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.
992975
993− These variables are appended to the KBUILD_CPPFLAGS,
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.
976+ KBUILD_VMLINUX_LIBS
997977
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.
998981
999982 6.2 Add prerequisites to archheaders
1000983 ------------------------------------
@@ -1139,7 +1122,7 @@ When kbuild executes, the following steps are followed (roughly): · 138 unmodified lines
11391122
11401123 header-test-y
11411124
1142− header-test-y specifies headers (*.h) in the current directory that
1125+ header-test-y specifies headers (`*.h`) in the current directory that
11431126 should be compile tested to ensure they are self-contained,
11441127 i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled,
11451128 this builds them as part of extra-y.
@@ -1147,11 +1130,11 @@ When kbuild executes, the following steps are followed (roughly): · 1 unmodified line
11471130 header-test-pattern-y
11481131
11491132 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::
11511134
1152− header-test-pattern-y += *.h
1135+ header-test-pattern-y += *.h
11531136
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
11551138 directory, but the files in 'header-test-' are excluded.
11561139
11571140 6.7 Commands useful for building a boot image
Kbuild+0−7
@@ -18,8 +18,6 @@ $(bounds-file): kernel/bounds.s FORCE · 17 unmodified lines
1818
1919 timeconst-file := include/generated/timeconst.h
2020
21−targets += $(timeconst-file)
22−
2321 filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $<
2422
2523 $(timeconst-file): kernel/time/timeconst.bc FORCE
@@ -42,7 +40,6 @@ $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE · 16 unmodified lines
4240 # Check for missing system calls
4341
4442 always += missing-syscalls
45−targets += missing-syscalls
4643
4744 quiet_cmd_syscalls = CALL $<
4845 cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
@@ -54,13 +51,9 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE · 5 unmodified lines
5451 # Check atomic headers are up-to-date
5552
5653 always += old-atomics
57−targets += old-atomics
5854
5955 quiet_cmd_atomics = CALL $<
6056 cmd_atomics = $(CONFIG_SHELL) $<
6157
6258 old-atomics: scripts/atomic/check-atomics.sh FORCE
6359 $(call cmd,atomics)
64−
65−# Keep these three files during make clean
66−no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)
Makefile+151−145
@@ -230,6 +230,8 @@ endif · 229 unmodified lines
230230
231231 export KBUILD_CHECKSRC KBUILD_EXTMOD
232232
233+extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
234+
233235 ifeq ($(abs_srctree),$(abs_objtree))
234236 # building in the source tree
235237 srctree := .
@@ -271,52 +273,62 @@ no-dot-config-targets := $(clean-targets) \ · 35 unmodified lines
271273 %asm-generic kernelversion %src-pkg
272274 no-sync-config-targets := $(no-dot-config-targets) install %install \
273275 kernelrelease
276+single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
274277
275−config-targets := 0
276−mixed-targets := 0
277−dot-config := 1
278−may-sync-config := 1
278+config-build :=
279+mixed-build :=
280+need-config := 1
281+may-sync-config := 1
282+single-build :=
279283
280284 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
281285 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
282− dot-config := 0
286+ need-config :=
283287 endif
284288 endif
285289
286290 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
287291 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
288− may-sync-config := 0
292+ may-sync-config :=
289293 endif
290294 endif
291295
292296 ifneq ($(KBUILD_EXTMOD),)
293− may-sync-config := 0
297+ may-sync-config :=
294298 endif
295299
296300 ifeq ($(KBUILD_EXTMOD),)
297301 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
298− config-targets := 1
302+ config-build := 1
299303 ifneq ($(words $(MAKECMDGOALS)),1)
300− mixed-targets := 1
304+ mixed-build := 1
301305 endif
302306 endif
303307 endif
304308
309+# We cannot build single targets and the others at the same time
310+ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
311+ single-build := 1
312+ ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
313+ mixed-build := 1
314+ endif
315+endif
316+
305317 # For "make -j clean all", "make -j mrproper defconfig all", etc.
306318 ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
307319 ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
308− mixed-targets := 1
320+ mixed-build := 1
309321 endif
310322 endif
311323
312324 # install and modules_install need also be processed one by one
313325 ifneq ($(filter install,$(MAKECMDGOALS)),)
314326 ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
315− mixed-targets := 1
327+ mixed-build := 1
316328 endif
317329 endif
318330
319−ifeq ($(mixed-targets),1)
331+ifdef mixed-build
320332 # ===========================================================================
321333 # We're called with mixed targets (*config and build targets).
322334 # Handle them one by one.
@@ -332,7 +344,7 @@ __build_one_by_one: · 9 unmodified lines
332344 $(MAKE) -f $(srctree)/Makefile $$i; \
333345 done
334346
335−else
347+else # !mixed-build
336348
337349 include scripts/Kbuild.include
338350
@@ -392,9 +404,7 @@ KCONFIG_CONFIG ?= .config · 53 unmodified lines
392404 export KCONFIG_CONFIG
393405
394406 # SHELL used by kbuild
395−CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
396− else if [ -x /bin/bash ]; then echo /bin/bash; \
397− else echo sh; fi ; fi)
407+CONFIG_SHELL := sh
398408
399409 HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
400410 HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
@@ -431,6 +441,7 @@ PYTHON = python · 30 unmodified lines
431441 PYTHON2 = python2
432442 PYTHON3 = python3
433443 CHECK = sparse
444+BASH = bash
434445
435446 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
436447 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
@@ -470,12 +481,13 @@ KBUILD_AFLAGS_KERNEL := · 33 unmodified lines
470481 KBUILD_CFLAGS_KERNEL :=
471482 KBUILD_AFLAGS_MODULE := -DMODULE
472483 KBUILD_CFLAGS_MODULE := -DMODULE
473−KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
484+KBUILD_LDFLAGS_MODULE :=
485+export KBUILD_LDS_MODULE := $(srctree)/scripts/module-common.lds
474486 KBUILD_LDFLAGS :=
475487 GCC_PLUGINS_CFLAGS :=
476488 CLANG_FLAGS :=
477489
478−export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
490+export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
479491 export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK INSTALLKERNEL
480492 export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
481493 export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
@@ -506,6 +518,7 @@ scripts_basic: · 24 unmodified lines
506518 $(Q)rm -f .tmp_quiet_recordmcount
507519
508520 PHONY += outputmakefile
521+# Before starting out-of-tree build, make sure the source tree is clean.
509522 # outputmakefile generates a Makefile in the output directory, if using a
510523 # separate output directory. This allows convenient use of make in the
511524 # output directory.
@@ -513,6 +526,15 @@ PHONY += outputmakefile · 1 unmodified line
513526 # ignore whole output directory
514527 outputmakefile:
515528 ifdef 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
516538 $(Q)ln -fsn $(srctree) source
517539 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
518540 $(Q)test -e .gitignore || \
@@ -544,7 +566,7 @@ endif · 25 unmodified lines
544566 # and from include/config/auto.conf.cmd to detect the compiler upgrade.
545567 CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1)
546568
547−ifeq ($(config-targets),1)
569+ifdef config-build
548570 # ===========================================================================
549571 # *config targets only - make sure prerequisites are updated, and descend
550572 # in scripts/kconfig to make the *config target
@@ -555,13 +577,13 @@ ifeq ($(config-targets),1) · 4 unmodified lines
555577 include arch/$(SRCARCH)/Makefile
556578 export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
557579
558−config: scripts_basic outputmakefile FORCE
580+config: outputmakefile scripts_basic FORCE
559581 $(Q)$(MAKE) $(build)=scripts/kconfig $@
560582
561−%config: scripts_basic outputmakefile FORCE
583+%config: outputmakefile scripts_basic FORCE
562584 $(Q)$(MAKE) $(build)=scripts/kconfig $@
563585
564−else
586+else #!config-build
565587 # ===========================================================================
566588 # Build targets only - this includes vmlinux, arch specific targets, clean
567589 # targets and others. In general all targets except *config targets.
@@ -604,7 +626,7 @@ endif · 36 unmodified lines
604626
605627 export KBUILD_MODULES KBUILD_BUILTIN
606628
607−ifeq ($(dot-config),1)
629+ifdef need-config
608630 include include/config/auto.conf
609631 endif
610632
@@ -645,15 +667,10 @@ RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc · 34 unmodified lines
645667 export RETPOLINE_CFLAGS
646668 export RETPOLINE_VDSO_CFLAGS
647669
648−# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
649−# values of the respective KBUILD_* variables
650−ARCH_CPPFLAGS :=
651−ARCH_AFLAGS :=
652−ARCH_CFLAGS :=
653670 include arch/$(SRCARCH)/Makefile
654671
655−ifeq ($(dot-config),1)
656−ifeq ($(may-sync-config),1)
672+ifdef need-config
673+ifdef may-sync-config
657674 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
658675 # changes are detected. This should be included after arch/$(SRCARCH)/Makefile
659676 # because some architectures define CROSS_COMPILE there.
@@ -676,7 +693,7 @@ $(KCONFIG_CONFIG): · 16 unmodified lines
676693 # The syncconfig should be executed only once to make all the targets.
677694 %/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
678695 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
679−else
696+else # !may-sync-config
680697 # External modules and some install targets need include/generated/autoconf.h
681698 # and include/config/auto.conf but do not care if they are up-to-date.
682699 # Use auto.conf to trigger the test
@@ -692,7 +709,7 @@ include/config/auto.conf: · 9 unmodified lines
692709 /bin/false)
693710
694711 endif # may-sync-config
695−endif # $(dot-config)
712+endif # need-config
696713
697714 KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
698715 KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
@@ -700,10 +717,12 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) · 1 unmodified line
700717 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
701718 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
702719
703−ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
704−KBUILD_CFLAGS += -Os
705−else
706−KBUILD_CFLAGS += -O2
720+ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
721+KBUILD_CFLAGS += -O2
722+else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
723+KBUILD_CFLAGS += -O3
724+else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
725+KBUILD_CFLAGS += -Os
707726 endif
708727
709728 ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED
@@ -751,6 +770,11 @@ else · 41 unmodified lines
751770 # These warnings generated too much noise in a regular build.
752771 # Use make W=1 to enable them (see scripts/Makefile.extrawarn)
753772 KBUILD_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.
777+KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
754778 endif
755779
756780 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
@@ -845,9 +869,6 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) · 88 unmodified lines
845869 # warn about C99 declaration after statement
846870 KBUILD_CFLAGS += -Wdeclaration-after-statement
847871
848−# Warn about unmarked fall-throughs in switch statement.
849−KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
850−
851872 # Variable Length Arrays (VLAs) should not be used anywhere in the kernel
852873 KBUILD_CFLAGS += -Wvla
853874
@@ -900,11 +921,10 @@ include scripts/Makefile.kasan · 46 unmodified lines
900921 include scripts/Makefile.extrawarn
901922 include scripts/Makefile.ubsan
902923
903−# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the
904−# last assignments
905−KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS)
906−KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS)
907−KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS)
924+# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
925+KBUILD_CPPFLAGS += $(KCPPFLAGS)
926+KBUILD_AFLAGS += $(KAFLAGS)
927+KBUILD_CFLAGS += $(KCFLAGS)
908928
909929 KBUILD_LDFLAGS_MODULE += --build-id
910930 LDFLAGS_vmlinux += --build-id
@@ -1007,7 +1027,7 @@ endif · 96 unmodified lines
10071027
10081028 PHONY += prepare0
10091029
1010−export MODORDER := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order
1030+export MODORDER := $(extmod-prefix)modules.order
10111031
10121032 ifeq ($(KBUILD_EXTMOD),)
10131033 core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
@@ -1020,6 +1040,9 @@ vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ · 6 unmodified lines
10201040 $(patsubst %/,%,$(filter %/, $(init-) $(core-) \
10211041 $(drivers-) $(net-) $(libs-) $(virt-))))
10221042
1043+build-dirs := $(vmlinux-dirs)
1044+clean-dirs := $(vmlinux-alldirs)
1045+
10231046 init-y := $(patsubst %/, %/built-in.a, $(init-y))
10241047 core-y := $(patsubst %/, %/built-in.a, $(core-y))
10251048 drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y))
@@ -1042,7 +1065,7 @@ vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) · 16 unmodified lines
10421065 # Recurse until adjust_autoksyms.sh is satisfied
10431066 PHONY += autoksyms_recursive
10441067 ifdef CONFIG_TRIM_UNUSED_KSYMS
1045−autoksyms_recursive: $(vmlinux-deps) modules.order
1068+autoksyms_recursive: descend modules.order
10461069 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
10471070 "$(MAKE) -f $(srctree)/Makefile vmlinux"
10481071 endif
@@ -1074,17 +1097,7 @@ targets := vmlinux · 25 unmodified lines
10741097
10751098 # The actual objects are generated when descending,
10761099 # make sure no implicit rule kicks in
1077−$(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
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−
1085−PHONY += $(vmlinux-dirs)
1086−$(vmlinux-dirs): prepare
1087− $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1
1100+$(sort $(vmlinux-deps)): descend ;
10881101
10891102 filechk_kernel.release = \
10901103 echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
@@ -1106,24 +1119,9 @@ scripts: scripts_basic scripts_dtc · 15 unmodified lines
11061119 # archprepare is used in arch Makefiles and when processed asm symlink,
11071120 # version.h and scripts_basic is processed / created.
11081121
1109−PHONY += prepare archprepare prepare3
1122+PHONY += prepare archprepare
11101123
1111−# prepare3 is used to check if we are building in a separate output directory,
1112−# and if so do:
1113−# 1) Check that make has not been executed in the kernel src $(srctree)
1114−prepare3: include/config/kernel.release
1115−ifdef 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;
1124−endif
1125−
1126−archprepare: archheaders archscripts scripts prepare3 outputmakefile \
1124+archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
11271125 asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h
11281126
11291127 prepare0: archprepare
@@ -1248,7 +1246,7 @@ kselftest-merge: · 118 unmodified lines
12481246 $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!))
12491247 $(Q)find $(srctree)/tools/testing/selftests -name config | \
12501248 xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
1251− +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1249+ $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
12521250
12531251 # ---------------------------------------------------------------------------
12541252 # Devicetree files
@@ -1259,11 +1257,11 @@ endif · 4 unmodified lines
12591257
12601258 ifneq ($(dtstree),)
12611259
1262−%.dtb: prepare3 scripts_dtc
1260+%.dtb: include/config/kernel.release scripts_dtc
12631261 $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
12641262
12651263 PHONY += dtbs dtbs_install dt_binding_check
1266−dtbs dtbs_check: prepare3 scripts_dtc
1264+dtbs dtbs_check: include/config/kernel.release scripts_dtc
12671265 $(Q)$(MAKE) $(build)=$(dtstree)
12681266
12691267 dtbs_check: export CHECK_DTBS=1
@@ -1302,17 +1300,16 @@ all: modules · 32 unmodified lines
13021300
13031301 PHONY += modules
13041302 modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules.builtin
1305− @$(kecho) ' Building modules, stage 2.';
13061303 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
13071304 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh
13081305
1309−modules.order: $(vmlinux-dirs)
1310− $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@
1306+modules.order: descend
1307+ $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
13111308
1312−modbuiltin-dirs := $(addprefix _modbuiltin_, $(vmlinux-dirs))
1309+modbuiltin-dirs := $(addprefix _modbuiltin_, $(build-dirs))
13131310
13141311 modules.builtin: $(modbuiltin-dirs)
1315− $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@
1312+ $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
13161313
13171314 PHONY += $(modbuiltin-dirs)
13181315 # tristate.conf is not included from this Makefile. Add it as a prerequisite
@@ -1385,12 +1382,14 @@ CLEAN_FILES += modules.builtin.modinfo · 66 unmodified lines
13851382
13861383 # Directories & files removed with 'make mrproper'
13871384 MRPROPER_DIRS += include/config include/generated \
1388− arch/$(SRCARCH)/include/generated .tmp_objdiff
1385+ arch/$(SRCARCH)/include/generated .tmp_objdiff \
1386+ debian/ snap/ tar-install/
13891387 MRPROPER_FILES += .config .config.old .version \
13901388 Module.symvers \
13911389 signing_key.pem signing_key.priv signing_key.x509 \
13921390 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
13941393
13951394 # Directories & files removed with 'make distclean'
13961395 DISTCLEAN_DIRS +=
@@ -1400,11 +1399,8 @@ DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS · 3 unmodified lines
14001399 #
14011400 clean: rm-dirs := $(CLEAN_DIRS)
14021401 clean: rm-files := $(CLEAN_FILES)
1403−clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs))
14041402
1405−PHONY += $(clean-dirs) clean archclean vmlinuxclean
1406−$(clean-dirs):
1407− $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1403+PHONY += archclean vmlinuxclean
14081404
14091405 vmlinuxclean:
14101406 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
@@ -1445,13 +1441,11 @@ distclean: mrproper · 34 unmodified lines
14451441
14461442 # Packaging of the kernel to various formats
14471443 # ---------------------------------------------------------------------------
1448−package-dir := scripts/package
14491444
14501445 %src-pkg: FORCE
1451− $(Q)$(MAKE) $(build)=$(package-dir) $@
1446+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
14521447 %pkg: include/config/kernel.release FORCE
1453− $(Q)$(MAKE) $(build)=$(package-dir) $@
1454−
1448+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
14551449
14561450 # Brief documentation of the typical targets used
14571451 # ---------------------------------------------------------------------------
@@ -1525,7 +1519,7 @@ help: · 67 unmodified lines
15251519 @echo ' or "cd tools; make help"'
15261520 @echo ''
15271521 @echo 'Kernel packaging:'
1528− @$(MAKE) $(build)=$(package-dir) help
1522+ @$(MAKE) -f $(srctree)/scripts/Makefile.package help
15291523 @echo ''
15301524 @echo 'Documentation targets:'
15311525 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
@@ -1550,7 +1544,7 @@ help: · 18 unmodified lines
15501544 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK (sparse by default)'
15511545 @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
15521546 @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'
15541548 @echo ' 1: warnings which may be relevant and do not occur too often'
15551549 @echo ' 2: warnings which occur quite often but may still be relevant'
15561550 @echo ' 3: more obscure warnings, can most likely be ignored'
@@ -1579,7 +1573,7 @@ $(help-board-dirs): help-%: · 22 unmodified lines
15791573 DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
15801574 linkcheckdocs dochelp refcheckdocs
15811575 PHONY += $(DOC_TARGETS)
1582−$(DOC_TARGETS): scripts_basic FORCE
1576+$(DOC_TARGETS):
15831577 $(Q)$(MAKE) $(build)=Documentation $@
15841578
15851579 # Misc
@@ -1624,13 +1618,9 @@ $(objtree)/Module.symvers: · 38 unmodified lines
16241618 echo " is missing; modules will have no dependencies and modversions."; \
16251619 echo )
16261620
1627−module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
1628−PHONY += $(module-dirs) modules
1629−$(module-dirs): prepare $(objtree)/Module.symvers
1630− $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) need-modorder=1
1631−
1632−modules: $(module-dirs)
1633− @$(kecho) ' Building modules, stage 2.';
1621+build-dirs := $(KBUILD_EXTMOD)
1622+PHONY += modules
1623+modules: descend $(objtree)/Module.symvers
16341624 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
16351625
16361626 PHONY += modules_install
@@ -1646,14 +1636,13 @@ PHONY += _emodinst_post · 9 unmodified lines
16461636 _emodinst_post: _emodinst_
16471637 $(call cmd,depmod)
16481638
1649−clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
1650−
1651−PHONY += $(clean-dirs) clean
1652−$(clean-dirs):
1653− $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1654−
1639+clean-dirs := $(KBUILD_EXTMOD)
16551640 clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
16561641
1642+PHONY += /
1643+/:
1644+ @echo >&2 '"$(MAKE) /" is no longer supported. Please use "$(MAKE) ./" instead.'
1645+
16571646 PHONY += help
16581647 help:
16591648 @echo ' Building external modules.'
@@ -1667,6 +1656,21 @@ help: · 7 unmodified lines
16671656 PHONY += prepare
16681657 endif # KBUILD_EXTMOD
16691658
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
1664+PHONY += descend $(build-dirs)
1665+descend: $(build-dirs)
1666+$(build-dirs): prepare
1667+ $(Q)$(MAKE) $(build)=$@ single-build=$(single-build) need-builtin=1 need-modorder=1
1668+
1669+clean-dirs := $(addprefix _clean_, $(clean-dirs))
1670+PHONY += $(clean-dirs) clean
1671+$(clean-dirs):
1672+ $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1673+
16701674 clean: $(clean-dirs)
16711675 $(call cmd,rmdirs)
16721676 $(call cmd,rmfiles)
@@ -1688,7 +1692,7 @@ clean: $(clean-dirs) · 15 unmodified lines
16881692 # Generate tags for editors
16891693 # ---------------------------------------------------------------------------
16901694 quiet_cmd_tags = GEN $@
1691− cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@
1695+ cmd_tags = $(BASH) $(srctree)/scripts/tags.sh $@
16921696
16931697 tags TAGS cscope gtags: FORCE
16941698 $(call cmd,tags)
@@ -1709,7 +1713,7 @@ versioncheck: · 14 unmodified lines
17091713 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
17101714
17111715 coccicheck:
1712− $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@
1716+ $(Q)$(BASH) $(srctree)/scripts/$@
17131717
17141718 namespacecheck:
17151719 $(PERL) $(srctree)/scripts/namespace.pl
@@ -1757,45 +1761,47 @@ tools/%: FORCE · 41 unmodified lines
17571761
17581762 # Single targets
17591763 # ---------------------------------------------------------------------------
1760−# Single targets are compatible with:
1761−# - build with mixed source and output
1762−# - build with separate output dir 'make O=...'
1763−# - external modules
1764+# To build individual files in subdirectories, you can do like this:
1765+#
1766+# make foo/bar/baz.s
17641767 #
1765−# target-dir => where to store outputfile
1766−# build-dir => directory in kernel source tree to use
1767−
1768−build-target = $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD)/)$@
1769−build-dir = $(patsubst %/,%,$(dir $(build-target)))
1770−
1771−%.i: prepare FORCE
1772− $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1773−%.ll: prepare FORCE
1774− $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1775−%.lst: prepare FORCE
1776− $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1777−%.o: prepare FORCE
1778− $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1779−%.s: prepare FORCE
1780− $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1781−%.symtypes: prepare FORCE
1782− $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1768+# The supported suffixes for single-target are listed in 'single-targets'
1769+#
1770+# To build only under specific subdirectories, you can do like this:
1771+#
1772+# make foo/bar/baz/
1773+
1774+ifdef single-build
1775+
1776+single-all := $(filter $(single-targets), $(MAKECMDGOALS))
1777+
1778+# .ko is special because modpost is needed
1779+single-ko := $(sort $(filter %.ko, $(single-all)))
1780+single-no-ko := $(sort $(patsubst %.ko,%.mod, $(single-all)))
1781+
1782+$(single-ko): single_modpost
1783+ @:
1784+$(single-no-ko): descend
1785+ @:
1786+
17831787 ifeq ($(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
17851789 # the situation of modules_install installing an invalid modules.order.
1786−%.ko: MODORDER := .modules.tmp
1790+MODORDER := .modules.tmp
17871791 endif
1788−%.ko: prepare FORCE
1789− $(Q)$(MAKE) $(build)=$(build-dir) $(build-target:.ko=.mod)
1790− $(Q)echo $(build-target) > $(MODORDER)
1792+
1793+PHONY += single_modpost
1794+single_modpost: $(single-no-ko)
1795+ $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER)
17911796 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
17921797
1793−# Modules
1794−PHONY += /
1795−/: ./
1798+KBUILD_MODULES := 1
17961799
1797−%/: prepare FORCE
1798− $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) need-modorder=1
1800+export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko))
1801+
1802+single-build = $(if $(filter-out $@/, $(single-no-ko)),1)
1803+
1804+endif
17991805
18001806 # FIXME Should go into a make.lib or something
18011807 # ===========================================================================
@@ -1816,9 +1822,9 @@ existing-targets := $(wildcard $(sort $(targets))) · 14 unmodified lines
18161822
18171823 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
18181824
1819−endif # ifeq ($(config-targets),1)
1820−endif # ifeq ($(mixed-targets),1)
1821−endif # need-sub-make
1825+endif # config-targets
1826+endif # mixed-build
1827+endif # need-sub-make
18221828
18231829 PHONY += FORCE
18241830 FORCE:
arch/Kconfig+7−0
@@ -292,6 +292,13 @@ config ARCH_32BIT_OFF_T · 291 unmodified lines
292292 still support 32-bit off_t. This option is enabled for all such
293293 architectures explicitly.
294294
295+config 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+
295302 config HAVE_REGS_AND_STACK_ACCESS_API
296303 bool
297304 help
arch/alpha/Kconfig+1−0
@@ -11,6 +11,7 @@ config ALPHA · 10 unmodified lines
1111 select PCI_DOMAINS if PCI
1212 select PCI_SYSCALL if PCI
1313 select HAVE_AOUT
14+ select HAVE_ASM_MODVERSIONS
1415 select HAVE_IDE
1516 select HAVE_OPROFILE
1617 select HAVE_PCSPKR_PLATFORM
arch/arc/Makefile+0−8
@@ -48,14 +48,6 @@ endif · 47 unmodified lines
4848 cfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI)
4949 cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables $(cfi)
5050
51−ifndef 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
56−ARCH_CFLAGS += -O3 $(call cc-disable-warning,maybe-uninitialized,)
57−endif
58−
5951 # small data is default for elf32 tool-chain. If not usable, disable it
6052 # This also allows repurposing GP as scratch reg to gcc reg allocator
6153 disable_small_data := y
arch/arc/configs/axs101_defconfig+1−0
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y · 8 unmodified lines
99 # CONFIG_UTS_NS is not set
1010 # CONFIG_PID_NS is not set
1111 CONFIG_BLK_DEV_INITRD=y
12+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1213 CONFIG_EMBEDDED=y
1314 CONFIG_PERF_EVENTS=y
1415 # CONFIG_VM_EVENT_COUNTERS is not set
arch/arc/configs/axs103_defconfig+1−0
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y · 8 unmodified lines
99 # CONFIG_UTS_NS is not set
1010 # CONFIG_PID_NS is not set
1111 CONFIG_BLK_DEV_INITRD=y
12+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1213 CONFIG_EMBEDDED=y
1314 CONFIG_PERF_EVENTS=y
1415 # CONFIG_VM_EVENT_COUNTERS is not set
arch/arc/configs/axs103_smp_defconfig+1−0
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y · 8 unmodified lines
99 # CONFIG_UTS_NS is not set
1010 # CONFIG_PID_NS is not set
1111 CONFIG_BLK_DEV_INITRD=y
12+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1213 CONFIG_EMBEDDED=y
1314 CONFIG_PERF_EVENTS=y
1415 # CONFIG_VM_EVENT_COUNTERS is not set
arch/arc/configs/haps_hs_defconfig+1−0
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y · 9 unmodified lines
1010 # CONFIG_UTS_NS is not set
1111 # CONFIG_PID_NS is not set
1212 CONFIG_BLK_DEV_INITRD=y
13+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314 CONFIG_EXPERT=y
1415 CONFIG_PERF_EVENTS=y
1516 # CONFIG_COMPAT_BRK is not set
arch/arc/configs/haps_hs_smp_defconfig+1−0
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y · 9 unmodified lines
1010 # CONFIG_UTS_NS is not set
1111 # CONFIG_PID_NS is not set
1212 CONFIG_BLK_DEV_INITRD=y
13+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314 CONFIG_EMBEDDED=y
1415 CONFIG_PERF_EVENTS=y
1516 # CONFIG_VM_EVENT_COUNTERS is not set
arch/arc/configs/hsdk_defconfig+1−0
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y · 8 unmodified lines
99 # CONFIG_PID_NS is not set
1010 CONFIG_BLK_DEV_INITRD=y
1111 CONFIG_BLK_DEV_RAM=y
12+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1213 CONFIG_EMBEDDED=y
1314 CONFIG_PERF_EVENTS=y
1415 # CONFIG_VM_EVENT_COUNTERS is not set
arch/arc/configs/nps_defconfig+1−0
@@ -6,6 +6,7 @@ CONFIG_HIGH_RES_TIMERS=y · 5 unmodified lines
66 CONFIG_IKCONFIG=y
77 CONFIG_IKCONFIG_PROC=y
88 CONFIG_BLK_DEV_INITRD=y
9+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
910 CONFIG_SYSCTL_SYSCALL=y
1011 # CONFIG_EPOLL is not set
1112 # CONFIG_SIGNALFD is not set
arch/arc/configs/nsim_700_defconfig+1−0
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y · 9 unmodified lines
1010 # CONFIG_UTS_NS is not set
1111 # CONFIG_PID_NS is not set
1212 CONFIG_BLK_DEV_INITRD=y
13+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314 CONFIG_KALLSYMS_ALL=y
1415 CONFIG_EMBEDDED=y
1516 CONFIG_PERF_EVENTS=y
arch/arc/configs/nsim_hs_defconfig+1−0
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y · 9 unmodified lines
1010 # CONFIG_UTS_NS is not set
1111 # CONFIG_PID_NS is not set
1212 CONFIG_BLK_DEV_INITRD=y
13+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314 CONFIG_KALLSYMS_ALL=y
1415 CONFIG_EMBEDDED=y
1516 CONFIG_PERF_EVENTS=y
arch/arc/configs/nsim_hs_smp_defconfig+1−0
@@ -8,6 +8,7 @@ CONFIG_NAMESPACES=y · 7 unmodified lines
88 # CONFIG_UTS_NS is not set
99 # CONFIG_PID_NS is not set
1010 CONFIG_BLK_DEV_INITRD=y
11+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1112 CONFIG_KALLSYMS_ALL=y
1213 CONFIG_EMBEDDED=y
1314 CONFIG_PERF_EVENTS=y
arch/arc/configs/nsimosci_defconfig+1−0
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y · 9 unmodified lines
1010 # CONFIG_UTS_NS is not set
1111 # CONFIG_PID_NS is not set
1212 CONFIG_BLK_DEV_INITRD=y
13+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314 CONFIG_KALLSYMS_ALL=y
1415 CONFIG_EMBEDDED=y
1516 CONFIG_PERF_EVENTS=y
arch/arc/configs/nsimosci_hs_defconfig+1−0
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y · 9 unmodified lines
1010 # CONFIG_UTS_NS is not set
1111 # CONFIG_PID_NS is not set
1212 CONFIG_BLK_DEV_INITRD=y
13+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314 CONFIG_KALLSYMS_ALL=y
1415 CONFIG_EMBEDDED=y
1516 CONFIG_PERF_EVENTS=y
arch/arc/configs/nsimosci_hs_smp_defconfig+1−0
@@ -8,6 +8,7 @@ CONFIG_IKCONFIG_PROC=y · 7 unmodified lines
88 # CONFIG_UTS_NS is not set
99 # CONFIG_PID_NS is not set
1010 CONFIG_BLK_DEV_INITRD=y
11+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1112 CONFIG_PERF_EVENTS=y
1213 # CONFIG_COMPAT_BRK is not set
1314 CONFIG_KPROBES=y
arch/arc/configs/tb10x_defconfig+1−0
@@ -14,6 +14,7 @@ CONFIG_INITRAMFS_SOURCE="../tb10x-rootfs.cpio" · 13 unmodified lines
1414 CONFIG_INITRAMFS_ROOT_UID=2100
1515 CONFIG_INITRAMFS_ROOT_GID=501
1616 # CONFIG_RD_GZIP is not set
17+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1718 CONFIG_SYSCTL_SYSCALL=y
1819 CONFIG_KALLSYMS_ALL=y
1920 # CONFIG_AIO is not set
arch/arc/configs/vdk_hs38_defconfig+1−0
@@ -4,6 +4,7 @@ CONFIG_HIGH_RES_TIMERS=y · 3 unmodified lines
44 CONFIG_IKCONFIG=y
55 CONFIG_IKCONFIG_PROC=y
66 CONFIG_BLK_DEV_INITRD=y
7+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
78 CONFIG_EMBEDDED=y
89 CONFIG_PERF_EVENTS=y
910 # CONFIG_VM_EVENT_COUNTERS is not set
arch/arc/configs/vdk_hs38_smp_defconfig+1−0
@@ -4,6 +4,7 @@ CONFIG_HIGH_RES_TIMERS=y · 3 unmodified lines
44 CONFIG_IKCONFIG=y
55 CONFIG_IKCONFIG_PROC=y
66 CONFIG_BLK_DEV_INITRD=y
7+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
78 CONFIG_EMBEDDED=y
89 CONFIG_PERF_EVENTS=y
910 # CONFIG_VM_EVENT_COUNTERS is not set
arch/arm/Makefile+1−1
@@ -17,7 +17,7 @@ KBUILD_LDFLAGS_MODULE += --be8 · 16 unmodified lines
1717 endif
1818
1919 ifeq ($(CONFIG_ARM_MODULE_PLTS),y)
20−KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm/kernel/module.lds
20+KBUILD_LDS_MODULE += $(srctree)/arch/arm/kernel/module.lds
2121 endif
2222
2323 GZFLAGS :=-9
arch/arm/kvm/Makefile+3−2
@@ -8,13 +8,14 @@ ifeq ($(plus_virt),+virt) · 7 unmodified lines
88 plus_virt_def := -DREQUIRES_VIRT=1
99 endif
1010
11+KVM := ../../../virt/kvm
12+
1113 ccflags-y += -I $(srctree)/$(src) -I $(srctree)/virt/kvm/arm/vgic
12−CFLAGS_arm.o := $(plus_virt_def)
14+CFLAGS_$(KVM)/arm/arm.o := $(plus_virt_def)
1315
1416 AFLAGS_init.o := -Wa,-march=armv7-a$(plus_virt)
1517 AFLAGS_interrupts.o := -Wa,-march=armv7-a$(plus_virt)
1618
17−KVM := ../../../virt/kvm
1819 kvm-arm-y = $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o $(KVM)/vfio.o
1920
2021 obj-$(CONFIG_KVM_ARM_HOST) += hyp/
arch/arm64/Kconfig+1−0
@@ -134,6 +134,7 @@ config ARM64 · 133 unmodified lines
134134 select HAVE_ARCH_TRANSPARENT_HUGEPAGE
135135 select HAVE_ARCH_VMAP_STACK
136136 select HAVE_ARM_SMCCC
137+ select HAVE_ASM_MODVERSIONS
137138 select HAVE_EBPF_JIT
138139 select HAVE_C_RECORDMCOUNT
139140 select HAVE_CMPXCHG_DOUBLE
arch/arm64/Makefile+1−1
@@ -108,7 +108,7 @@ endif · 107 unmodified lines
108108 CHECKFLAGS += -D__aarch64__
109109
110110 ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
111−KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds
111+KBUILD_LDS_MODULE += $(srctree)/arch/arm64/kernel/module.lds
112112 endif
113113
114114 # Default value
arch/ia64/Kconfig+1−0
@@ -19,6 +19,7 @@ config IA64 · 18 unmodified lines
1919 select PCI_DOMAINS if PCI
2020 select PCI_MSI
2121 select PCI_SYSCALL if PCI
22+ select HAVE_ASM_MODVERSIONS
2223 select HAVE_UNSTABLE_SCHED_CLOCK
2324 select HAVE_EXIT_THREAD
2425 select HAVE_IDE
arch/ia64/Makefile+1−1
@@ -20,7 +20,7 @@ CHECKFLAGS += -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__ · 19 unmodified lines
2020
2121 OBJCOPYFLAGS := --strip-all
2222 LDFLAGS_vmlinux := -static
23−KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds
23+KBUILD_LDS_MODULE += $(srctree)/arch/ia64/module.lds
2424 KBUILD_AFLAGS_KERNEL := -mconstant-gp
2525 EXTRA :=
2626
arch/m68k/Kconfig+1−0
@@ -12,6 +12,7 @@ config M68K · 11 unmodified lines
1212 select DMA_DIRECT_REMAP if HAS_DMA && MMU && !COLDFIRE
1313 select HAVE_IDE
1414 select HAVE_AOUT if MMU
15+ select HAVE_ASM_MODVERSIONS
1516 select HAVE_DEBUG_BUGVERBOSE
1617 select GENERIC_IRQ_SHOW
1718 select GENERIC_ATOMIC64
arch/m68k/Makefile+1−1
@@ -73,7 +73,7 @@ KBUILD_AFLAGS += -D__uClinux__ · 72 unmodified lines
7373 endif
7474
7575 KBUILD_LDFLAGS := -m m68kelf
76−KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds
76+KBUILD_LDS_MODULE += $(srctree)/arch/m68k/kernel/module.lds
7777
7878 ifdef CONFIG_SUN3
7979 LDFLAGS_vmlinux = -N
arch/mips/Kconfig+1−0
@@ -44,6 +44,7 @@ config MIPS · 43 unmodified lines
4444 select HAVE_ARCH_SECCOMP_FILTER
4545 select HAVE_ARCH_TRACEHOOK
4646 select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES && 64BIT
47+ select HAVE_ASM_MODVERSIONS
4748 select HAVE_EBPF_JIT if (!CPU_MICROMIPS)
4849 select HAVE_CONTEXT_TRACKING
4950 select HAVE_COPY_THREAD_TLS
arch/mips/boot/Makefile+1−1
@@ -160,7 +160,7 @@ targets += vmlinux.lzo.itb · 159 unmodified lines
160160 quiet_cmd_itb-image = ITB $@
161161 cmd_itb-image = \
162162 env PATH="$(objtree)/scripts/dtc:$(PATH)" \
163− $(CONFIG_SHELL) $(MKIMAGE) \
163+ $(BASH) $(MKIMAGE) \
164164 -D "-I dts -O dtb -p 500 \
165165 --include $(objtree)/arch/mips \
166166 --warning no-unit_address_vs_reg" \
arch/parisc/Makefile+1−1
@@ -60,7 +60,7 @@ KBUILD_CFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY=1 \ · 59 unmodified lines
6060 -DFTRACE_PATCHABLE_FUNCTION_SIZE=$(NOP_COUNT)
6161
6262 CC_FLAGS_FTRACE := -fpatchable-function-entry=$(NOP_COUNT),$(shell echo $$(($(NOP_COUNT)-1)))
63−KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/parisc/kernel/module.lds
63+KBUILD_LDS_MODULE += $(srctree)/arch/parisc/kernel/module.lds
6464 endif
6565
6666 OBJCOPY_FLAGS =-O binary -R .note -R .comment -S
arch/powerpc/Kconfig+1−0
@@ -177,6 +177,7 @@ config PPC · 176 unmodified lines
177177 select HAVE_ARCH_NVRAM_OPS
178178 select HAVE_ARCH_SECCOMP_FILTER
179179 select HAVE_ARCH_TRACEHOOK
180+ select HAVE_ASM_MODVERSIONS
180181 select HAVE_C_RECORDMCOUNT
181182 select HAVE_CBPF_JIT if !PPC64
182183 select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13)
arch/powerpc/Makefile+1−1
@@ -65,7 +65,7 @@ UTS_MACHINE := $(subst $(space),,$(machine-y)) · 64 unmodified lines
6565 ifdef CONFIG_PPC32
6666 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
6767 else
68−KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/powerpc/kernel/module.lds
68+KBUILD_LDS_MODULE += $(srctree)/arch/powerpc/kernel/module.lds
6969 ifeq ($(call ld-ifversion, -ge, 225000000, y),y)
7070 # Have the linker provide sfpr if possible.
7171 # There is a corresponding test in arch/powerpc/lib/Makefile
arch/powerpc/Makefile.postlink+1−1
@@ -18,7 +18,7 @@ quiet_cmd_relocs_check = CHKREL $@ · 17 unmodified lines
1818 ifdef CONFIG_PPC_BOOK3S_64
1919 cmd_relocs_check = \
2020 $(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)" "$@"
2222 else
2323 cmd_relocs_check = \
2424 $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@"
arch/powerpc/kernel/prom_init_check.sh+1−1
@@ -33,7 +33,7 @@ OBJ="$2" · 32 unmodified lines
3333
3434 ERROR=0
3535
36−function check_section()
36+check_section()
3737 {
3838 file=$1
3939 section=$2
arch/riscv/Kconfig+1−0
@@ -31,6 +31,7 @@ config RISCV · 30 unmodified lines
3131 select GENERIC_SMP_IDLE_THREAD
3232 select GENERIC_ATOMIC64 if !64BIT
3333 select HAVE_ARCH_AUDITSYSCALL
34+ select HAVE_ASM_MODVERSIONS
3435 select HAVE_MEMBLOCK_NODE_MAP
3536 select HAVE_DMA_CONTIGUOUS
3637 select HAVE_FUTEX_CMPXCHG if FUTEX
arch/riscv/Makefile+1−1
@@ -52,7 +52,7 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y) · 51 unmodified lines
5252 KBUILD_CFLAGS += -mcmodel=medany
5353 endif
5454 ifeq ($(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
5656 endif
5757 ifeq ($(CONFIG_PERF_EVENTS),y)
5858 KBUILD_CFLAGS += -fno-omit-frame-pointer
arch/s390/Kconfig+1−0
@@ -132,6 +132,7 @@ config S390 · 131 unmodified lines
132132 select HAVE_ARCH_TRACEHOOK
133133 select HAVE_ARCH_TRANSPARENT_HUGEPAGE
134134 select HAVE_ARCH_VMAP_STACK
135+ select HAVE_ASM_MODVERSIONS
135136 select HAVE_EBPF_JIT if PACK_STACK && HAVE_MARCH_Z196_FEATURES
136137 select HAVE_CMPXCHG_DOUBLE
137138 select HAVE_CMPXCHG_LOCAL
arch/sparc/Kconfig+1−0
@@ -17,6 +17,7 @@ config SPARC · 16 unmodified lines
1717 select ARCH_MIGHT_HAVE_PC_SERIO
1818 select OF
1919 select OF_PROMTREE
20+ select HAVE_ASM_MODVERSIONS
2021 select HAVE_IDE
2122 select HAVE_OPROFILE
2223 select HAVE_ARCH_KGDB if !SMP || SPARC64
arch/um/Kconfig+1−0
@@ -9,6 +9,7 @@ config UML · 8 unmodified lines
99 select ARCH_NO_PREEMPT
1010 select HAVE_ARCH_AUDITSYSCALL
1111 select HAVE_ARCH_SECCOMP_FILTER
12+ select HAVE_ASM_MODVERSIONS
1213 select HAVE_UID16
1314 select HAVE_FUTEX_CMPXCHG if FUTEX
1415 select HAVE_DEBUG_KMEMLEAK
arch/x86/Kconfig+1−0
@@ -147,6 +147,7 @@ config X86 · 146 unmodified lines
147147 select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD if X86_64
148148 select HAVE_ARCH_VMAP_STACK if X86_64
149149 select HAVE_ARCH_WITHIN_STACK_FRAMES
150+ select HAVE_ASM_MODVERSIONS
150151 select HAVE_CMPXCHG_DOUBLE
151152 select HAVE_CMPXCHG_LOCAL
152153 select HAVE_CONTEXT_TRACKING if X86_64
arch/x86/entry/vdso/Makefile+2−1
@@ -89,6 +89,7 @@ $(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS · 88 unmodified lines
8989 #
9090 CFLAGS_REMOVE_vdso-note.o = -pg
9191 CFLAGS_REMOVE_vclock_gettime.o = -pg
92+CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg
9293 CFLAGS_REMOVE_vgetcpu.o = -pg
9394 CFLAGS_REMOVE_vvar.o = -pg
9495
@@ -128,7 +129,7 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE · 33 unmodified lines
128129 $(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
129130 $(call if_changed,vdso_and_check)
130131
131−CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
132+CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds)
132133 VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
133134
134135 targets += vdso32/vdso32.lds
drivers/gpu/drm/amd/display/dc/calcs/Makefile+3−3
@@ -36,9 +36,9 @@ ifdef CONFIG_CC_IS_CLANG · 35 unmodified lines
3636 calcs_ccflags += -msse2
3737 endif
3838
39−CFLAGS_dcn_calcs.o := $(calcs_ccflags)
40−CFLAGS_dcn_calc_auto.o := $(calcs_ccflags)
41−CFLAGS_dcn_calc_math.o := $(calcs_ccflags) -Wno-tautological-compare
39+CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calcs.o := $(calcs_ccflags)
40+CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calc_auto.o := $(calcs_ccflags)
41+CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calc_math.o := $(calcs_ccflags) -Wno-tautological-compare
4242
4343 BW_CALCS = dce_calcs.o bw_fixed.o custom_float.o
4444
drivers/gpu/drm/amd/display/dc/dcn20/Makefile+2−2
@@ -16,10 +16,10 @@ else ifneq ($(call cc-option, -mstack-alignment=16),) · 15 unmodified lines
1616 cc_stack_align := -mstack-alignment=16
1717 endif
1818
19−CFLAGS_dcn20_resource.o := -mhard-float -msse $(cc_stack_align)
19+CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse $(cc_stack_align)
2020
2121 ifdef CONFIG_CC_IS_CLANG
22−CFLAGS_dcn20_resource.o += -msse2
22+CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -msse2
2323 endif
2424
2525 AMD_DAL_DCN20 = $(addprefix $(AMDDALPATH)/dc/dcn20/,$(DCN20))
drivers/gpu/drm/amd/display/dc/dcn21/Makefile+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
33
44 DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o
55
6−CFLAGS_dcn21_resource.o := -mhard-float -msse -mpreferred-stack-boundary=4
6+CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -msse -mpreferred-stack-boundary=4
77
88 AMD_DAL_DCN21 = $(addprefix $(AMDDALPATH)/dc/dcn21/,$(DCN21))
99
drivers/gpu/drm/amd/display/dc/dml/Makefile+11−14
@@ -36,25 +36,22 @@ ifdef CONFIG_CC_IS_CLANG · 35 unmodified lines
3636 dml_ccflags += -msse2
3737 endif
3838
39−CFLAGS_display_mode_lib.o := $(dml_ccflags)
39+CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o := $(dml_ccflags)
4040
4141 ifdef CONFIG_DRM_AMD_DC_DCN2_0
42−CFLAGS_display_mode_vba.o := $(dml_ccflags)
43−CFLAGS_display_mode_vba_20.o := $(dml_ccflags)
44−CFLAGS_display_rq_dlg_calc_20.o := $(dml_ccflags)
45−CFLAGS_display_mode_vba_20v2.o := $(dml_ccflags)
46−CFLAGS_display_rq_dlg_calc_20v2.o := $(dml_ccflags)
42+CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_vba.o := $(dml_ccflags)
43+CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o := $(dml_ccflags)
44+CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20.o := $(dml_ccflags)
45+CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20v2.o := $(dml_ccflags)
46+CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20v2.o := $(dml_ccflags)
4747 endif
4848 ifdef CONFIG_DRM_AMD_DC_DCN2_1
49−CFLAGS_display_mode_vba_21.o := $(dml_ccflags)
50−CFLAGS_display_rq_dlg_calc_21.o := $(dml_ccflags)
49+CFLAGS_$(AMDDALPATH)/dc/dml/dcn21/display_mode_vba_21.o := $(dml_ccflags)
50+CFLAGS_$(AMDDALPATH)/dc/dml/dcn21/display_rq_dlg_calc_21.o := $(dml_ccflags)
5151 endif
52−ifdef CONFIG_DRM_AMD_DCN3AG
53−CFLAGS_display_mode_vba_3ag.o := $(dml_ccflags)
54−endif
55−CFLAGS_dml1_display_rq_dlg_calc.o := $(dml_ccflags)
56−CFLAGS_display_rq_dlg_helpers.o := $(dml_ccflags)
57−CFLAGS_dml_common_defs.o := $(dml_ccflags)
52+CFLAGS_$(AMDDALPATH)/dc/dml/dml1_display_rq_dlg_calc.o := $(dml_ccflags)
53+CFLAGS_$(AMDDALPATH)/dc/dml/display_rq_dlg_helpers.o := $(dml_ccflags)
54+CFLAGS_$(AMDDALPATH)/dc/dml/dml_common_defs.o := $(dml_ccflags)
5855
5956 DML = display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_calc.o \
6057 dml_common_defs.o
drivers/gpu/drm/amd/display/dc/dsc/Makefile+3−4
@@ -13,10 +13,9 @@ ifdef CONFIG_CC_IS_CLANG · 12 unmodified lines
1313 dsc_ccflags += -msse2
1414 endif
1515
16−CFLAGS_rc_calc.o := $(dsc_ccflags)
17−CFLAGS_rc_calc_dpi.o := $(dsc_ccflags)
18−CFLAGS_codec_main_amd.o := $(dsc_ccflags)
19−CFLAGS_dc_dsc.o := $(dsc_ccflags)
16+CFLAGS_$(AMDDALPATH)/dc/dsc/rc_calc.o := $(dsc_ccflags)
17+CFLAGS_$(AMDDALPATH)/dc/dsc/rc_calc_dpi.o := $(dsc_ccflags)
18+CFLAGS_$(AMDDALPATH)/dc/dsc/dc_dsc.o := $(dsc_ccflags)
2019
2120 DSC = dc_dsc.o rc_calc.o rc_calc_dpi.o
2221
drivers/gpu/drm/i915/Makefile+1−1
@@ -26,7 +26,7 @@ subdir-ccflags-$(CONFIG_DRM_I915_WERROR) += -Werror · 25 unmodified lines
2626
2727 # Fine grained warnings disable
2828 CFLAGS_i915_pci.o = $(call cc-disable-warning, override-init)
29−CFLAGS_intel_fbdev.o = $(call cc-disable-warning, override-init)
29+CFLAGS_display/intel_fbdev.o = $(call cc-disable-warning, override-init)
3030
3131 subdir-ccflags-y += \
3232 $(call as-instr,movntdqa (%eax)$(comma)%xmm0,-DCONFIG_AS_MOVNTDQA)
drivers/net/ethernet/aquantia/atlantic/hw_atl/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0
2−# kbuild requires Makefile in a directory to build individual objects
drivers/net/ethernet/mellanox/mlx5/core/accel/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0-only
2−subdir-ccflags-y += -I$(src)/..
drivers/net/ethernet/mellanox/mlx5/core/diag/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0-only
2−subdir-ccflags-y += -I$(src)/..
drivers/net/ethernet/mellanox/mlx5/core/en/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0-only
2−subdir-ccflags-y += -I$(src)/..
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/Makefile+0−1
@@ -1 +0,0 @@
1−subdir-ccflags-y += -I$(src)/../..
drivers/net/ethernet/mellanox/mlx5/core/en_accel/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0-only
2−subdir-ccflags-y += -I$(src)/..
drivers/net/ethernet/mellanox/mlx5/core/fpga/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0-only
2−subdir-ccflags-y += -I$(src)/..
drivers/net/ethernet/mellanox/mlx5/core/ipoib/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0-only
2−subdir-ccflags-y += -I$(src)/..
drivers/net/ethernet/mellanox/mlx5/core/lib/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0-only
2−subdir-ccflags-y += -I$(src)/..
drivers/net/ethernet/netronome/nfp/bpf/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0
2−# kbuild requires Makefile in a directory to build individual objects
drivers/net/ethernet/netronome/nfp/flower/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0
2−# kbuild requires Makefile in a directory to build individual objects
drivers/net/ethernet/netronome/nfp/nfpcore/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0
2−# kbuild requires Makefile in a directory to build individual objects
drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0
2−# kbuild requires Makefile in a directory to build individual objects
drivers/net/ethernet/netronome/nfp/nic/Makefile+0−2
@@ -1,2 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0
2−# kbuild requires Makefile in a directory to build individual objects
include/linux/compiler_types.h+14−6
@@ -130,10 +130,6 @@ struct ftrace_likely_data { · 129 unmodified lines
130130
131131 /*
132132 * 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.
137133 * Prefer gnu_inline, so that extern inline functions do not emit an
138134 * externally visible function. This makes extern inline behave as per gnu89
139135 * semantics rather than c99. This prevents multiple symbol definition errors
@@ -144,15 +140,27 @@ struct ftrace_likely_data { · 4 unmodified lines
144140 */
145141 #if !defined(CONFIG_OPTIMIZE_INLINING)
146142 #define inline inline __attribute__((__always_inline__)) __gnu_inline \
147− __maybe_unused notrace
143+ __inline_maybe_unused notrace
148144 #else
149145 #define inline inline __gnu_inline \
150− __maybe_unused notrace
146+ __inline_maybe_unused notrace
151147 #endif
152148
153149 #define __inline__ inline
154150 #define __inline inline
155151
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+
156164 /*
157165 * Rather then using noinline to prevent stack consumption, use
158166 * noinline_for_stack instead. For documentation reasons.
include/linux/export.h+16−26
@@ -18,9 +18,6 @@ extern struct module __this_module; · 17 unmodified lines
1818 #define THIS_MODULE ((struct module *)0)
1919 #endif
2020
21−#ifdef CONFIG_MODULES
22−
23−#if defined(__KERNEL__) && !defined(__GENKSYMS__)
2421 #ifdef CONFIG_MODVERSIONS
2522 /* Mark the CRC weak since genksyms apparently decides not to
2623 * generate a checksums for some symbols */
@@ -74,6 +71,12 @@ struct kernel_symbol { · 47 unmodified lines
7471 };
7572 #endif
7673
74+#ifdef __GENKSYMS__
75+
76+#define ___EXPORT_SYMBOL(sym, sec) __GENKSYMS_EXPORT_SYMBOL(sym)
77+
78+#else
79+
7780 /* For every exported symbol, place a struct in the __ksymtab section */
7881 #define ___EXPORT_SYMBOL(sym, sec) \
7982 extern typeof(sym) sym; \
@@ -83,7 +86,9 @@ struct kernel_symbol { · 3 unmodified lines
8386 = #sym; \
8487 __KSYMTAB_ENTRY(sym, sec)
8588
86−#if defined(__DISABLE_EXPORTS)
89+#endif
90+
91+#if !defined(CONFIG_MODULES) || defined(__DISABLE_EXPORTS)
8792
8893 /*
8994 * Allow symbol exports to be disabled completely so that C code may
@@ -117,37 +122,22 @@ struct kernel_symbol { · 27 unmodified lines
117122 #define __cond_export_sym_0(sym, sec) /* nothing */
118123
119124 #else
120−#define __EXPORT_SYMBOL ___EXPORT_SYMBOL
121−#endif
122125
123−#define EXPORT_SYMBOL(sym) \
124− __EXPORT_SYMBOL(sym, "")
126+#define __EXPORT_SYMBOL(sym, sec) ___EXPORT_SYMBOL(sym, sec)
125127
126−#define EXPORT_SYMBOL_GPL(sym) \
127− __EXPORT_SYMBOL(sym, "_gpl")
128−
129−#define EXPORT_SYMBOL_GPL_FUTURE(sym) \
130− __EXPORT_SYMBOL(sym, "_gpl_future")
128+#endif /* CONFIG_MODULES */
131129
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")
132133 #ifdef CONFIG_UNUSED_SYMBOLS
133−#define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
134−#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
134+#define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
135+#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
135136 #else
136137 #define EXPORT_UNUSED_SYMBOL(sym)
137138 #define EXPORT_UNUSED_SYMBOL_GPL(sym)
138139 #endif
139140
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 */
151141 #endif /* !__ASSEMBLY__ */
152142
153143 #endif /* _LINUX_EXPORT_H */
include/linux/vermagic.h+2−0
@@ -9,6 +9,8 @@ · 8 unmodified lines
99 #endif
1010 #ifdef CONFIG_PREEMPT
1111 #define MODULE_VERMAGIC_PREEMPT "preempt "
12+#elif defined(CONFIG_PREEMPT_RT)
13+#define MODULE_VERMAGIC_PREEMPT "preempt_rt "
1214 #else
1315 #define MODULE_VERMAGIC_PREEMPT ""
1416 #endif
init/Kconfig+20−6
@@ -1234,20 +1234,26 @@ choice · 1233 unmodified lines
12341234 default CC_OPTIMIZE_FOR_PERFORMANCE
12351235
12361236 config CC_OPTIMIZE_FOR_PERFORMANCE
1237− bool "Optimize for performance"
1237+ bool "Optimize for performance (-O2)"
12381238 help
12391239 This is the default optimization level for the kernel, building
12401240 with the "-O2" compiler flag for best performance and most
12411241 helpful compile-time warnings.
12421242
1243−config CC_OPTIMIZE_FOR_SIZE
1244− bool "Optimize for size"
1243+config CC_OPTIMIZE_FOR_PERFORMANCE_O3
1244+ bool "Optimize more for performance (-O3)"
1245+ depends on ARC
12451246 imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
12461247 help
1247− Enabling this option will pass "-Os" instead of "-O2" to
1248− your compiler resulting in a smaller kernel.
1248+ Choosing this option will pass "-O3" to your compiler to optimize
1249+ the kernel yet more for performance.
12491250
1250− If unsure, say N.
1251+config 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.
12511257
12521258 endchoice
12531259
@@ -2014,6 +2020,14 @@ config MODVERSIONS · 760 unmodified lines
20142020 make them incompatible with the kernel you are running. If
20152021 unsure, say N.
20162022
2023+config 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+
20172031 config MODULE_REL_CRCS
20182032 bool
20192033 depends on MODVERSIONS
init/Makefile+3−2
@@ -33,5 +33,6 @@ $(obj)/version.o: include/generated/compile.h · 32 unmodified lines
3333 silent_chk_compile.h = :
3434 include/generated/compile.h: FORCE
3535 @$($(quiet)chk_compile.h)
36− $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
37− "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(KBUILD_CFLAGS)"
36+ $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
37+ "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" \
38+ "$(CONFIG_PREEMPT_RT)" "$(CC) $(KBUILD_CFLAGS)"
kernel/Makefile+1−1
@@ -127,7 +127,7 @@ $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE · 126 unmodified lines
127127 $(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz
128128
129129 quiet_cmd_genikh = CHK $(obj)/kheaders_data.tar.xz
130−cmd_genikh = $(CONFIG_SHELL) $(srctree)/kernel/gen_kheaders.sh $@
130+ cmd_genikh = $(BASH) $(srctree)/kernel/gen_kheaders.sh $@
131131 $(obj)/kheaders_data.tar.xz: FORCE
132132 $(call cmd,genikh)
133133
scripts/Kconfig.include+3−0
@@ -35,5 +35,8 @@ ld-option = $(success,$(LD) -v $(1)) · 34 unmodified lines
3535 $(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
3636 $(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found)
3737
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+
3841 # gcc version including patch level
3942 gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))
scripts/Makefile+1−1
@@ -36,4 +36,4 @@ subdir-$(CONFIG_MODVERSIONS) += genksyms · 35 unmodified lines
3636 subdir-$(CONFIG_SECURITY_SELINUX) += selinux
3737
3838 # Let clean descend into subdirs
39−subdir- += basic dtc gdb kconfig mod package
39+subdir- += basic dtc gdb kconfig mod
scripts/Makefile.build+43−30
@@ -52,7 +52,7 @@ ifndef obj · 51 unmodified lines
5252 $(warning kbuild: Makefile.build is included improperly)
5353 endif
5454
55−ifeq ($(MAKECMDGOALS)$(need-modorder),)
55+ifeq ($(need-modorder),)
5656 ifneq ($(obj-m),)
5757 $(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.)
5858 $(warning You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.)
@@ -76,11 +76,6 @@ endif · 17 unmodified lines
7676
7777 mod-targets := $(patsubst %.o, %.mod, $(obj-m))
7878
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−
8479 # Linus' kernel sanity checking tool
8580 ifeq ($(KBUILD_CHECKSRC),1)
8681 quiet_cmd_checksrc = CHECK $<
@@ -90,23 +85,13 @@ else ifeq ($(KBUILD_CHECKSRC),2) · 3 unmodified lines
9085 cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
9186 endif
9287
93−ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
88+ifneq ($(KBUILD_EXTRA_WARN),)
9489 cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $<
9590 endif
9691
9792 # Compile C sources (.c)
9893 # ---------------------------------------------------------------------------
9994
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−
104−modkern_cflags = \
105− $(if $(part-of-module), \
106− $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
107− $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
108−quiet_modtag = $(if $(part-of-module),[M], )
109−
11095 quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
11196 cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
11297
@@ -310,11 +295,6 @@ $(obj)/%.h.s: $(src)/%.h FORCE · 197 unmodified lines
310295 # Compile assembler sources (.S)
311296 # ---------------------------------------------------------------------------
312297
313−modkern_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−
318298 # .S file exports must have their C prototypes defined in asm/asm-prototypes.h
319299 # or a file that it includes, in order to get versioned symbols. We build a
320300 # dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from
@@ -356,11 +336,7 @@ $(obj)/%.s: $(src)/%.S FORCE · 35 unmodified lines
356336 quiet_cmd_as_o_S = AS $(quiet_modtag) $@
357337 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
358338
359−ifdef CONFIG_MODVERSIONS
360−
361−ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h)
362−
363−ifneq ($(ASM_PROTOTYPES),)
339+ifdef CONFIG_ASM_MODVERSIONS
364340
365341 # versioning matches the C process described above, with difference that
366342 # we parse asm-prototypes.h C header to get function definitions.
@@ -376,7 +352,6 @@ cmd_modversions_S = \ · 9 unmodified lines
376352 rm -f $(@D)/.tmp_$(@F:.o=.ver); \
377353 fi
378354 endif
379−endif
380355
381356 $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
382357 $(call if_changed_rule,as_o_S)
@@ -395,9 +370,9 @@ $(obj)/%.lds: $(src)/%.lds.S FORCE · 12 unmodified lines
395370
396371 # ASN.1 grammar
397372 # ---------------------------------------------------------------------------
398−quiet_cmd_asn1_compiler = ASN.1 $@
373+quiet_cmd_asn1_compiler = ASN.1 $(basename $@).[ch]
399374 cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \
400− $(subst .h,.c,$@) $(subst .c,.h,$@)
375+ $(basename $@).c $(basename $@).h
401376
402377 $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
403378 $(call cmd,asn1_compiler)
@@ -489,12 +464,50 @@ targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \ · 85 unmodified lines
489464 $(call intermediate_targets, .lex.o, .lex.c) \
490465 $(call intermediate_targets, .tab.o, .tab.c .tab.h)
491466
467+# Build
468+# ---------------------------------------------------------------------------
469+
470+ifdef single-build
471+
472+curdir-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.
477+unknown-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)
483+ifneq ($(unknown-single),)
484+ $(Q)$(MAKE) -f /dev/null $(unknown-single)
485+endif
486+ @:
487+
488+ifeq ($(curdir-single),)
489+# Nothing to do in this directory. Do not include any .*.cmd file for speed-up
490+targets :=
491+else
492+targets += $(curdir-single)
493+endif
494+
495+else
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+
502+endif
503+
492504 # Descending
493505 # ---------------------------------------------------------------------------
494506
495507 PHONY += $(subdir-ym)
496508 $(subdir-ym):
497509 $(Q)$(MAKE) $(build)=$@ \
510+ $(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \
498511 need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),1) \
499512 need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1))
500513
scripts/Makefile.clean+5−26
@@ -17,17 +17,8 @@ include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-di · 16 unmodified lines
1717 # Figure out what we need to build from the various variables
1818 # ==========================================================================
1919
20−__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
21−subdir-y += $(__subdir-y)
22−__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
23−subdir-m += $(__subdir-m)
24−__subdir- := $(patsubst %/,%,$(filter %/, $(obj-)))
25−subdir- += $(__subdir-)
26−
27−# Subdirectories we need to descend into
28−
29−subdir-ym := $(sort $(subdir-y) $(subdir-m))
30−subdir-ymn := $(sort $(subdir-ym) $(subdir-))
20+subdir-ymn := $(sort $(subdir-y) $(subdir-m) $(subdir-) \
21+ $(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m) $(obj-))))
3122
3223 # Add subdir path
3324
@@ -52,26 +43,14 @@ __clean-files := $(wildcard \ · 18 unmodified lines
5243 $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \
5344 $(filter $(objtree)/%, $(__clean-files)))
5445
55−# same as clean-files
56−
57−__clean-dirs := $(wildcard \
58− $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(clean-dirs))) \
59− $(filter $(objtree)/%, $(clean-dirs)))
60−
6146 # ==========================================================================
6247
63−quiet_cmd_clean = CLEAN $(obj)
64− cmd_clean = rm -f $(__clean-files)
65−quiet_cmd_cleandir = CLEAN $(__clean-dirs)
66− cmd_cleandir = rm -rf $(__clean-dirs)
67−
48+quiet_cmd_clean = CLEAN $(obj)
49+ cmd_clean = rm -rf $(__clean-files)
6850
6951 __clean: $(subdir-ymn)
7052 ifneq ($(strip $(__clean-files)),)
71− +$(call cmd,clean)
72−endif
73−ifneq ($(strip $(__clean-dirs)),)
74− +$(call cmd,cleandir)
53+ $(call cmd,clean)
7554 endif
7655 @:
7756
scripts/Makefile.extrawarn+69−52
@@ -1,74 +1,91 @@
11 # SPDX-License-Identifier: GPL-2.0
22 # ==========================================================================
3−#
43 # make W=... settings
54 #
6−# W=1 - warnings that may be relevant and does not occur too often
7−# W=2 - warnings that occur quite often but may still be relevant
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
5+# There are three warning groups enabled by W=1, W=2, W=3.
6+# They are independent, and can be combined like W=12 or W=123.
127 # ==========================================================================
138
149 KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
1510
11+# backward compatibility
12+KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
13+
1614 ifeq ("$(origin W)", "command line")
17− export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
15+ KBUILD_EXTRA_WARN := $(W)
1816 endif
1917
20−ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
21−warning- := $(empty)
22−
23−warning-1 := -Wextra -Wunused -Wno-unused-parameter
24−warning-1 += -Wmissing-declarations
25−warning-1 += -Wmissing-format-attribute
26−warning-1 += -Wmissing-prototypes
27−warning-1 += -Wold-style-definition
28−warning-1 += -Wmissing-include-dirs
29−warning-1 += $(call cc-option, -Wunused-but-set-variable)
30−warning-1 += $(call cc-option, -Wunused-const-variable)
31−warning-1 += $(call cc-option, -Wpacked-not-aligned)
32−warning-1 += $(call cc-option, -Wstringop-truncation)
18+export KBUILD_EXTRA_WARN
19+
20+#
21+# W=1 - warnings which may be relevant and do not occur too often
22+#
23+ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
24+
25+KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
26+KBUILD_CFLAGS += -Wmissing-declarations
27+KBUILD_CFLAGS += -Wmissing-format-attribute
28+KBUILD_CFLAGS += -Wmissing-prototypes
29+KBUILD_CFLAGS += -Wold-style-definition
30+KBUILD_CFLAGS += -Wmissing-include-dirs
31+KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
32+KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
33+KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
34+KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
3335 # The following turn off the warnings enabled by -Wextra
34−warning-1 += -Wno-missing-field-initializers
35−warning-1 += -Wno-sign-compare
36−
37−warning-2 += -Wcast-align
38−warning-2 += -Wdisabled-optimization
39−warning-2 += -Wnested-externs
40−warning-2 += -Wshadow
41−warning-2 += $(call cc-option, -Wlogical-op)
42−warning-2 += -Wmissing-field-initializers
43−warning-2 += -Wsign-compare
44−warning-2 += $(call cc-option, -Wmaybe-uninitialized)
45−warning-2 += $(call cc-option, -Wunused-macros)
46−
47−warning-3 := -Wbad-function-cast
48−warning-3 += -Wcast-qual
49−warning-3 += -Wconversion
50−warning-3 += -Wpacked
51−warning-3 += -Wpadded
52−warning-3 += -Wpointer-arith
53−warning-3 += -Wredundant-decls
54−warning-3 += -Wswitch-default
55−warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
56−
57−warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
58−warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
59−warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
60−
61−ifeq ("$(strip $(warning))","")
62− $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
63−endif
36+KBUILD_CFLAGS += -Wno-missing-field-initializers
37+KBUILD_CFLAGS += -Wno-sign-compare
38+
39+KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
6440
65−KBUILD_CFLAGS += $(warning)
6641 else
6742
43+# Some diagnostics enabled by default are noisy.
44+# Suppress them by using -Wno... except for W=1.
45+
6846 ifdef CONFIG_CC_IS_CLANG
6947 KBUILD_CFLAGS += -Wno-initializer-overrides
7048 KBUILD_CFLAGS += -Wno-format
7149 KBUILD_CFLAGS += -Wno-sign-compare
7250 KBUILD_CFLAGS += -Wno-format-zero-length
7351 endif
52+
53+endif
54+
55+#
56+# W=2 - warnings which occur quite often but may still be relevant
57+#
58+ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
59+
60+KBUILD_CFLAGS += -Wcast-align
61+KBUILD_CFLAGS += -Wdisabled-optimization
62+KBUILD_CFLAGS += -Wnested-externs
63+KBUILD_CFLAGS += -Wshadow
64+KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
65+KBUILD_CFLAGS += -Wmissing-field-initializers
66+KBUILD_CFLAGS += -Wsign-compare
67+KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
68+KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
69+
70+KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2
71+
72+endif
73+
74+#
75+# W=3 - more obscure warnings, can most likely be ignored
76+#
77+ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),)
78+
79+KBUILD_CFLAGS += -Wbad-function-cast
80+KBUILD_CFLAGS += -Wcast-qual
81+KBUILD_CFLAGS += -Wconversion
82+KBUILD_CFLAGS += -Wpacked
83+KBUILD_CFLAGS += -Wpadded
84+KBUILD_CFLAGS += -Wpointer-arith
85+KBUILD_CFLAGS += -Wredundant-decls
86+KBUILD_CFLAGS += -Wswitch-default
87+KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
88+
89+KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3
90+
7491 endif
scripts/Makefile.host+28−11
@@ -1,4 +1,21 @@
11 # SPDX-License-Identifier: GPL-2.0
2+
3+# LEX
4+# ---------------------------------------------------------------------------
5+quiet_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+# ---------------------------------------------------------------------------
13+quiet_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+
219 # ==========================================================================
320 # Building binaries on the host system
421 # Binaries are used during the compilation of the kernel, for example
@@ -63,9 +80,9 @@ host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs)) · 58 unmodified lines
6380 # Handle options to gcc. Support building with separate output directory
6481
6582 _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
66− $(HOSTCFLAGS_$(basetarget).o)
83+ $(HOSTCFLAGS_$(target-stem).o)
6784 _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
68− $(HOSTCXXFLAGS_$(basetarget).o)
85+ $(HOSTCXXFLAGS_$(target-stem).o)
6986
7087 # $(objtree)/$(obj) for including generated headers from checkin source files
7188 ifeq ($(KBUILD_EXTMOD),)
@@ -85,7 +102,7 @@ hostcxx_flags = -Wp,-MD,$(depfile) $(_hostcxx_flags) · 13 unmodified lines
85102 # host-csingle -> Executable
86103 quiet_cmd_host-csingle = HOSTCC $@
87104 cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(KBUILD_HOSTLDFLAGS) -o $@ $< \
88− $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
105+ $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
89106 $(host-csingle): $(obj)/%: $(src)/%.c FORCE
90107 $(call if_changed_dep,host-csingle)
91108
@@ -93,8 +110,8 @@ $(host-csingle): $(obj)/%: $(src)/%.c FORCE · 1 unmodified line
93110 # host-cmulti -> executable
94111 quiet_cmd_host-cmulti = HOSTLD $@
95112 cmd_host-cmulti = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ \
96− $(addprefix $(obj)/,$($(@F)-objs)) \
97− $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
113+ $(addprefix $(obj)/, $($(target-stem)-objs)) \
114+ $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
98115 $(host-cmulti): FORCE
99116 $(call if_changed,host-cmulti)
100117 $(call multi_depend, $(host-cmulti), , -objs)
@@ -111,8 +128,8 @@ $(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE · 10 unmodified lines
111128 quiet_cmd_host-cxxmulti = HOSTLD $@
112129 cmd_host-cxxmulti = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -o $@ \
113130 $(foreach o,objs cxxobjs,\
114− $(addprefix $(obj)/,$($(@F)-$(o)))) \
115− $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
131+ $(addprefix $(obj)/, $($(target-stem)-$(o)))) \
132+ $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
116133 $(host-cxxmulti): FORCE
117134 $(call if_changed,host-cxxmulti)
118135 $(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs)
@@ -144,8 +161,8 @@ $(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE · 25 unmodified lines
144161 # *.o -> .so shared library (host-cshlib)
145162 quiet_cmd_host-cshlib = HOSTLLD -shared $@
146163 cmd_host-cshlib = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \
147− $(addprefix $(obj)/,$($(@F:.so=-objs))) \
148− $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
164+ $(addprefix $(obj)/, $($(target-stem)-objs)) \
165+ $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem).so)
149166 $(host-cshlib): FORCE
150167 $(call if_changed,host-cshlib)
151168 $(call multi_depend, $(host-cshlib), .so, -objs)
@@ -154,8 +171,8 @@ $(call multi_depend, $(host-cshlib), .so, -objs) · 2 unmodified lines
154171 # *.o -> .so shared library (host-cxxshlib)
155172 quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
156173 cmd_host-cxxshlib = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \
157− $(addprefix $(obj)/,$($(@F:.so=-objs))) \
158− $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
174+ $(addprefix $(obj)/, $($(target-stem)-objs)) \
175+ $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem).so)
159176 $(host-cxxshlib): FORCE
160177 $(call if_changed,host-cxxshlib)
161178 $(call multi_depend, $(host-cxxshlib), .so, -objs)
scripts/Makefile.lib+28−35
@@ -41,9 +41,9 @@ obj-m := $(filter-out %/, $(obj-m)) · 40 unmodified lines
4141 # Subdirectories we need to descend into
4242 subdir-ym := $(sort $(subdir-y) $(subdir-m))
4343
44−# if $(foo-objs), $(foo-y), or $(foo-m) exists, foo.o is a composite object
45−multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
46−multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m))))
44+# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
45+multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m))))
46+multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m))))
4747 multi-used := $(multi-used-y) $(multi-used-m)
4848
4949 # $(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)) · 2 unmodified lines
5252
5353 # Replace multi-part objects by their individual parts,
5454 # including built-in.a from subdirectories
55−real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
56−real-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)))
55+real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
56+real-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)))
5757
5858 # DTB
5959 # 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),\ · 41 unmodified lines
101101
102102 modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
103103
104+# target with $(obj)/ and its suffix stripped
105+target-stem = $(basename $(patsubst $(obj)/%,%,$@))
106+
104107 # These flags are needed for modversions and compiling, so we define them here
105108 # $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
106109 # end up in (or would, if it gets compiled in)
@@ -109,12 +112,12 @@ basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) · 2 unmodified lines
109112 modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname))
110113
111114 orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
112− $(ccflags-y) $(CFLAGS_$(basetarget).o)
113−_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
115+ $(ccflags-y) $(CFLAGS_$(target-stem).o)
116+_c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), $(orig_c_flags))
114117 orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \
115− $(asflags-y) $(AFLAGS_$(basetarget).o)
116−_a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags))
117−_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
118+ $(asflags-y) $(AFLAGS_$(target-stem).o)
119+_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), $(orig_a_flags))
120+_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds)
118121
119122 #
120123 # 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) · 38 unmodified lines
159162 endif
160163 endif
161164
165+part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y)
166+quiet_modtag = $(if $(part-of-module),[M], )
167+
168+modkern_cflags = \
169+ $(if $(part-of-module), \
170+ $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
171+ $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
172+
173+modkern_aflags = $(if $(part-of-module), \
174+ $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \
175+ $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))
176+
162177 c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
163178 -include $(srctree)/include/linux/compiler_types.h \
164179 $(_c_flags) $(modkern_cflags) \
@@ -187,28 +202,6 @@ $(foreach m, $(notdir $1), \ · 22 unmodified lines
187202 $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
188203 endef
189204
190−# LEX
191−# ---------------------------------------------------------------------------
192−quiet_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−# ---------------------------------------------------------------------------
200−quiet_cmd_bison = YACC $@
201− cmd_bison = $(YACC) -o$@ -t -l $<
202−
203−$(obj)/%.tab.c: $(src)/%.y FORCE
204− $(call if_changed,bison)
205−
206−quiet_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−
212205 # Shipped files
213206 # ===========================================================================
214207
@@ -258,7 +251,7 @@ quiet_cmd_gzip = GZIP $@ · 43 unmodified lines
258251 DTC ?= $(objtree)/scripts/dtc/dtc
259252
260253 # Disable noisy checks by default
261−ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
254+ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
262255 DTC_FLAGS += -Wno-unit_address_vs_reg \
263256 -Wno-unit_address_format \
264257 -Wno-avoid_unnecessary_addr_size \
@@ -269,7 +262,7 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \ · 4 unmodified lines
269262 -Wno-pci_device_reg
270263 endif
271264
272−ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
265+ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),)
273266 DTC_FLAGS += -Wnode_name_chars_strict \
274267 -Wproperty_name_chars_strict
275268 endif
@@ -374,7 +367,7 @@ UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR) · 98 unmodified lines
374367 UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
375368
376369 quiet_cmd_uimage = UIMAGE $@
377− cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
370+ cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
378371 -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
379372 -T $(UIMAGE_TYPE) \
380373 -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
scripts/Makefile.modfinal+60−0
@@ -0,0 +1,60 @@
1+# SPDX-License-Identifier: GPL-2.0-only
2+# ===========================================================================
3+# Module final link
4+# ===========================================================================
5+
6+PHONY := __modfinal
7+__modfinal:
8+
9+include $(srctree)/scripts/Kbuild.include
10+
11+# for c_flags
12+include $(srctree)/scripts/Makefile.lib
13+
14+# find all modules listed in modules.order
15+modules := $(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
21+modname = $(notdir $(@:.mod.o=))
22+part-of-module = y
23+
24+quiet_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+
30+ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
31+
32+quiet_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+
43+targets += $(modules) $(modules:.ko=.mod.o)
44+
45+# Add FORCE to the prequisites of a target to force it to be always rebuilt.
46+# ---------------------------------------------------------------------------
47+
48+PHONY += FORCE
49+FORCE:
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+
56+existing-targets := $(wildcard $(sort $(targets)))
57+
58+-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
59+
60+.PHONY: $(PHONY)
scripts/Makefile.modpost+12−68
@@ -15,15 +15,13 @@ · 14 unmodified lines
1515 # 2) modpost is then used to
1616 # 3) create one <module>.mod.c file pr. module
1717 # 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
2018
2119 # Step 3 is used to place certain information in the module's ELF
2220 # section, including information such as:
2321 # Version magic (see include/linux/vermagic.h for full details)
2422 # - Kernel release
2523 # - SMP is CONFIG_SMP
26−# - PREEMPT is CONFIG_PREEMPT
24+# - PREEMPT is CONFIG_PREEMPT[_RT]
2725 # - GCC Version
2826 # Module info
2927 # - Module version (MODULE_VERSION)
@@ -60,13 +58,10 @@ MODPOST = scripts/mod/modpost \ · 30 unmodified lines
6058
6159 ifdef MODPOST_VMLINUX
6260
63−__modpost: vmlinux.o
61+quiet_cmd_modpost = MODPOST vmlinux.o
62+ cmd_modpost = $(MODPOST) vmlinux.o
6463
65−quiet_cmd_modpost = MODPOST $@
66− cmd_modpost = $(MODPOST) $@
67−
68−PHONY += vmlinux.o
69−vmlinux.o:
64+__modpost:
7065 $(call cmd,modpost)
7166
7267 else
@@ -83,73 +78,22 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ · 10 unmodified lines
8378 $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
8479 endif
8580
86−include scripts/Makefile.lib
81+MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux)
8782
8883 # find all modules listed in modules.order
8984 modules := $(sort $(shell cat $(MODORDER)))
9085
91−# Stop after building .o files if NOFINAL is set. Makes compile tests quicker
92−__modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
93− @:
94−
95−MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux)
96−
97−# We can go over command line length here, so be careful.
86+# Read out modules.order instead of expanding $(modules) to pass in modpost.
87+# Otherwise, allmodconfig would fail with "Argument list too long".
9888 quiet_cmd_modpost = MODPOST $(words $(modules)) modules
9989 cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST)
10090
101−PHONY += modules-modpost
102−modules-modpost:
91+__modpost:
92+ @$(kecho) ' Building modules, stage 2.'
10393 $(call cmd,modpost)
104−
105−# Declare generated files as targets for modpost
106−$(modules:.ko=.mod.c): modules-modpost
107−
108−# Step 5), compile all *.mod.c files
109−
110−# modname is set to make c_flags define KBUILD_MODNAME
111−modname = $(notdir $(@:.mod.o=))
112−
113−quiet_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−
120−targets += $(modules:.ko=.mod.o)
121−
122−ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
123−
124−# Step 6), final link of the modules with optional arch pass after final link
125−quiet_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−
135−targets += $(modules)
136−
137−
138−# Add FORCE to the prequisites of a target to force it to be always rebuilt.
139−# ---------------------------------------------------------------------------
140−
141−PHONY += FORCE
142−
143−FORCE:
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−
150−existing-targets := $(wildcard $(sort $(targets)))
151−
152−-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
94+ifneq ($(KBUILD_MODPOST_NOFINAL),1)
95+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
96+endif
15397
15498 endif
15599
scripts/Makefile.packagerenamed from scripts/package/Makefile+24−19
@@ -1,6 +1,7 @@
11 # SPDX-License-Identifier: GPL-2.0-only
22 # Makefile for the different targets used to generate full packages of a kernel
3−# It uses the generic clean infrastructure of kbuild
3+
4+include $(srctree)/scripts/Kbuild.include
45
56 # RPM target
67 # ---------------------------------------------------------------------------
@@ -50,7 +51,8 @@ rm -f $(objtree)/.scmversion · 43 unmodified lines
5051
5152 # rpm-pkg
5253 # ---------------------------------------------------------------------------
53−rpm-pkg: FORCE
54+PHONY += rpm-pkg
55+rpm-pkg:
5456 $(MAKE) clean
5557 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
5658 $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
@@ -59,15 +61,15 @@ rpm-pkg: FORCE · 2 unmodified lines
5961
6062 # binrpm-pkg
6163 # ---------------------------------------------------------------------------
62−binrpm-pkg: FORCE
64+PHONY += binrpm-pkg
65+binrpm-pkg:
6366 $(MAKE) -f $(srctree)/Makefile
6467 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
6568 +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
6669 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
6770
68−clean-files += $(objtree)/*.spec
69−
70−deb-pkg: FORCE
71+PHONY += deb-pkg
72+deb-pkg:
7173 $(MAKE) clean
7274 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
7375 $(call cmd,src_tar,$(KDEB_SOURCENAME))
@@ -75,18 +77,19 @@ deb-pkg: FORCE · 1 unmodified line
7577 mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
7678 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc
7779
78−bindeb-pkg: FORCE
80+PHONY += bindeb-pkg
81+bindeb-pkg:
7982 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
8083 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
8184
82−intdeb-pkg: FORCE
85+PHONY += intdeb-pkg
86+intdeb-pkg:
8387 +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
8488
85−clean-dirs += $(objtree)/debian/
86−
8789 # snap-pkg
8890 # ---------------------------------------------------------------------------
89−snap-pkg: FORCE
91+PHONY += snap-pkg
92+snap-pkg:
9093 rm -rf $(objtree)/snap
9194 mkdir $(objtree)/snap
9295 $(MAKE) clean
@@ -98,17 +101,14 @@ snap-pkg: FORCE · 5 unmodified lines
98101 cd $(objtree)/snap && \
99102 snapcraft --target-arch=$(UTS_MACHINE)
100103
101−clean-dirs += $(objtree)/snap/
102−
103104 # tarball targets
104105 # ---------------------------------------------------------------------------
105−tar%pkg: FORCE
106+tar-pkgs := tar-pkg targz-pkg tarbz2-pkg tarxz-pkg
107+PHONY += $(tar-pkgs)
108+$(tar-pkgs):
106109 $(MAKE) -f $(srctree)/Makefile
107110 +$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
108111
109−clean-dirs += $(objtree)/tar-install/
110−
111−
112112 # perf-pkg - generate a source tarball with perf source
113113 # ---------------------------------------------------------------------------
114114
@@ -133,12 +133,15 @@ $(if $(findstring xz,$@),xz, \ · 18 unmodified lines
133133 $(error unknown target $@)))) \
134134 -f -9 $(perf-tar).tar)
135135
136−perf-%pkg: FORCE
136+perf-tar-pkgs := perf-tar-src-pkg perf-targz-src-pkg perf-tarbz2-src-pkg perf-tarxz-src-pkg
137+PHONY += $(perf-tar-pkgs)
138+$(perf-tar-pkgs):
137139 $(call cmd,perf_tar)
138140
139141 # Help text displayed when executing 'make help'
140142 # ---------------------------------------------------------------------------
141−help: FORCE
143+PHONY += help
144+help:
142145 @echo ' rpm-pkg - Build both source and binary RPM kernel packages'
143146 @echo ' binrpm-pkg - Build only the binary kernel RPM package'
144147 @echo ' deb-pkg - Build both source and binary deb kernel packages'
@@ -152,3 +155,5 @@ help: FORCE · 7 unmodified lines
152155 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
153156 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
154157 @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'
158+
159+.PHONY: $(PHONY)
scripts/basic/Makefile+2−12
@@ -1,16 +1,6 @@
11 # SPDX-License-Identifier: GPL-2.0-only
2−###
3−# This Makefile lists the most basic programs used during the 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
2+#
3+# fixdep: used to generate dependency information during build process
114
125 hostprogs-y := fixdep
136 always := $(hostprogs-y)
14−
15−# fixdep is needed to compile other host programs
16−$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
scripts/genksyms/Makefile+2−9
@@ -12,22 +12,15 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o · 11 unmodified lines
1212 #
1313 # Just in case, run "$(YACC) --version" without suppressing stderr
1414 # so that 'bison: not found' will be displayed if it is missing.
15−ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
15+ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
1616
1717 quiet_cmd_bison_no_warn = $(quiet_cmd_bison)
1818 cmd_bison_no_warn = $(YACC) --version >/dev/null; \
1919 $(cmd_bison) 2>/dev/null
2020
21−$(obj)/parse.tab.c: $(src)/parse.y FORCE
21+$(obj)/pars%.tab.c $(obj)/pars%.tab.h: $(src)/pars%.y FORCE
2222 $(call if_changed,bison_no_warn)
2323
24−quiet_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−
3124 endif
3225
3326 # -I needed for generated C source (shipped source)
scripts/genksyms/keywords.c+1−5
@@ -3,11 +3,7 @@ static struct resword { · 2 unmodified lines
33 const char *name;
44 int token;
55 } keywords[] = {
6− { "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 },
6+ { "__GENKSYMS_EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW },
117 { "__asm", ASM_KEYW },
128 { "__asm__", ASM_KEYW },
139 { "__attribute", ATTRIBUTE_KEYW },
scripts/genksyms/lex.l+10−22
@@ -1,25 +1,13 @@
1−/* Lexical analysis for genksyms.
2− Copyright 1996, 1997 Linux International.
3−
4− New implementation contributed by Richard Henderson <rth@tamu.edu>
5− Based on original work by Bjorn Ekwall <bj0rn@blox.se>
6−
7− Taken from Linux modutils 2.4.22.
8−
9− This program is free software; you can redistribute it and/or modify it
10− under the terms of the GNU General Public License as published by the
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−
1+/* SPDX-License-Identifier: GPL-2.0-or-later */
2+/*
3+ * Lexical analysis for genksyms.
4+ * Copyright 1996, 1997 Linux International.
5+ *
6+ * New implementation contributed by Richard Henderson <rth@tamu.edu>
7+ * Based on original work by Bjorn Ekwall <bj0rn@blox.se>
8+ *
9+ * Taken from Linux modutils 2.4.22.
10+ */
2311
2412 %{
2513
scripts/genksyms/parse.y+10−22
@@ -1,25 +1,13 @@
1−/* C global declaration parser for genksyms.
2− Copyright 1996, 1997 Linux International.
3−
4− New implementation contributed by Richard Henderson <rth@tamu.edu>
5− Based on original work by Bjorn Ekwall <bj0rn@blox.se>
6−
7− This file is part of the Linux modutils.
8−
9− This program is free software; you can redistribute it and/or modify it
10− under the terms of the GNU General Public License as published by the
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−
1+/* SPDX-License-Identifier: GPL-2.0-or-later */
2+/*
3+ * C global declaration parser for genksyms.
4+ * Copyright 1996, 1997 Linux International.
5+ *
6+ * New implementation contributed by Richard Henderson <rth@tamu.edu>
7+ * Based on original work by Bjorn Ekwall <bj0rn@blox.se>
8+ *
9+ * This file is part of the Linux modutils.
10+ */
2311
2412 %{
2513
scripts/headers_install.sh+72−0
@@ -41,5 +41,77 @@ sed -E -e ' · 40 unmodified lines
4141 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
4242 [ $? -gt 1 ] && exit 1
4343
44+# Remove /* ... */ style comments, and find CONFIG_ references in code
45+configs=$(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.
72+config_leak_ignores="
73+arch/alpha/include/uapi/asm/setup.h:CONFIG_ALPHA_LEGACY_START_ADDRESS
74+arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K
75+arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K
76+arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
77+arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
78+arch/hexagon/include/uapi/asm/ptrace.h:CONFIG_HEXAGON_ARCH_VERSION
79+arch/hexagon/include/uapi/asm/user.h:CONFIG_HEXAGON_ARCH_VERSION
80+arch/ia64/include/uapi/asm/cmpxchg.h:CONFIG_IA64_DEBUG_CMPXCHG
81+arch/m68k/include/uapi/asm/ptrace.h:CONFIG_COLDFIRE
82+arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
83+arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
84+arch/sh/include/uapi/asm/ptrace.h:CONFIG_CPU_SH5
85+arch/sh/include/uapi/asm/sigcontext.h:CONFIG_CPU_SH5
86+arch/sh/include/uapi/asm/stat.h:CONFIG_CPU_SH5
87+arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
88+arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64
89+arch/x86/include/uapi/asm/mman.h:CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
90+include/uapi/asm-generic/fcntl.h:CONFIG_64BIT
91+include/uapi/linux/atmdev.h:CONFIG_COMPAT
92+include/uapi/linux/elfcore.h:CONFIG_BINFMT_ELF_FDPIC
93+include/uapi/linux/eventpoll.h:CONFIG_PM_SLEEP
94+include/uapi/linux/hw_breakpoint.h:CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
95+include/uapi/linux/pktcdvd.h:CONFIG_CDROM_PKTCDVD_WCACHE
96+include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS
97+"
98+
99+for c in $configs
100+do
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
114+done
115+
44116 rm -f $TMPFILE
45117 trap - EXIT
scripts/kconfig/Makefile+5−5
@@ -114,7 +114,7 @@ testconfig: $(obj)/conf · 113 unmodified lines
114114 $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
115115 -o cache_dir=$(abspath $(obj)/tests/.cache) \
116116 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
117−clean-dirs += tests/.cache
117+clean-files += tests/.cache
118118
119119 # Help text used by make help
120120 help:
@@ -166,15 +166,15 @@ $(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg · 45 unmodified lines
166166
167167 # mconf: Used for the menuconfig target based on lxdialog
168168 hostprogs-y += mconf
169−lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
170−mconf-objs := mconf.o $(addprefix lxdialog/, $(lxdialog)) $(common-objs)
169+lxdialog := $(addprefix lxdialog/, \
170+ checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
171+mconf-objs := mconf.o $(lxdialog) $(common-objs)
171172
172173 HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
173174 $(foreach f, mconf.o $(lxdialog), \
174175 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
175176
176−$(obj)/mconf.o: $(obj)/mconf-cfg
177−$(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/mconf-cfg
177+$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
178178
179179 # qconf: Used for the xconfig target based on Qt
180180 hostprogs-y += qconf
scripts/kconfig/merge_config.sh+6−6
@@ -13,12 +13,12 @@ · 12 unmodified lines
1313 # Copyright (c) 2009-2010 Wind River Systems, Inc.
1414 # Copyright 2011 Linaro
1515
16+set -e
17+
1618 clean_up() {
1719 rm -f $TMP_FILE
1820 rm -f $MERGE_FILE
19− exit
2021 }
21−trap clean_up HUP INT TERM
2222
2323 usage() {
2424 echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
@@ -110,6 +110,9 @@ TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) · 85 unmodified lines
110110 MERGE_FILE=$(mktemp ./.merge_tmp.config.XXXXXXXXXX)
111111
112112 echo "Using $INITFILE as base"
113+
114+trap clean_up EXIT
115+
113116 cat $INITFILE > $TMP_FILE
114117
115118 # Merge files, printing warnings on overridden values
@@ -155,7 +158,6 @@ if [ "$RUNMAKE" = "false" ]; then · 39 unmodified lines
155158 echo "#"
156159 echo "# merged configuration written to $KCONFIG_CONFIG (needs make)"
157160 echo "#"
158− clean_up
159161 exit
160162 fi
161163
@@ -177,7 +179,7 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET · 15 unmodified lines
177179 for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
178180
179181 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)
181183 if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then
182184 echo "Value requested for $CFG not in final .config"
183185 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 · 1 unmodified line
185187 echo ""
186188 fi
187189 done
188−
189−clean_up
scripts/link-vmlinux.sh+21−19
@@ -64,6 +64,8 @@ vmlinux_link() · 63 unmodified lines
6464 local output=${1}
6565 local objects
6666
67+ info LD ${output}
68+
6769 # skip output file argument
6870 shift
6971
@@ -157,6 +159,18 @@ kallsyms() · 87 unmodified lines
157159 ${CC} ${aflags} -c -o ${2} ${afile}
158160 }
159161
162+# Perform one step in kallsyms generation, including temporary linking of
163+# vmlinux.
164+kallsyms_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+
160174 # Create map file with all symbols from ${1}
161175 # See mksymap for additional details
162176 mksysmap()
@@ -243,6 +257,7 @@ if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then · 80 unmodified lines
243257 fi
244258
245259 kallsymso=""
260+kallsymso_prev=""
246261 kallsyms_vmlinux=""
247262 if [ -n "${CONFIG_KALLSYMS}" ]; then
248263
@@ -269,32 +284,19 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then · 20 unmodified lines
269284 # a) Verify that the System.map from vmlinux matches the map from
270285 # ${kallsymso}.
271286
272− kallsymso=.tmp_kallsyms2.o
273− kallsyms_vmlinux=.tmp_vmlinux2
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
287+ kallsyms_step 1
288+ kallsyms_step 2
282289
283290 # step 3
284− size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" .tmp_kallsyms1.o)
285− size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" .tmp_kallsyms2.o)
291+ size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev})
292+ size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
286293
287294 if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
288− kallsymso=.tmp_kallsyms3.o
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
295+ kallsyms_step 3
293296 fi
294297 fi
295298
296−info LD vmlinux
297−vmlinux_link vmlinux "${kallsymso}" "${btf_vmlinux_bin_o}"
299+vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o}
298300
299301 if [ -n "${CONFIG_BUILDTIME_EXTABLE_SORT}" ]; then
300302 info SORTEX vmlinux
scripts/mkcompile_h+3−1
@@ -5,7 +5,8 @@ TARGET=$1 · 4 unmodified lines
55 ARCH=$2
66 SMP=$3
77 PREEMPT=$4
8−CC=$5
8+PREEMPT_RT=$5
9+CC=$6
910
1011 vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
1112
@@ -53,6 +54,7 @@ UTS_VERSION="#$VERSION" · 41 unmodified lines
5354 CONFIG_FLAGS=""
5455 if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi
5556 if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi
57+if [ -n "$PREEMPT_RT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT_RT"; fi
5658 UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP"
5759
5860 # Truncate to maximum length
scripts/mkmakefile+2−2
@@ -12,6 +12,6 @@ if [ "${quiet}" != "silent_" ]; then · 11 unmodified lines
1212 fi
1313
1414 cat << EOF > Makefile
15−# Automatically generated by $(realpath $0): don't edit
16−include $(realpath $1/Makefile)
15+# Automatically generated by $0: don't edit
16+include $1/Makefile
1717 EOF
scripts/mod/file2alias.c+5−0
@@ -34,6 +34,11 @@ typedef Elf64_Addr kernel_ulong_t; · 33 unmodified lines
3434 typedef uint32_t __u32;
3535 typedef uint16_t __u16;
3636 typedef unsigned char __u8;
37+typedef struct {
38+ __u8 b[16];
39+} guid_t;
40+
41+/* backwards compatibility, don't use in new code */
3742 typedef struct {
3843 __u8 b[16];
3944 } uuid_le;
scripts/mod/modpost.c+38−10
@@ -169,6 +169,7 @@ struct symbol { · 168 unmodified lines
169169 unsigned int kernel:1; /* 1 if symbol is from kernel
170170 * (only for external modules) **/
171171 unsigned int preloaded:1; /* 1 if symbol from Module.symvers, or crc */
172+ unsigned int is_static:1; /* 1 if symbol is not global */
172173 enum export export; /* Type of export */
173174 char name[0];
174175 };
@@ -201,6 +202,7 @@ static struct symbol *alloc_symbol(const char *name, unsigned int weak, · 26 unmodified lines
201202 strcpy(s->name, name);
202203 s->weak = weak;
203204 s->next = next;
205+ s->is_static = 1;
204206 return s;
205207 }
206208
@@ -795,9 +797,9 @@ static int match(const char *sym, const char * const pat[]) · 588 unmodified lines
795797
796798 /* "*foo*" */
797799 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);
799802
800− here = strstr(sym, bare);
801803 free(bare);
802804 if (here != NULL)
803805 return 1;
@@ -1980,6 +1982,21 @@ static void read_symbols(const char *modname) · 1176 unmodified lines
19801982 handle_modversions(mod, &info, sym, symname);
19811983 handle_moddevtable(mod, &info, sym, symname);
19821984 }
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+
19832000 if (!is_vmlinux(modname) || vmlinux_section_warnings)
19842001 check_sec_ref(mod, modname, &info);
19852002
@@ -2159,7 +2176,7 @@ static void add_header(struct buffer *b, struct module *mod) · 173 unmodified lines
21592176 buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n");
21602177 buf_printf(b, "\n");
21612178 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");
21632180 buf_printf(b, "\t.name = KBUILD_MODNAME,\n");
21642181 if (mod->has_init)
21652182 buf_printf(b, "\t.init = init_module,\n");
@@ -2213,8 +2230,7 @@ static int add_versions(struct buffer *b, struct module *mod) · 47 unmodified lines
22132230
22142231 buf_printf(b, "\n");
22152232 buf_printf(b, "static const struct modversion_info ____versions[]\n");
2216− buf_printf(b, "__used\n");
2217− buf_printf(b, "__attribute__((section(\"__versions\"))) = {\n");
2233+ buf_printf(b, "__used __section(__versions) = {\n");
22182234
22192235 for (s = mod->unres; s; s = s->next) {
22202236 if (!s->module)
@@ -2250,10 +2266,7 @@ static void add_depends(struct buffer *b, struct module *mod) · 29 unmodified lines
22502266 s->module->seen = is_vmlinux(s->module->name);
22512267
22522268 buf_printf(b, "\n");
2253− buf_printf(b, "static const char __module_depends[]\n");
2254− buf_printf(b, "__used\n");
2255− buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
2256− buf_printf(b, "\"depends=");
2269+ buf_printf(b, "MODULE_INFO(depends, \"");
22572270 for (s = mod->unres; s; s = s->next) {
22582271 const char *p;
22592272 if (!s->module)
@@ -2271,7 +2284,7 @@ static void add_depends(struct buffer *b, struct module *mod) · 11 unmodified lines
22712284 buf_printf(b, "%s%s", first ? "" : ",", p);
22722285 first = 0;
22732286 }
2274− buf_printf(b, "\";\n");
2287+ buf_printf(b, "\");\n");
22752288 }
22762289
22772290 static void add_srcversion(struct buffer *b, struct module *mod)
@@ -2369,6 +2382,7 @@ static void read_dump(const char *fname, unsigned int kernel) · 91 unmodified lines
23692382 s = sym_add_exported(symname, mod, export_no(export));
23702383 s->kernel = kernel;
23712384 s->preloaded = 1;
2385+ s->is_static = 0;
23722386 sym_update_crc(symname, mod, crc, export_no(export));
23732387 }
23742388 release_file(file, size);
@@ -2425,6 +2439,7 @@ int main(int argc, char **argv) · 50 unmodified lines
24252439 char *dump_write = NULL, *files_source = NULL;
24262440 int opt;
24272441 int err;
2442+ int n;
24282443 struct ext_sym_list *extsym_iter;
24292444 struct ext_sym_list *extsym_start = NULL;
24302445
@@ -2520,6 +2535,19 @@ int main(int argc, char **argv) · 89 unmodified lines
25202535 if (sec_mismatch_count && sec_mismatch_fatal)
25212536 fatal("modpost: Section mismatches detected.\n"
25222537 "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+
25232551 free(buf.p);
25242552
25252553 return err;
usr/include/Makefile+1−3
@@ -115,6 +115,4 @@ header-test-y += $(filter-out $(header-test-), \ · 114 unmodified lines
115115 $(patsubst $(obj)/%,%, $(wildcard \
116116 $(addprefix $(obj)/, *.h */*.h */*/*.h */*/*/*.h))))
117117
118−# For GNU Make <= 4.2.1, $(wildcard $(obj)/*/) matches to not only directories
119−# but also regular files. Use $(filter %/, ...) just in case.
120−clean-dirs += $(patsubst $(obj)/%/,%,$(filter %/, $(wildcard $(obj)/*/)))
118+clean-files += $(filter-out Makefile, $(notdir $(wildcard $(obj)/*)))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t