Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'kbuild-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada:

- Evaluate $(call cc-option,...) etc. only for build targets

- Add CONFIG_VMLINUX_MAP to generate .map file when linking vmlinux

- Remove unnecessary --gcc-toolchains Clang flag because the --prefix
flag finds the toolchains

- Do not pass Clang's --prefix flag when using the integrated as

- Check the assembler version in Kconfig time

- Add new CONFIG options, AS_VERSION, AS_IS_GNU, AS_IS_LLVM to clean up
some dependencies in Kconfig

- Fix invalid Module.symvers creation when building only modules
without vmlinux

- Fix false-positive modpost warnings when CONFIG_TRIM_UNUSED_KSYMS is
set, but there is no module to build

- Refactor module installation Makefile

- Support zstd for module compression

- Convert alpha and ia64 to use generic shell scripts to generate the
syscall headers

- Add a new elfnote to indicate if the kernel was built with LTO, which
will be used by pahole

- Flatten the directory structure under include/config/ so CONFIG
options and filenames match

- Change the deb source package name from linux-$(KERNELRELEASE) to
linux-upstream

* tag 'kbuild-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (42 commits)
kbuild: Add $(KBUILD_HOSTLDFLAGS) to 'has_libelf' test
kbuild: deb-pkg: change the source package name to linux-upstream
tools: do not include scripts/Kbuild.include
kbuild: redo fake deps at include/config/*.h
kbuild: remove TMPO from try-run
MAINTAINERS: add pattern for dummy-tools
kbuild: add an elfnote for whether vmlinux is built with lto
ia64: syscalls: switch to generic syscallhdr.sh
ia64: syscalls: switch to generic syscalltbl.sh
alpha: syscalls: switch to generic syscallhdr.sh
alpha: syscalls: switch to generic syscalltbl.sh
sysctl: use min() helper for namecmp()
kbuild: add support for zstd compressed modules
kbuild: remove CONFIG_MODULE_COMPRESS
kbuild: merge scripts/Makefile.modsign to scripts/Makefile.modinst
kbuild: move module strip/compression code into scripts/Makefile.modinst
kbuild: refactor scripts/Makefile.modinst
kbuild: rename extmod-prefix to extmod_prefix
kbuild: check module name conflict for external modules as well
kbuild: show the target directory for depmod log
...

+641 -602
+2
.gitignore
··· 57 57 /tags 58 58 /TAGS 59 59 /linux 60 + /modules-only.symvers 60 61 /vmlinux 61 62 /vmlinux.32 63 + /vmlinux.map 62 64 /vmlinux.symvers 63 65 /vmlinux-gdb.py 64 66 /vmlinuz
+1 -1
Documentation/devicetree/bindings/Makefile
··· 48 48 $(call cmd,mk_schema) 49 49 endef 50 50 51 - DT_DOCS = $(shell $(find_cmd) | sed -e 's|^$(srctree)/||') 51 + DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_cmd))) 52 52 53 53 override DTC_FLAGS := \ 54 54 -Wno-avoid_unnecessary_addr_size \
+2
Documentation/dontdiff
··· 178 178 mktree 179 179 mkutf8data 180 180 modpost 181 + modules-only.symvers 181 182 modules.builtin 182 183 modules.builtin.modinfo 183 184 modules.nsdeps ··· 253 252 vmlinux.aout 254 253 vmlinux.bin.all 255 254 vmlinux.lds 255 + vmlinux.map 256 256 vmlinux.symvers 257 257 vmlinuz 258 258 voffset.h
+1 -1
Documentation/kbuild/Kconfig.recursion-issue-02
··· 6 6 # make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig 7 7 # 8 8 # The recursive limitations with Kconfig has some non intuitive implications on 9 - # kconfig sematics which are documented here. One known practical implication 9 + # kconfig semantics which are documented here. One known practical implication 10 10 # of the recursive limitation is that drivers cannot negate features from other 11 11 # drivers if they share a common core requirement and use disjoint semantics to 12 12 # annotate those requirements, ie, some drivers use "depends on" while others
+1
MAINTAINERS
··· 9844 9844 F: scripts/Kbuild* 9845 9845 F: scripts/Makefile* 9846 9846 F: scripts/basic/ 9847 + F: scripts/dummy-tools/ 9847 9848 F: scripts/mk* 9848 9849 F: scripts/mod/ 9849 9850 F: scripts/package/
+103 -127
Makefile
··· 264 264 $(version_h) headers headers_% archheaders archscripts \ 265 265 %asm-generic kernelversion %src-pkg dt_binding_check \ 266 266 outputmakefile 267 + # Installation targets should not require compiler. Unfortunately, vdso_install 268 + # is an exception where build artifacts may be updated. This must be fixed. 269 + no-compiler-targets := $(no-dot-config-targets) install dtbs_install \ 270 + headers_install modules_install kernelrelease image_name 267 271 no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \ 268 272 image_name 269 273 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/ ··· 275 271 config-build := 276 272 mixed-build := 277 273 need-config := 1 274 + need-compiler := 1 278 275 may-sync-config := 1 279 276 single-build := 280 277 281 278 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) 282 279 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) 283 280 need-config := 281 + endif 282 + endif 283 + 284 + ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),) 285 + ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),) 286 + need-compiler := 284 287 endif 285 288 endif 286 289 ··· 350 339 351 340 else # !mixed-build 352 341 353 - include scripts/Kbuild.include 342 + include $(srctree)/scripts/Kbuild.include 354 343 355 344 # Read KERNELRELEASE from include/config/kernel.release (if it exists) 356 345 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) 357 346 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 358 347 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 359 348 360 - include scripts/subarch.include 349 + include $(srctree)/scripts/subarch.include 361 350 362 351 # Cross compiling and selecting different set of gcc/bin-utils 363 352 # --------------------------------------------------------------------------- ··· 574 563 # Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile. 575 564 # CC_VERSION_TEXT is referenced from Kconfig (so it needs export), 576 565 # and from include/config/auto.conf.cmd to detect the compiler upgrade. 577 - CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g') 566 + CC_VERSION_TEXT = $(subst $(pound),,$(shell $(CC) --version 2>/dev/null | head -n 1)) 578 567 579 568 ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) 580 569 ifneq ($(CROSS_COMPILE),) 581 570 CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) 571 + endif 572 + ifeq ($(LLVM_IAS),1) 573 + CLANG_FLAGS += -integrated-as 574 + else 575 + CLANG_FLAGS += -no-integrated-as 582 576 GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) 583 577 CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) 584 - GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) 585 - endif 586 - ifneq ($(GCC_TOOLCHAIN),) 587 - CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) 588 - endif 589 - ifneq ($(LLVM_IAS),1) 590 - CLANG_FLAGS += -no-integrated-as 591 578 endif 592 579 CLANG_FLAGS += -Werror=unknown-warning-option 593 580 KBUILD_CFLAGS += $(CLANG_FLAGS) 594 581 KBUILD_AFLAGS += $(CLANG_FLAGS) 595 582 export CLANG_FLAGS 583 + endif 584 + 585 + # Include this also for config targets because some architectures need 586 + # cc-cross-prefix to determine CROSS_COMPILE. 587 + ifdef need-compiler 588 + include $(srctree)/scripts/Makefile.compiler 596 589 endif 597 590 598 591 ifdef config-build ··· 607 592 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. 608 593 # KBUILD_DEFCONFIG may point out an alternative default configuration 609 594 # used for 'make defconfig' 610 - include arch/$(SRCARCH)/Makefile 595 + include $(srctree)/arch/$(SRCARCH)/Makefile 611 596 export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT 612 597 613 598 config: outputmakefile scripts_basic FORCE ··· 694 679 export RETPOLINE_CFLAGS 695 680 export RETPOLINE_VDSO_CFLAGS 696 681 697 - include arch/$(SRCARCH)/Makefile 682 + include $(srctree)/arch/$(SRCARCH)/Makefile 698 683 699 684 ifdef need-config 700 685 ifdef may-sync-config ··· 923 908 ifdef CONFIG_LTO_CLANG 924 909 ifdef CONFIG_LTO_CLANG_THIN 925 910 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit 926 - KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache 911 + KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod_prefix).thinlto-cache 927 912 else 928 913 CC_FLAGS_LTO := -flto 929 914 endif ··· 1084 1069 MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) 1085 1070 export MODLIB 1086 1071 1087 - # 1088 - # INSTALL_MOD_STRIP, if defined, will cause modules to be 1089 - # stripped after they are installed. If INSTALL_MOD_STRIP is '1', then 1090 - # the default option --strip-debug will be used. Otherwise, 1091 - # INSTALL_MOD_STRIP value will be used as the options to the strip command. 1092 - 1093 - ifdef INSTALL_MOD_STRIP 1094 - ifeq ($(INSTALL_MOD_STRIP),1) 1095 - mod_strip_cmd = $(STRIP) --strip-debug 1096 - else 1097 - mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP) 1098 - endif # INSTALL_MOD_STRIP=1 1099 - else 1100 - mod_strip_cmd = true 1101 - endif # INSTALL_MOD_STRIP 1102 - export mod_strip_cmd 1103 - 1104 - # CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed 1105 - # after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP 1106 - # or CONFIG_MODULE_COMPRESS_XZ. 1107 - 1108 - mod_compress_cmd = true 1109 - ifdef CONFIG_MODULE_COMPRESS 1110 - ifdef CONFIG_MODULE_COMPRESS_GZIP 1111 - mod_compress_cmd = $(KGZIP) -n -f 1112 - endif # CONFIG_MODULE_COMPRESS_GZIP 1113 - ifdef CONFIG_MODULE_COMPRESS_XZ 1114 - mod_compress_cmd = $(XZ) --lzma2=dict=2MiB -f 1115 - endif # CONFIG_MODULE_COMPRESS_XZ 1116 - endif # CONFIG_MODULE_COMPRESS 1117 - export mod_compress_cmd 1118 - 1119 - ifdef CONFIG_MODULE_SIG_ALL 1120 - $(eval $(call config_filename,MODULE_SIG_KEY)) 1121 - 1122 - mod_sign_cmd = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509 1123 - else 1124 - mod_sign_cmd = true 1125 - endif 1126 - export mod_sign_cmd 1127 - 1128 1072 HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) 1129 1073 1130 1074 has_libelf = $(call try-run,\ 1131 - echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0) 1075 + echo "int main() {}" | $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0) 1132 1076 1133 1077 ifdef CONFIG_STACK_VALIDATION 1134 1078 ifeq ($(has_libelf),1) ··· 1121 1147 1122 1148 PHONY += prepare0 1123 1149 1124 - extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/) 1125 - export MODORDER := $(extmod-prefix)modules.order 1126 - export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps 1150 + export extmod_prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/) 1151 + export MODORDER := $(extmod_prefix)modules.order 1152 + export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps 1127 1153 1128 1154 ifeq ($(KBUILD_EXTMOD),) 1129 1155 core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ ··· 1191 1217 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 1192 1218 1193 1219 vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE 1194 - +$(call if_changed,link-vmlinux) 1220 + +$(call if_changed_dep,link-vmlinux) 1195 1221 1196 1222 targets := vmlinux 1197 1223 ··· 1336 1362 # Deprecated. It is no-op now. 1337 1363 PHONY += headers_check 1338 1364 headers_check: 1339 - @: 1365 + @echo >&2 "=================== WARNING ===================" 1366 + @echo >&2 "Since Linux 5.5, 'make headers_check' is no-op," 1367 + @echo >&2 "and will be removed after Linux 5.15 release." 1368 + @echo >&2 "Please remove headers_check from your scripts." 1369 + @echo >&2 "===============================================" 1340 1370 1341 1371 ifdef CONFIG_HEADERS_INSTALL 1342 1372 prepare: headers ··· 1438 1460 1439 1461 PHONY += modules 1440 1462 modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare 1441 - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1442 - 1443 - PHONY += modules_check 1444 - modules_check: modules.order 1445 - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $< 1446 1463 1447 1464 cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@ 1448 1465 ··· 1451 1478 modules_prepare: prepare 1452 1479 $(Q)$(MAKE) $(build)=scripts scripts/module.lds 1453 1480 1454 - # Target to install modules 1455 - PHONY += modules_install 1456 - modules_install: _modinst_ _modinst_post 1481 + export modules_sign_only := 1457 1482 1458 - PHONY += _modinst_ 1459 - _modinst_: 1483 + ifeq ($(CONFIG_MODULE_SIG),y) 1484 + PHONY += modules_sign 1485 + modules_sign: modules_install 1486 + @: 1487 + 1488 + # modules_sign is a subset of modules_install. 1489 + # 'make modules_install modules_sign' is equivalent to 'make modules_install'. 1490 + ifeq ($(filter modules_install,$(MAKECMDGOALS)),) 1491 + modules_sign_only := y 1492 + endif 1493 + endif 1494 + 1495 + modinst_pre := 1496 + ifneq ($(filter modules_install,$(MAKECMDGOALS)),) 1497 + modinst_pre := __modinst_pre 1498 + endif 1499 + 1500 + modules_install: $(modinst_pre) 1501 + PHONY += __modinst_pre 1502 + __modinst_pre: 1460 1503 @rm -rf $(MODLIB)/kernel 1461 1504 @rm -f $(MODLIB)/source 1462 1505 @mkdir -p $(MODLIB)/kernel ··· 1484 1495 @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order 1485 1496 @cp -f modules.builtin $(MODLIB)/ 1486 1497 @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ 1487 - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst 1488 - 1489 - # This depmod is only for convenience to give the initial 1490 - # boot a modules.dep even before / is mounted read-write. However the 1491 - # boot script depmod is the master version. 1492 - PHONY += _modinst_post 1493 - _modinst_post: _modinst_ 1494 - $(call cmd,depmod) 1495 - 1496 - ifeq ($(CONFIG_MODULE_SIG), y) 1497 - PHONY += modules_sign 1498 - modules_sign: 1499 - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign 1500 - endif 1501 - 1502 - else # CONFIG_MODULES 1503 - 1504 - # Modules not configured 1505 - # --------------------------------------------------------------------------- 1506 - 1507 - PHONY += modules modules_install 1508 - modules modules_install: 1509 - @echo >&2 1510 - @echo >&2 "The present kernel configuration has modules disabled." 1511 - @echo >&2 "Type 'make config' and enable loadable module support." 1512 - @echo >&2 "Then build a kernel with module support enabled." 1513 - @echo >&2 1514 - @exit 1 1515 1498 1516 1499 endif # CONFIG_MODULES 1517 1500 ··· 1495 1534 # make distclean Remove editor backup files, patch leftover files and the like 1496 1535 1497 1536 # Directories & files removed with 'make clean' 1498 - CLEAN_FILES += include/ksym vmlinux.symvers \ 1537 + CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \ 1499 1538 modules.builtin modules.builtin.modinfo modules.nsdeps \ 1500 1539 compile_commands.json .thinlto-cache 1501 1540 ··· 1732 1771 KBUILD_MODULES := 1 1733 1772 1734 1773 build-dirs := $(KBUILD_EXTMOD) 1735 - PHONY += modules 1736 - modules: $(MODORDER) 1737 - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1738 - 1739 1774 $(MODORDER): descend 1740 1775 @: 1741 1776 1742 - PHONY += modules_install 1743 - modules_install: _emodinst_ _emodinst_post 1744 - 1745 - install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) 1746 - PHONY += _emodinst_ 1747 - _emodinst_: 1748 - $(Q)mkdir -p $(MODLIB)/$(install-dir) 1749 - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst 1750 - 1751 - PHONY += _emodinst_post 1752 - _emodinst_post: _emodinst_ 1753 - $(call cmd,depmod) 1754 - 1755 - compile_commands.json: $(extmod-prefix)compile_commands.json 1777 + compile_commands.json: $(extmod_prefix)compile_commands.json 1756 1778 PHONY += compile_commands.json 1757 1779 1758 1780 clean-dirs := $(KBUILD_EXTMOD) ··· 1756 1812 PHONY += prepare modules_prepare 1757 1813 1758 1814 endif # KBUILD_EXTMOD 1815 + 1816 + # --------------------------------------------------------------------------- 1817 + # Modules 1818 + 1819 + PHONY += modules modules_install 1820 + 1821 + ifdef CONFIG_MODULES 1822 + 1823 + modules: modules_check 1824 + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1825 + 1826 + PHONY += modules_check 1827 + modules_check: $(MODORDER) 1828 + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $< 1829 + 1830 + quiet_cmd_depmod = DEPMOD $(MODLIB) 1831 + cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ 1832 + $(KERNELRELEASE) 1833 + 1834 + modules_install: 1835 + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst 1836 + $(call cmd,depmod) 1837 + 1838 + else # CONFIG_MODULES 1839 + 1840 + # Modules not configured 1841 + # --------------------------------------------------------------------------- 1842 + 1843 + modules modules_install: 1844 + @echo >&2 '***' 1845 + @echo >&2 '*** The present kernel configuration has modules disabled.' 1846 + @echo >&2 '*** To use the module feature, please run "make menuconfig" etc.' 1847 + @echo >&2 '*** to enable CONFIG_MODULES.' 1848 + @echo >&2 '***' 1849 + @exit 1 1850 + 1851 + endif # CONFIG_MODULES 1759 1852 1760 1853 # Single targets 1761 1854 # --------------------------------------------------------------------------- ··· 1825 1844 1826 1845 PHONY += single_modpost 1827 1846 single_modpost: $(single-no-ko) modules_prepare 1828 - $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER) 1847 + $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$m;) } > $(MODORDER) 1829 1848 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1830 1849 1831 1850 KBUILD_MODULES := 1 1832 1851 1833 - export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko)) 1852 + export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod_prefix), $(single-no-ko)) 1834 1853 1835 1854 # trim unrelated directories 1836 1855 build-dirs := $(foreach d, $(build-dirs), \ ··· 1899 1918 quiet_cmd_gen_compile_commands = GEN $@ 1900 1919 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs)) 1901 1920 1902 - $(extmod-prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \ 1921 + $(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \ 1903 1922 $(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \ 1904 1923 $(if $(CONFIG_MODULES), $(MODORDER)) FORCE 1905 1924 $(call if_changed,gen_compile_commands) 1906 1925 1907 - targets += $(extmod-prefix)compile_commands.json 1926 + targets += $(extmod_prefix)compile_commands.json 1908 1927 1909 1928 PHONY += clang-tidy clang-analyzer 1910 1929 ··· 1912 1931 quiet_cmd_clang_tools = CHECK $< 1913 1932 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $< 1914 1933 1915 - clang-tidy clang-analyzer: $(extmod-prefix)compile_commands.json 1934 + clang-tidy clang-analyzer: $(extmod_prefix)compile_commands.json 1916 1935 $(call cmd,clang_tools) 1917 1936 else 1918 1937 clang-tidy clang-analyzer: ··· 1981 2000 1982 2001 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) 1983 2002 cmd_rmfiles = rm -rf $(rm-files) 1984 - 1985 - # Run depmod only if we have System.map and depmod is executable 1986 - quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) 1987 - cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ 1988 - $(KERNELRELEASE) 1989 2003 1990 2004 # read saved command lines for existing targets 1991 2005 existing-targets := $(wildcard $(sort $(targets)))
+1 -2
arch/Kconfig
··· 631 631 config HAS_LTO_CLANG 632 632 def_bool y 633 633 # Clang >= 11: https://github.com/ClangBuiltLinux/linux/issues/510 634 - depends on CC_IS_CLANG && CLANG_VERSION >= 110000 && LD_IS_LLD 635 - depends on $(success,test $(LLVM_IAS) -eq 1) 634 + depends on CC_IS_CLANG && CLANG_VERSION >= 110000 && LD_IS_LLD && AS_IS_LLVM 636 635 depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm) 637 636 depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) 638 637 depends on ARCH_SUPPORTS_LTO_CLANG
+4 -10
arch/alpha/kernel/syscalls/Makefile
··· 6 6 $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') 7 7 8 8 syscall := $(src)/syscall.tbl 9 - syshdr := $(srctree)/$(src)/syscallhdr.sh 10 - systbl := $(srctree)/$(src)/syscalltbl.sh 9 + syshdr := $(srctree)/scripts/syscallhdr.sh 10 + systbl := $(srctree)/scripts/syscalltbl.sh 11 11 12 12 quiet_cmd_syshdr = SYSHDR $@ 13 - cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \ 14 - '$(syshdr_abis_$(basetarget))' \ 15 - '$(syshdr_pfx_$(basetarget))' \ 16 - '$(syshdr_offset_$(basetarget))' 13 + cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --emit-nr $< $@ 17 14 18 15 quiet_cmd_systbl = SYSTBL $@ 19 - cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@' \ 20 - '$(systbl_abis_$(basetarget))' \ 21 - '$(systbl_abi_$(basetarget))' \ 22 - '$(systbl_offset_$(basetarget))' 16 + cmd_systbl = $(CONFIG_SHELL) $(systbl) $< $@ 23 17 24 18 $(uapi)/unistd_32.h: $(syscall) $(syshdr) FORCE 25 19 $(call if_changed,syshdr)
-36
arch/alpha/kernel/syscalls/syscallhdr.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - in="$1" 5 - out="$2" 6 - my_abis=`echo "($3)" | tr ',' '|'` 7 - prefix="$4" 8 - offset="$5" 9 - 10 - fileguard=_UAPI_ASM_ALPHA_`basename "$out" | sed \ 11 - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ 12 - -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` 13 - grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( 14 - printf "#ifndef %s\n" "${fileguard}" 15 - printf "#define %s\n" "${fileguard}" 16 - printf "\n" 17 - 18 - nxt=0 19 - while read nr abi name entry ; do 20 - if [ -z "$offset" ]; then 21 - printf "#define __NR_%s%s\t%s\n" \ 22 - "${prefix}" "${name}" "${nr}" 23 - else 24 - printf "#define __NR_%s%s\t(%s + %s)\n" \ 25 - "${prefix}" "${name}" "${offset}" "${nr}" 26 - fi 27 - nxt=$((nr+1)) 28 - done 29 - 30 - printf "\n" 31 - printf "#ifdef __KERNEL__\n" 32 - printf "#define __NR_syscalls\t%s\n" "${nxt}" 33 - printf "#endif\n" 34 - printf "\n" 35 - printf "#endif /* %s */\n" "${fileguard}" 36 - ) > "$out"
-32
arch/alpha/kernel/syscalls/syscalltbl.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - in="$1" 5 - out="$2" 6 - my_abis=`echo "($3)" | tr ',' '|'` 7 - my_abi="$4" 8 - offset="$5" 9 - 10 - emit() { 11 - t_nxt="$1" 12 - t_nr="$2" 13 - t_entry="$3" 14 - 15 - while [ $t_nxt -lt $t_nr ]; do 16 - printf "__SYSCALL(%s, sys_ni_syscall, )\n" "${t_nxt}" 17 - t_nxt=$((t_nxt+1)) 18 - done 19 - printf "__SYSCALL(%s, %s, )\n" "${t_nxt}" "${t_entry}" 20 - } 21 - 22 - grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( 23 - nxt=0 24 - if [ -z "$offset" ]; then 25 - offset=0 26 - fi 27 - 28 - while read nr abi name entry ; do 29 - emit $((nxt+offset)) $((nr+offset)) $entry 30 - nxt=$((nr+1)) 31 - done 32 - ) > "$out"
+1 -2
arch/alpha/kernel/systbls.S
··· 7 7 8 8 #include <asm/unistd.h> 9 9 10 - #define __SYSCALL(nr, entry, nargs) .quad entry 10 + #define __SYSCALL(nr, entry) .quad entry 11 11 .data 12 12 .align 3 13 13 .globl sys_call_table 14 14 sys_call_table: 15 15 #include <asm/syscall_table.h> 16 - #undef __SYSCALL
+3
arch/arm64/Kconfig
··· 525 525 526 526 If unsure, say Y. 527 527 528 + config ARM64_LD_HAS_FIX_ERRATUM_843419 529 + def_bool $(ld-option,--fix-cortex-a53-843419) 530 + 528 531 config ARM64_ERRATUM_1024718 529 532 bool "Cortex-A55: 1024718: Update of DBM/AP bits without break before make might result in incorrect update" 530 533 default y
+1 -1
arch/arm64/Makefile
··· 21 21 endif 22 22 23 23 ifeq ($(CONFIG_ARM64_ERRATUM_843419),y) 24 - ifeq ($(call ld-option, --fix-cortex-a53-843419),) 24 + ifneq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y) 25 25 $(warning ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum) 26 26 else 27 27 LDFLAGS_vmlinux += --fix-cortex-a53-843419
+1 -2
arch/ia64/kernel/entry.S
··· 1420 1420 1421 1421 #endif /* CONFIG_FUNCTION_TRACER */ 1422 1422 1423 - #define __SYSCALL(nr, entry, nargs) data8 entry 1423 + #define __SYSCALL(nr, entry) data8 entry 1424 1424 .rodata 1425 1425 .align 8 1426 1426 .globl sys_call_table 1427 1427 sys_call_table: 1428 1428 #include <asm/syscall_table.h> 1429 - #undef __SYSCALL
+4 -12
arch/ia64/kernel/syscalls/Makefile
··· 6 6 $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') 7 7 8 8 syscall := $(src)/syscall.tbl 9 - syshdr := $(srctree)/$(src)/syscallhdr.sh 10 - systbl := $(srctree)/$(src)/syscalltbl.sh 9 + syshdr := $(srctree)/scripts/syscallhdr.sh 10 + systbl := $(srctree)/scripts/syscalltbl.sh 11 11 12 12 quiet_cmd_syshdr = SYSHDR $@ 13 - cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \ 14 - '$(syshdr_abis_$(basetarget))' \ 15 - '$(syshdr_pfx_$(basetarget))' \ 16 - '$(syshdr_offset_$(basetarget))' 13 + cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --emit-nr --offset __NR_Linux $< $@ 17 14 18 15 quiet_cmd_systbl = SYSTBL $@ 19 - cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@' \ 20 - '$(systbl_abis_$(basetarget))' \ 21 - '$(systbl_abi_$(basetarget))' \ 22 - '$(systbl_offset_$(basetarget))' 16 + cmd_systbl = $(CONFIG_SHELL) $(systbl) $< $@ 23 17 24 - syshdr_offset_unistd_64 := __NR_Linux 25 18 $(uapi)/unistd_64.h: $(syscall) $(syshdr) FORCE 26 19 $(call if_changed,syshdr) 27 20 28 - systbl_offset_syscall_table := 1024 29 21 $(kapi)/syscall_table.h: $(syscall) $(systbl) FORCE 30 22 $(call if_changed,systbl) 31 23
-36
arch/ia64/kernel/syscalls/syscallhdr.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - in="$1" 5 - out="$2" 6 - my_abis=`echo "($3)" | tr ',' '|'` 7 - prefix="$4" 8 - offset="$5" 9 - 10 - fileguard=_UAPI_ASM_IA64_`basename "$out" | sed \ 11 - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ 12 - -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` 13 - grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( 14 - printf "#ifndef %s\n" "${fileguard}" 15 - printf "#define %s\n" "${fileguard}" 16 - printf "\n" 17 - 18 - nxt=0 19 - while read nr abi name entry ; do 20 - if [ -z "$offset" ]; then 21 - printf "#define __NR_%s%s\t%s\n" \ 22 - "${prefix}" "${name}" "${nr}" 23 - else 24 - printf "#define __NR_%s%s\t(%s + %s)\n" \ 25 - "${prefix}" "${name}" "${offset}" "${nr}" 26 - fi 27 - nxt=$((nr+1)) 28 - done 29 - 30 - printf "\n" 31 - printf "#ifdef __KERNEL__\n" 32 - printf "#define __NR_syscalls\t%s\n" "${nxt}" 33 - printf "#endif\n" 34 - printf "\n" 35 - printf "#endif /* %s */\n" "${fileguard}" 36 - ) > "$out"
-32
arch/ia64/kernel/syscalls/syscalltbl.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - in="$1" 5 - out="$2" 6 - my_abis=`echo "($3)" | tr ',' '|'` 7 - my_abi="$4" 8 - offset="$5" 9 - 10 - emit() { 11 - t_nxt="$1" 12 - t_nr="$2" 13 - t_entry="$3" 14 - 15 - while [ $t_nxt -lt $t_nr ]; do 16 - printf "__SYSCALL(%s, sys_ni_syscall, )\n" "${t_nxt}" 17 - t_nxt=$((t_nxt+1)) 18 - done 19 - printf "__SYSCALL(%s, %s, )\n" "${t_nxt}" "${t_entry}" 20 - } 21 - 22 - grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( 23 - nxt=0 24 - if [ -z "$offset" ]; then 25 - offset=0 26 - fi 27 - 28 - while read nr abi name entry ; do 29 - emit $((nxt+offset)) $((nr+offset)) $entry 30 - nxt=$((nr+1)) 31 - done 32 - ) > "$out"
+2 -2
arch/x86/Makefile
··· 138 138 x32_ld_ok := $(call try-run,\ 139 139 /bin/echo -e '1: .quad 1b' | \ 140 140 $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \ 141 - $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMPO" && \ 142 - $(LD) -m elf32_x86_64 "$$TMPO" -o "$$TMP",y,n) 141 + $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMP.o" && \ 142 + $(LD) -m elf32_x86_64 "$$TMP.o" -o "$$TMP",y,n) 143 143 ifeq ($(x32_ld_ok),y) 144 144 CONFIG_X86_X32_ABI := y 145 145 KBUILD_AFLAGS += -DCONFIG_X86_X32_ABI
+1 -6
fs/proc/proc_sysctl.c
··· 94 94 95 95 static int namecmp(const char *name1, int len1, const char *name2, int len2) 96 96 { 97 - int minlen; 98 97 int cmp; 99 98 100 - minlen = len1; 101 - if (minlen > len2) 102 - minlen = len2; 103 - 104 - cmp = memcmp(name1, name2, minlen); 99 + cmp = memcmp(name1, name2, min(len1, len2)); 105 100 if (cmp == 0) 106 101 cmp = len1 - len2; 107 102 return cmp;
+1 -1
include/linux/compiler-version.h
··· 9 9 * This header exists to force full rebuild when the compiler is upgraded. 10 10 * 11 11 * When fixdep scans this, it will find this string "CONFIG_CC_VERSION_TEXT" 12 - * and add dependency on include/config/cc/version/text.h, which is touched 12 + * and add dependency on include/config/CC_VERSION_TEXT, which is touched 13 13 * by Kconfig when the version string from the compiler changes. 14 14 */
+14
include/linux/elfnote-lto.h
··· 1 + #ifndef __ELFNOTE_LTO_H 2 + #define __ELFNOTE_LTO_H 3 + 4 + #include <linux/elfnote.h> 5 + 6 + #define LINUX_ELFNOTE_LTO_INFO 0x101 7 + 8 + #ifdef CONFIG_LTO 9 + #define BUILD_LTO_INFO ELFNOTE32("Linux", LINUX_ELFNOTE_LTO_INFO, 1) 10 + #else 11 + #define BUILD_LTO_INFO ELFNOTE32("Linux", LINUX_ELFNOTE_LTO_INFO, 0) 12 + #endif 13 + 14 + #endif /* __ELFNOTE_LTO_H */
+51 -26
init/Kconfig
··· 21 21 22 22 - Ensure full rebuild when the compiler is updated 23 23 include/linux/compiler-version.h contains this option in the comment 24 - line so fixdep adds include/config/cc/version/text.h into the 24 + line so fixdep adds include/config/CC_VERSION_TEXT into the 25 25 auto-generated dependency. When the compiler is updated, syncconfig 26 26 will touch it and then every file will be rebuilt. 27 27 ··· 40 40 int 41 41 default $(cc-version) if CC_IS_CLANG 42 42 default 0 43 + 44 + config AS_IS_GNU 45 + def_bool $(success,test "$(as-name)" = GNU) 46 + 47 + config AS_IS_LLVM 48 + def_bool $(success,test "$(as-name)" = LLVM) 49 + 50 + config AS_VERSION 51 + int 52 + # Use clang version if this is the integrated assembler 53 + default CLANG_VERSION if AS_IS_LLVM 54 + default $(as-version) 43 55 44 56 config LD_IS_BFD 45 57 def_bool $(success,test "$(ld-name)" = BFD) ··· 2241 2229 default "sha384" if MODULE_SIG_SHA384 2242 2230 default "sha512" if MODULE_SIG_SHA512 2243 2231 2244 - config MODULE_COMPRESS 2245 - bool "Compress modules on installation" 2246 - help 2247 - 2248 - Compresses kernel modules when 'make modules_install' is run; gzip or 2249 - xz depending on "Compression algorithm" below. 2250 - 2251 - module-init-tools MAY support gzip, and kmod MAY support gzip and xz. 2252 - 2253 - Out-of-tree kernel modules installed using Kbuild will also be 2254 - compressed upon installation. 2255 - 2256 - Note: for modules inside an initrd or initramfs, it's more efficient 2257 - to compress the whole initrd or initramfs instead. 2258 - 2259 - Note: This is fully compatible with signed modules. 2260 - 2261 - If in doubt, say N. 2262 - 2263 2232 choice 2264 - prompt "Compression algorithm" 2265 - depends on MODULE_COMPRESS 2266 - default MODULE_COMPRESS_GZIP 2233 + prompt "Module compression mode" 2267 2234 help 2268 - This determines which sort of compression will be used during 2269 - 'make modules_install'. 2235 + This option allows you to choose the algorithm which will be used to 2236 + compress modules when 'make modules_install' is run. (or, you can 2237 + choose to not compress modules at all.) 2270 2238 2271 - GZIP (default) and XZ are supported. 2239 + External modules will also be compressed in the same way during the 2240 + installation. 2241 + 2242 + For modules inside an initrd or initramfs, it's more efficient to 2243 + compress the whole initrd or initramfs instead. 2244 + 2245 + This is fully compatible with signed modules. 2246 + 2247 + Please note that the tool used to load modules needs to support the 2248 + corresponding algorithm. module-init-tools MAY support gzip, and kmod 2249 + MAY support gzip, xz and zstd. 2250 + 2251 + Your build system needs to provide the appropriate compression tool 2252 + to compress the modules. 2253 + 2254 + If in doubt, select 'None'. 2255 + 2256 + config MODULE_COMPRESS_NONE 2257 + bool "None" 2258 + help 2259 + Do not compress modules. The installed modules are suffixed 2260 + with .ko. 2272 2261 2273 2262 config MODULE_COMPRESS_GZIP 2274 2263 bool "GZIP" 2264 + help 2265 + Compress modules with GZIP. The installed modules are suffixed 2266 + with .ko.gz. 2275 2267 2276 2268 config MODULE_COMPRESS_XZ 2277 2269 bool "XZ" 2270 + help 2271 + Compress modules with XZ. The installed modules are suffixed 2272 + with .ko.xz. 2273 + 2274 + config MODULE_COMPRESS_ZSTD 2275 + bool "ZSTD" 2276 + help 2277 + Compress modules with ZSTD. The installed modules are suffixed 2278 + with .ko.zst. 2278 2279 2279 2280 endchoice 2280 2281
+2
init/version.c
··· 9 9 10 10 #include <generated/compile.h> 11 11 #include <linux/build-salt.h> 12 + #include <linux/elfnote-lto.h> 12 13 #include <linux/export.h> 13 14 #include <linux/uts.h> 14 15 #include <linux/utsname.h> ··· 46 45 " (" LINUX_COMPILER ") %s\n"; 47 46 48 47 BUILD_SALT; 48 + BUILD_LTO_INFO;
+1 -1
kernel/gen_kheaders.sh
··· 36 36 # 37 37 # When Kconfig regenerates include/generated/autoconf.h, its timestamp is 38 38 # updated, but the contents might be still the same. When any CONFIG option is 39 - # changed, Kconfig touches the corresponding timestamp file include/config/*.h. 39 + # changed, Kconfig touches the corresponding timestamp file include/config/*. 40 40 # Hence, the md5sum detects the configuration change anyway. We do not need to 41 41 # check include/generated/autoconf.h explicitly. 42 42 #
+11 -2
lib/Kconfig.debug
··· 284 284 285 285 config DEBUG_INFO_DWARF5 286 286 bool "Generate DWARF Version 5 debuginfo" 287 - depends on GCC_VERSION >= 50000 || CC_IS_CLANG 288 - depends on CC_IS_GCC || $(success,$(srctree)/scripts/test_dwarf5_support.sh $(CC) $(CLANG_FLAGS)) 287 + depends on GCC_VERSION >= 50000 || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502))) 289 288 depends on !DEBUG_INFO_BTF 290 289 help 291 290 Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc ··· 447 448 bool 448 449 depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT 449 450 default y 451 + 452 + config VMLINUX_MAP 453 + bool "Generate vmlinux.map file when linking" 454 + depends on EXPERT 455 + help 456 + Selecting this option will pass "-Map=vmlinux.map" to ld 457 + when linking vmlinux. That file can be useful for verifying 458 + and debugging magic section games, and for seeing which 459 + pieces of code get eliminated with 460 + CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. 450 461 451 462 config DEBUG_FORCE_WEAK_PER_CPU 452 463 bool "Force weak per-cpu definitions"
-80
scripts/Kbuild.include
··· 67 67 fi 68 68 endef 69 69 70 - ###### 71 - # gcc support functions 72 - # See documentation in Documentation/kbuild/makefiles.rst 73 - 74 - # cc-cross-prefix 75 - # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) 76 - # Return first <prefix> where a <prefix>gcc is found in PATH. 77 - # If no gcc found in PATH with listed prefixes return nothing 78 - # 79 - # Note: '2>/dev/null' is here to force Make to invoke a shell. Otherwise, it 80 - # would try to directly execute the shell builtin 'command'. This workaround 81 - # should be kept for a long time since this issue was fixed only after the 82 - # GNU Make 4.2.1 release. 83 - cc-cross-prefix = $(firstword $(foreach c, $(1), \ 84 - $(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c)))) 85 - 86 - # output directory for tests below 87 - TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$ 88 - 89 - # try-run 90 - # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) 91 - # Exit code chooses option. "$$TMP" serves as a temporary file and is 92 - # automatically cleaned up. 93 - try-run = $(shell set -e; \ 94 - TMP=$(TMPOUT)/tmp; \ 95 - TMPO=$(TMPOUT)/tmp.o; \ 96 - mkdir -p $(TMPOUT); \ 97 - trap "rm -rf $(TMPOUT)" EXIT; \ 98 - if ($(1)) >/dev/null 2>&1; \ 99 - then echo "$(2)"; \ 100 - else echo "$(3)"; \ 101 - fi) 102 - 103 - # as-option 104 - # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) 105 - 106 - as-option = $(call try-run,\ 107 - $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) 108 - 109 - # as-instr 110 - # Usage: cflags-y += $(call as-instr,instr,option1,option2) 111 - 112 - as-instr = $(call try-run,\ 113 - printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) 114 - 115 - # __cc-option 116 - # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586) 117 - __cc-option = $(call try-run,\ 118 - $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) 119 - 120 - # cc-option 121 - # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) 122 - 123 - cc-option = $(call __cc-option, $(CC),\ 124 - $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2)) 125 - 126 - # cc-option-yn 127 - # Usage: flag := $(call cc-option-yn,-march=winchip-c6) 128 - cc-option-yn = $(call try-run,\ 129 - $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) 130 - 131 - # cc-disable-warning 132 - # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) 133 - cc-disable-warning = $(call try-run,\ 134 - $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) 135 - 136 - # cc-ifversion 137 - # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) 138 - cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4)) 139 - 140 - # ld-option 141 - # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) 142 - ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3)) 143 - 144 - # ld-ifversion 145 - # Usage: $(call ld-ifversion, -ge, 22252, y) 146 - ld-ifversion = $(shell [ $(CONFIG_LD_VERSION)0 $(1) $(2)0 ] && echo $(3) || echo $(4)) 147 - 148 - ###### 149 - 150 70 ### 151 71 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= 152 72 # Usage:
+6
scripts/Kconfig.include
··· 45 45 cc-name := $(shell,set -- $(cc-info) && echo $1) 46 46 cc-version := $(shell,set -- $(cc-info) && echo $2) 47 47 48 + # Get the assembler name, version, and error out if it is not supported. 49 + as-info := $(shell,$(srctree)/scripts/as-version.sh $(CC) $(CLANG_FLAGS)) 50 + $(error-if,$(success,test -z "$(as-info)"),Sorry$(comma) this assembler is not supported.) 51 + as-name := $(shell,set -- $(as-info) && echo $1) 52 + as-version := $(shell,set -- $(as-info) && echo $2) 53 + 48 54 # Get the linker name, version, and error out if it is not supported. 49 55 ld-info := $(shell,$(srctree)/scripts/ld-version.sh $(LD)) 50 56 $(error-if,$(success,test -z "$(ld-info)"),Sorry$(comma) this linker is not supported.)
+2 -2
scripts/Makefile.asm-generic
··· 14 14 15 15 # $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case. 16 16 ifneq ($(SRCARCH),um) 17 - include $(generic)/Kbuild 17 + include $(srctree)/$(generic)/Kbuild 18 18 endif 19 19 20 - include scripts/Kbuild.include 20 + include $(srctree)/scripts/Kbuild.include 21 21 22 22 redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y)) 23 23 redundant += $(foreach f, $(generic-y), $(if $(wildcard $(srctree)/$(src)/$(f)),$(f)))
+10 -9
scripts/Makefile.build
··· 35 35 # Read auto.conf if it exists, otherwise ignore 36 36 -include include/config/auto.conf 37 37 38 - include scripts/Kbuild.include 38 + include $(srctree)/scripts/Kbuild.include 39 + include $(srctree)/scripts/Makefile.compiler 39 40 40 41 # The filename Kbuild has precedence over Makefile 41 42 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) 42 43 kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) 43 44 include $(kbuild-file) 44 45 45 - include scripts/Makefile.lib 46 + include $(srctree)/scripts/Makefile.lib 46 47 47 48 # Do not include hostprogs rules unless needed. 48 49 # $(sort ...) is used here to remove duplicated words and excessive spaces. 49 50 hostprogs := $(sort $(hostprogs)) 50 51 ifneq ($(hostprogs),) 51 - include scripts/Makefile.host 52 + include $(srctree)/scripts/Makefile.host 52 53 endif 53 54 54 55 # Do not include userprogs rules unless needed. 55 56 # $(sort ...) is used here to remove duplicated words and excessive spaces. 56 57 userprogs := $(sort $(userprogs)) 57 58 ifneq ($(userprogs),) 58 - include scripts/Makefile.userprogs 59 + include $(srctree)/scripts/Makefile.userprogs 59 60 endif 60 61 61 62 ifndef obj ··· 239 238 240 239 # Rebuild all objects when objtool changes, or is enabled/disabled. 241 240 objtool_dep = $(objtool_obj) \ 242 - $(wildcard include/config/orc/unwinder.h \ 243 - include/config/stack/validation.h) 241 + $(wildcard include/config/ORC_UNWINDER \ 242 + include/config/STACK_VALIDATION) 244 243 245 244 ifdef CONFIG_TRIM_UNUSED_KSYMS 246 245 cmd_gen_ksymdeps = \ ··· 445 444 cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) 446 445 endif 447 446 448 - $(multi-used-m): FORCE 447 + $(multi-obj-m): FORCE 449 448 $(call if_changed,link_multi-m) 450 - $(call multi_depend, $(multi-used-m), .o, -objs -y -m) 449 + $(call multi_depend, $(multi-obj-m), .o, -objs -y -m) 451 450 452 - targets += $(multi-used-m) 451 + targets += $(multi-obj-m) 453 452 targets := $(filter-out $(PHONY), $(targets)) 454 453 455 454 # Add intermediate targets:
+1 -1
scripts/Makefile.clean
··· 8 8 PHONY := __clean 9 9 __clean: 10 10 11 - include scripts/Kbuild.include 11 + include $(srctree)/scripts/Kbuild.include 12 12 13 13 # The filename Kbuild has precedence over Makefile 14 14 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
+74
scripts/Makefile.compiler
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + # cc-cross-prefix 4 + # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) 5 + # Return first <prefix> where a <prefix>gcc is found in PATH. 6 + # If no gcc found in PATH with listed prefixes return nothing 7 + # 8 + # Note: '2>/dev/null' is here to force Make to invoke a shell. Otherwise, it 9 + # would try to directly execute the shell builtin 'command'. This workaround 10 + # should be kept for a long time since this issue was fixed only after the 11 + # GNU Make 4.2.1 release. 12 + cc-cross-prefix = $(firstword $(foreach c, $(1), \ 13 + $(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c)))) 14 + 15 + # output directory for tests below 16 + TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$ 17 + 18 + # try-run 19 + # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) 20 + # Exit code chooses option. "$$TMP" serves as a temporary file and is 21 + # automatically cleaned up. 22 + try-run = $(shell set -e; \ 23 + TMP=$(TMPOUT)/tmp; \ 24 + mkdir -p $(TMPOUT); \ 25 + trap "rm -rf $(TMPOUT)" EXIT; \ 26 + if ($(1)) >/dev/null 2>&1; \ 27 + then echo "$(2)"; \ 28 + else echo "$(3)"; \ 29 + fi) 30 + 31 + # as-option 32 + # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) 33 + 34 + as-option = $(call try-run,\ 35 + $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) 36 + 37 + # as-instr 38 + # Usage: cflags-y += $(call as-instr,instr,option1,option2) 39 + 40 + as-instr = $(call try-run,\ 41 + printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) 42 + 43 + # __cc-option 44 + # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586) 45 + __cc-option = $(call try-run,\ 46 + $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) 47 + 48 + # cc-option 49 + # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) 50 + 51 + cc-option = $(call __cc-option, $(CC),\ 52 + $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2)) 53 + 54 + # cc-option-yn 55 + # Usage: flag := $(call cc-option-yn,-march=winchip-c6) 56 + cc-option-yn = $(call try-run,\ 57 + $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) 58 + 59 + # cc-disable-warning 60 + # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) 61 + cc-disable-warning = $(call try-run,\ 62 + $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) 63 + 64 + # cc-ifversion 65 + # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) 66 + cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4)) 67 + 68 + # ld-option 69 + # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) 70 + ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3)) 71 + 72 + # ld-ifversion 73 + # Usage: $(call ld-ifversion, -ge, 22252, y) 74 + ld-ifversion = $(shell [ $(CONFIG_LD_VERSION)0 $(1) $(2)0 ] && echo $(3) || echo $(4))
+1 -1
scripts/Makefile.dtbinst
··· 14 14 __dtbs_install: 15 15 16 16 include include/config/auto.conf 17 - include scripts/Kbuild.include 17 + include $(srctree)/scripts/Kbuild.include 18 18 include $(src)/Makefile 19 19 20 20 dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-)))
+1 -1
scripts/Makefile.headersinst
··· 12 12 PHONY := __headers 13 13 __headers: 14 14 15 - include scripts/Kbuild.include 15 + include $(srctree)/scripts/Kbuild.include 16 16 17 17 src := $(srctree)/$(obj) 18 18 gen := $(objtree)/$(subst include/,include/generated/,$(obj))
+8 -8
scripts/Makefile.lib
··· 45 45 endif 46 46 47 47 # Expand $(foo-objs) $(foo-y) by calling $(call suffix-search,foo.o,-objs -y) 48 - suffix-search = $(foreach s,$(2),$($(1:.o=$s))) 48 + suffix-search = $(strip $(foreach s, $2, $($(1:.o=$s)))) 49 49 # If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object 50 - multi-search = $(sort $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)), $(m)))) 51 - multi-used-y := $(call multi-search,$(obj-y),-objs -y) 52 - multi-used-m := $(call multi-search,$(obj-m),-objs -y -m) 53 - multi-used := $(multi-used-y) $(multi-used-m) 50 + multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $m))) 51 + multi-obj-y := $(call multi-search,$(obj-y),-objs -y) 52 + multi-obj-m := $(call multi-search,$(obj-m),-objs -y -m) 53 + multi-obj-ym := $(multi-obj-y) $(multi-obj-m) 54 54 55 55 # Replace multi-part objects by their individual parts, 56 56 # including built-in.a from subdirectories 57 - real-search = $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)),$(call suffix-search,$(m),$(2)),$(m))) 57 + real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $(call suffix-search, $m, $2), $m)) 58 58 real-obj-y := $(call real-search, $(obj-y),-objs -y) 59 59 real-obj-m := $(call real-search, $(obj-m),-objs -y -m) 60 60 ··· 104 104 lib-y := $(addprefix $(obj)/,$(lib-y)) 105 105 real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) 106 106 real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) 107 - multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) 107 + multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m)) 108 108 subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) 109 109 110 110 # Finds the multi-part object the current object will be linked into. 111 111 # If the object belongs to two or more multi-part objects, list them all. 112 - modname-multi = $(sort $(foreach m,$(multi-used),\ 112 + modname-multi = $(sort $(foreach m,$(multi-obj-ym),\ 113 113 $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))) 114 114 115 115 __modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
+96 -17
scripts/Makefile.modinst
··· 6 6 PHONY := __modinst 7 7 __modinst: 8 8 9 - include scripts/Kbuild.include 9 + include include/config/auto.conf 10 + include $(srctree)/scripts/Kbuild.include 10 11 11 - modules := $(sort $(shell cat $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order)) 12 + modules := $(sort $(shell cat $(MODORDER))) 12 13 13 - PHONY += $(modules) 14 + ifeq ($(KBUILD_EXTMOD),) 15 + dst := $(MODLIB)/kernel 16 + else 17 + INSTALL_MOD_DIR ?= extra 18 + dst := $(MODLIB)/$(INSTALL_MOD_DIR) 19 + endif 20 + 21 + suffix-y := 22 + suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz 23 + suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz 24 + suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst 25 + 26 + modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules)) 27 + 14 28 __modinst: $(modules) 15 29 @: 16 30 17 - # Don't stop modules_install if we can't sign external modules. 18 - quiet_cmd_modules_install = INSTALL $@ 19 - cmd_modules_install = \ 20 - mkdir -p $(2) ; \ 21 - cp $@ $(2) ; \ 22 - $(mod_strip_cmd) $(2)/$(notdir $@) ; \ 23 - $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) ; \ 24 - $(mod_compress_cmd) $(2)/$(notdir $@) 31 + quiet_cmd_none = 32 + cmd_none = : 25 33 26 - # Modules built outside the kernel source tree go into extra by default 27 - INSTALL_MOD_DIR ?= extra 28 - ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) 34 + # 35 + # Installation 36 + # 37 + quiet_cmd_install = INSTALL $@ 38 + cmd_install = mkdir -p $(dir $@); cp $< $@ 29 39 30 - modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) 40 + # Strip 41 + # 42 + # INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they 43 + # are installed. If INSTALL_MOD_STRIP is '1', then the default option 44 + # --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used 45 + # as the options to the strip command. 46 + ifdef INSTALL_MOD_STRIP 31 47 32 - $(modules): 33 - $(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) 48 + ifeq ($(INSTALL_MOD_STRIP),1) 49 + strip-option := --strip-debug 50 + else 51 + strip-option := $(INSTALL_MOD_STRIP) 52 + endif 53 + 54 + quiet_cmd_strip = STRIP $@ 55 + cmd_strip = $(STRIP) $(strip-option) $@ 56 + 57 + else 58 + 59 + quiet_cmd_strip = 60 + cmd_strip = : 61 + 62 + endif 63 + 64 + # 65 + # Signing 66 + # Don't stop modules_install even if we can't sign external modules. 67 + # 68 + ifeq ($(CONFIG_MODULE_SIG_ALL),y) 69 + quiet_cmd_sign = SIGN $@ 70 + $(eval $(call config_filename,MODULE_SIG_KEY)) 71 + cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509 $@ \ 72 + $(if $(KBUILD_EXTMOD),|| true) 73 + else 74 + quiet_cmd_sign := 75 + cmd_sign := : 76 + endif 77 + 78 + ifeq ($(modules_sign_only),) 79 + 80 + $(dst)/%.ko: $(extmod_prefix)%.ko FORCE 81 + $(call cmd,install) 82 + $(call cmd,strip) 83 + $(call cmd,sign) 84 + 85 + else 86 + 87 + $(dst)/%.ko: FORCE 88 + $(call cmd,sign) 89 + 90 + endif 91 + 92 + # 93 + # Compression 94 + # 95 + quiet_cmd_gzip = GZIP $@ 96 + cmd_gzip = $(KGZIP) -n -f $< 97 + quiet_cmd_xz = XZ $@ 98 + cmd_xz = $(XZ) --lzma2=dict=2MiB -f $< 99 + quiet_cmd_zstd = ZSTD $@ 100 + cmd_zstd = $(ZSTD) -T0 --rm -f -q $< 101 + 102 + $(dst)/%.ko.gz: $(dst)/%.ko FORCE 103 + $(call cmd,gzip) 104 + 105 + $(dst)/%.ko.xz: $(dst)/%.ko FORCE 106 + $(call cmd,xz) 107 + 108 + $(dst)/%.ko.zst: $(dst)/%.ko FORCE 109 + $(call cmd,zstd) 110 + 111 + PHONY += FORCE 112 + FORCE: 34 113 35 114 .PHONY: $(PHONY)
+25 -7
scripts/Makefile.modpost
··· 32 32 # Step 4 is solely used to allow module versioning in external modules, 33 33 # where the CRC of each module is retrieved from the Module.symvers file. 34 34 35 - # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined 36 - # symbols in the final module linking stage 37 35 # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. 38 36 # This is solely useful to speed up test compiles 39 37 ··· 39 41 __modpost: 40 42 41 43 include include/config/auto.conf 42 - include scripts/Kbuild.include 44 + include $(srctree)/scripts/Kbuild.include 43 45 44 46 # for ld_flags 45 - include scripts/Makefile.lib 47 + include $(srctree)/scripts/Makefile.lib 46 48 47 49 MODPOST = scripts/mod/modpost \ 48 50 $(if $(CONFIG_MODVERSIONS),-m) \ 49 51 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ 50 52 $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ 51 - $(if $(KBUILD_MODPOST_WARN),-w) \ 52 53 -o $@ 53 54 54 55 ifdef MODPOST_VMLINUX ··· 65 68 ifeq ($(KBUILD_EXTMOD),) 66 69 67 70 input-symdump := vmlinux.symvers 68 - output-symdump := Module.symvers 71 + output-symdump := modules-only.symvers 72 + 73 + quiet_cmd_cat = GEN $@ 74 + cmd_cat = cat $(real-prereqs) > $@ 75 + 76 + ifneq ($(wildcard vmlinux.symvers),) 77 + 78 + __modpost: Module.symvers 79 + Module.symvers: vmlinux.symvers modules-only.symvers FORCE 80 + $(call if_changed,cat) 81 + 82 + targets += Module.symvers 83 + 84 + endif 69 85 70 86 else 71 87 ··· 98 88 99 89 endif 100 90 91 + existing-input-symdump := $(wildcard $(input-symdump)) 92 + 101 93 # modpost options for modules (both in-kernel and external) 102 94 MODPOST += \ 103 - $(addprefix -i ,$(wildcard $(input-symdump))) \ 95 + $(addprefix -i ,$(existing-input-symdump)) \ 104 96 $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \ 105 97 $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) 106 98 ··· 116 104 $(input-symdump): 117 105 @echo >&2 'WARNING: Symbol version dump "$@" is missing.' 118 106 @echo >&2 ' Modules may not have dependencies or modversions.' 107 + @echo >&2 ' You may get many unresolved symbol warnings.' 119 108 120 109 ifdef CONFIG_LTO_CLANG 121 110 # With CONFIG_LTO_CLANG, .o files might be LLVM bitcode, so we need to run ··· 135 122 endif 136 123 137 124 modules := $(sort $(shell cat $(MODORDER))) 125 + 126 + # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined symbols 127 + ifneq ($(KBUILD_MODPOST_WARN)$(filter-out $(existing-input-symdump), $(input-symdump)),) 128 + MODPOST += -w 129 + endif 138 130 139 131 # Read out modules.order to pass in modpost. 140 132 # Otherwise, allmodconfig would fail with "Argument list too long".
-29
scripts/Makefile.modsign
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - # ========================================================================== 3 - # Signing modules 4 - # ========================================================================== 5 - 6 - PHONY := __modsign 7 - __modsign: 8 - 9 - include scripts/Kbuild.include 10 - 11 - modules := $(sort $(shell cat modules.order)) 12 - 13 - PHONY += $(modules) 14 - __modsign: $(modules) 15 - @: 16 - 17 - quiet_cmd_sign_ko = SIGN [M] $(2)/$(notdir $@) 18 - cmd_sign_ko = $(mod_sign_cmd) $(2)/$(notdir $@) 19 - 20 - # Modules built outside the kernel source tree go into extra by default 21 - INSTALL_MOD_DIR ?= extra 22 - ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) 23 - 24 - modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) 25 - 26 - $(modules): 27 - $(call cmd,sign_ko,$(MODLIB)/$(modinst_dir)) 28 - 29 - .PHONY: $(PHONY)
+1 -1
scripts/Makefile.package
··· 25 25 26 26 # Remove hyphens since they have special meaning in RPM filenames 27 27 KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) 28 - KDEB_SOURCENAME ?= linux-$(KERNELRELEASE) 28 + KDEB_SOURCENAME ?= linux-upstream 29 29 KBUILD_PKG_ROOTCMD ?="fakeroot -u" 30 30 export KDEB_SOURCENAME 31 31 # Include only those top-level files that are needed by make, plus the GPL copy
+82
scripts/as-version.sh
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0-only 3 + # 4 + # Print the assembler name and its version in a 5 or 6-digit form. 5 + # Also, perform the minimum version check. 6 + # (If it is the integrated assembler, return 0 as the version, and 7 + # skip the version check.) 8 + 9 + set -e 10 + 11 + # Convert the version string x.y.z to a canonical 5 or 6-digit form. 12 + get_canonical_version() 13 + { 14 + IFS=. 15 + set -- $1 16 + 17 + # If the 2nd or 3rd field is missing, fill it with a zero. 18 + # 19 + # The 4th field, if present, is ignored. 20 + # This occurs in development snapshots as in 2.35.1.20201116 21 + echo $((10000 * $1 + 100 * ${2:-0} + ${3:-0})) 22 + } 23 + 24 + # Clang fails to handle -Wa,--version unless -no-integrated-as is given. 25 + # We check -(f)integrated-as, expecting it is explicitly passed in for the 26 + # integrated assembler case. 27 + check_integrated_as() 28 + { 29 + while [ $# -gt 0 ]; do 30 + if [ "$1" = -integrated-as -o "$1" = -fintegrated-as ]; then 31 + # For the intergrated assembler, we do not check the 32 + # version here. It is the same as the clang version, and 33 + # it has been already checked by scripts/cc-version.sh. 34 + echo LLVM 0 35 + exit 0 36 + fi 37 + shift 38 + done 39 + } 40 + 41 + check_integrated_as "$@" 42 + 43 + orig_args="$@" 44 + 45 + # Get the first line of the --version output. 46 + IFS=' 47 + ' 48 + set -- $(LC_ALL=C "$@" -Wa,--version -c -x assembler /dev/null -o /dev/null 2>/dev/null) 49 + 50 + # Split the line on spaces. 51 + IFS=' ' 52 + set -- $1 53 + 54 + min_tool_version=$(dirname $0)/min-tool-version.sh 55 + 56 + if [ "$1" = GNU -a "$2" = assembler ]; then 57 + shift $(($# - 1)) 58 + version=$1 59 + min_version=$($min_tool_version binutils) 60 + name=GNU 61 + else 62 + echo "$orig_args: unknown assembler invoked" >&2 63 + exit 1 64 + fi 65 + 66 + # Some distributions append a package release number, as in 2.34-4.fc32 67 + # Trim the hyphen and any characters that follow. 68 + version=${version%-*} 69 + 70 + cversion=$(get_canonical_version $version) 71 + min_cversion=$(get_canonical_version $min_version) 72 + 73 + if [ "$cversion" -lt "$min_cversion" ]; then 74 + echo >&2 "***" 75 + echo >&2 "*** Assembler is too old." 76 + echo >&2 "*** Your $name assembler version: $version" 77 + echo >&2 "*** Minimum $name assembler version: $min_version" 78 + echo >&2 "***" 79 + exit 1 80 + fi 81 + 82 + echo $name $cversion
+6 -37
scripts/basic/fixdep.c
··· 34 34 * the config symbols are rebuilt. 35 35 * 36 36 * So if the user changes his CONFIG_HIS_DRIVER option, only the objects 37 - * which depend on "include/config/his/driver.h" will be rebuilt, 37 + * which depend on "include/config/HIS_DRIVER" will be rebuilt, 38 38 * so most likely only his driver ;-) 39 39 * 40 40 * The idea above dates, by the way, back to Michael E Chastain, AFAIK. ··· 74 74 * 75 75 * and then basically copies the .<target>.d file to stdout, in the 76 76 * process filtering out the dependency on autoconf.h and adding 77 - * dependencies on include/config/my/option.h for every 77 + * dependencies on include/config/MY_OPTION for every 78 78 * CONFIG_MY_OPTION encountered in any of the prerequisites. 79 79 * 80 80 * We don't even try to really parse the header files, but ··· 107 107 108 108 /* 109 109 * In the intended usage of this program, the stdout is redirected to .*.cmd 110 - * files. The return value of printf() and putchar() must be checked to catch 111 - * any error, e.g. "No space left on device". 110 + * files. The return value of printf() must be checked to catch any error, 111 + * e.g. "No space left on device". 112 112 */ 113 113 static void xprintf(const char *format, ...) 114 114 { ··· 122 122 exit(1); 123 123 } 124 124 va_end(ap); 125 - } 126 - 127 - static void xputchar(int c) 128 - { 129 - int ret; 130 - 131 - ret = putchar(c); 132 - if (ret == EOF) { 133 - perror("fixdep"); 134 - exit(1); 135 - } 136 - } 137 - 138 - /* 139 - * Print out a dependency path from a symbol name 140 - */ 141 - static void print_dep(const char *m, int slen, const char *dir) 142 - { 143 - int c, prev_c = '/', i; 144 - 145 - xprintf(" $(wildcard %s/", dir); 146 - for (i = 0; i < slen; i++) { 147 - c = m[i]; 148 - if (c == '_') 149 - c = '/'; 150 - else 151 - c = tolower(c); 152 - if (c != '/' || prev_c != '/') 153 - xputchar(c); 154 - prev_c = c; 155 - } 156 - xprintf(".h) \\\n"); 157 125 } 158 126 159 127 struct item { ··· 188 220 return; 189 221 190 222 define_config(m, slen, hash); 191 - print_dep(m, slen, "include/config"); 223 + /* Print out a dependency path from a symbol name. */ 224 + xprintf(" $(wildcard include/config/%.*s) \\\n", slen, m); 192 225 } 193 226 194 227 /* test if s ends in sub */
+5 -15
scripts/cc-version.sh
··· 6 6 7 7 set -e 8 8 9 - # When you raise the minimum compiler version, please update 10 - # Documentation/process/changes.rst as well. 11 - gcc_min_version=4.9.0 12 - clang_min_version=10.0.1 13 - icc_min_version=16.0.3 # temporary 14 - 15 - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293 16 - # https://lore.kernel.org/r/20210107111841.GN1551@shell.armlinux.org.uk 17 - if [ "$SRCARCH" = arm64 ]; then 18 - gcc_min_version=5.1.0 19 - fi 20 - 21 9 # Print the compiler name and some version components. 22 10 get_compiler_info() 23 11 { ··· 36 48 37 49 name=$1 38 50 51 + min_tool_version=$(dirname $0)/min-tool-version.sh 52 + 39 53 case "$name" in 40 54 GCC) 41 55 version=$2.$3.$4 42 - min_version=$gcc_min_version 56 + min_version=$($min_tool_version gcc) 43 57 ;; 44 58 Clang) 45 59 version=$2.$3.$4 46 - min_version=$clang_min_version 60 + min_version=$($min_tool_version llvm) 47 61 ;; 48 62 ICC) 49 63 version=$(($2 / 100)).$(($2 % 100)).$3 50 - min_version=$icc_min_version 64 + min_version=$($min_tool_version icc) 51 65 ;; 52 66 *) 53 67 echo "$orig_args: unknown compiler" >&2
+6
scripts/dummy-tools/gcc
··· 67 67 fi 68 68 fi 69 69 70 + # To set CONFIG_AS_IS_GNU 71 + if arg_contain -Wa,--version "$@"; then 72 + echo "GNU assembler (scripts/dummy-tools) 2.50" 73 + exit 0 74 + fi 75 + 70 76 if arg_contain -S "$@"; then 71 77 # For scripts/gcc-x86-*-has-stack-protector.sh 72 78 if arg_contain -fstack-protector "$@"; then
+5 -10
scripts/kconfig/confdata.c
··· 130 130 static int conf_touch_dep(const char *name) 131 131 { 132 132 int fd, ret; 133 - const char *s; 134 - char *d, c; 133 + char *d; 135 134 136 - /* check overflow: prefix + name + ".h" + '\0' must fit in buffer. */ 137 - if (depfile_prefix_len + strlen(name) + 3 > sizeof(depfile_path)) 135 + /* check overflow: prefix + name + '\0' must fit in buffer. */ 136 + if (depfile_prefix_len + strlen(name) + 1 > sizeof(depfile_path)) 138 137 return -1; 139 138 140 139 d = depfile_path + depfile_prefix_len; 141 - s = name; 142 - 143 - while ((c = *s++)) 144 - *d++ = (c == '_') ? '/' : tolower(c); 145 - strcpy(d, ".h"); 140 + strcpy(d, name); 146 141 147 142 /* Assume directory path already exists. */ 148 143 fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644); ··· 460 465 * Reading from include/config/auto.conf 461 466 * If CONFIG_FOO previously existed in 462 467 * auto.conf but it is missing now, 463 - * include/config/foo.h must be touched. 468 + * include/config/FOO must be touched. 464 469 */ 465 470 conf_touch_dep(line + strlen(CONFIG_)); 466 471 else
+4 -7
scripts/ld-version.sh
··· 6 6 7 7 set -e 8 8 9 - # When you raise the minimum linker version, please update 10 - # Documentation/process/changes.rst as well. 11 - bfd_min_version=2.23.0 12 - lld_min_version=10.0.1 13 - 14 9 # Convert the version string x.y.z to a canonical 5 or 6-digit form. 15 10 get_canonical_version() 16 11 { ··· 30 35 IFS=' ' 31 36 set -- $1 32 37 38 + min_tool_version=$(dirname $0)/min-tool-version.sh 39 + 33 40 if [ "$1" = GNU -a "$2" = ld ]; then 34 41 shift $(($# - 1)) 35 42 version=$1 36 - min_version=$bfd_min_version 43 + min_version=$($min_tool_version binutils) 37 44 name=BFD 38 45 disp_name="GNU ld" 39 46 elif [ "$1" = GNU -a "$2" = gold ]; then ··· 48 51 49 52 if [ "$1" = LLD ]; then 50 53 version=$2 51 - min_version=$lld_min_version 54 + min_version=$($min_tool_version llvm) 52 55 name=LLD 53 56 disp_name=LLD 54 57 else
+39
scripts/min-tool-version.sh
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0-only 3 + # 4 + # Print the minimum supported version of the given tool. 5 + # When you raise the minimum version, please update 6 + # Documentation/process/changes.rst as well. 7 + 8 + set -e 9 + 10 + if [ $# != 1 ]; then 11 + echo "Usage: $0 toolname" >&2 12 + exit 1 13 + fi 14 + 15 + case "$1" in 16 + binutils) 17 + echo 2.23.0 18 + ;; 19 + gcc) 20 + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293 21 + # https://lore.kernel.org/r/20210107111841.GN1551@shell.armlinux.org.uk 22 + if [ "$SRCARCH" = arm64 ]; then 23 + echo 5.1.0 24 + else 25 + echo 4.9.0 26 + fi 27 + ;; 28 + icc) 29 + # temporary 30 + echo 16.0.3 31 + ;; 32 + llvm) 33 + echo 10.0.1 34 + ;; 35 + *) 36 + echo "$1: unknown tool" >&2 37 + exit 1 38 + ;; 39 + esac
+19 -31
scripts/mod/modpost.c
··· 23 23 24 24 /* Are we using CONFIG_MODVERSIONS? */ 25 25 static int modversions = 0; 26 - /* Warn about undefined symbols? (do so if we have vmlinux) */ 27 - static int have_vmlinux = 0; 28 26 /* Is CONFIG_MODULE_SRCVERSION_ALL set? */ 29 27 static int all_versions = 0; 30 28 /* If we are modposting external module set to 1 */ ··· 38 40 static int allow_missing_ns_imports; 39 41 40 42 static bool error_occurred; 43 + 44 + /* 45 + * Cut off the warnings when there are too many. This typically occurs when 46 + * vmlinux is missing. ('make modules' without building vmlinux.) 47 + */ 48 + #define MAX_UNRESOLVED_REPORTS 10 49 + static unsigned int nr_unresolved; 41 50 42 51 enum export { 43 52 export_plain, ··· 182 177 mod->next = modules; 183 178 modules = mod; 184 179 185 - if (mod->is_vmlinux) 186 - have_vmlinux = 1; 187 - 188 180 return mod; 189 181 } 190 182 ··· 204 202 205 203 static struct symbol *symbolhash[SYMBOL_HASH_SIZE]; 206 204 207 - /* This is based on the hash agorithm from gdbm, via tdb */ 205 + /* This is based on the hash algorithm from gdbm, via tdb */ 208 206 static inline unsigned int tdb_hash(const char *name) 209 207 { 210 208 unsigned value; /* Used to compute the hash value. */ ··· 987 985 }; 988 986 989 987 /** 990 - * Describe how to match sections on different criterias: 988 + * Describe how to match sections on different criteria: 991 989 * 992 990 * @fromsec: Array of sections to be matched. 993 991 * ··· 995 993 * this array is forbidden (black-list). Can be empty. 996 994 * 997 995 * @good_tosec: Relocations applied to a section in @fromsec must be 998 - * targetting sections in this array (white-list). Can be empty. 996 + * targeting sections in this array (white-list). Can be empty. 999 997 * 1000 998 * @mismatch: Type of mismatch. 1001 999 * 1002 1000 * @symbol_white_list: Do not match a relocation to a symbol in this list 1003 - * even if it is targetting a section in @bad_to_sec. 1001 + * even if it is targeting a section in @bad_to_sec. 1004 1002 * 1005 1003 * @handler: Specific handler to call when a match is found. If NULL, 1006 1004 * default_mismatch_handler() will be called. ··· 2143 2141 const char *basename; 2144 2142 exp = find_symbol(s->name); 2145 2143 if (!exp || exp->module == mod) { 2146 - if (have_vmlinux && !s->weak) 2144 + if (!s->weak && nr_unresolved++ < MAX_UNRESOLVED_REPORTS) 2147 2145 modpost_log(warn_unresolved ? LOG_WARN : LOG_ERROR, 2148 2146 "\"%s\" [%s.ko] undefined!\n", 2149 2147 s->name, mod->name); ··· 2193 2191 */ 2194 2192 buf_printf(b, "#define INCLUDE_VERMAGIC\n"); 2195 2193 buf_printf(b, "#include <linux/build-salt.h>\n"); 2194 + buf_printf(b, "#include <linux/elfnote-lto.h>\n"); 2196 2195 buf_printf(b, "#include <linux/vermagic.h>\n"); 2197 2196 buf_printf(b, "#include <linux/compiler.h>\n"); 2198 2197 buf_printf(b, "\n"); 2199 2198 buf_printf(b, "BUILD_SALT;\n"); 2199 + buf_printf(b, "BUILD_LTO_INFO;\n"); 2200 2200 buf_printf(b, "\n"); 2201 2201 buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n"); 2202 2202 buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n"); ··· 2427 2423 fatal("parse error in symbol dump file\n"); 2428 2424 } 2429 2425 2430 - /* For normal builds always dump all symbols. 2431 - * For external modules only dump symbols 2432 - * that are not read from kernel Module.symvers. 2433 - **/ 2434 - static int dump_sym(struct symbol *sym) 2435 - { 2436 - if (!external_module) 2437 - return 1; 2438 - if (sym->module->from_dump) 2439 - return 0; 2440 - return 1; 2441 - } 2442 - 2443 2426 static void write_dump(const char *fname) 2444 2427 { 2445 2428 struct buffer buf = { }; ··· 2437 2446 for (n = 0; n < SYMBOL_HASH_SIZE ; n++) { 2438 2447 symbol = symbolhash[n]; 2439 2448 while (symbol) { 2440 - if (dump_sym(symbol)) { 2449 + if (!symbol->module->from_dump) { 2441 2450 namespace = symbol->namespace; 2442 2451 buf_printf(&buf, "0x%08x\t%s\t%s\t%s\t%s\n", 2443 2452 symbol->crc, symbol->name, ··· 2549 2558 if (files_source) 2550 2559 read_symbols_from_files(files_source); 2551 2560 2552 - /* 2553 - * When there's no vmlinux, don't print warnings about 2554 - * unresolved symbols (since there'll be too many ;) 2555 - */ 2556 - if (!have_vmlinux) 2557 - warn("Symbol info of vmlinux is missing. Unresolved symbol check will be entirely skipped.\n"); 2558 - 2559 2561 for (mod = modules; mod; mod = mod->next) { 2560 2562 char fname[PATH_MAX]; 2561 2563 ··· 2591 2607 export_str(s->export)); 2592 2608 } 2593 2609 } 2610 + 2611 + if (nr_unresolved > MAX_UNRESOLVED_REPORTS) 2612 + warn("suppressed %u unresolved symbol warnings because there were too many)\n", 2613 + nr_unresolved - MAX_UNRESOLVED_REPORTS); 2594 2614 2595 2615 free(buf.p); 2596 2616
+2 -2
scripts/modules-check.sh
··· 13 13 # Check uniqueness of module names 14 14 check_same_name_modules() 15 15 { 16 - for m in $(sed 's:.*/::' $1 | sort | uniq -d) 16 + for m in $(sed 's:.*/::' "$1" | sort | uniq -d) 17 17 do 18 18 echo "error: the following would cause module name conflict:" >&2 19 - sed -n "/\/$m/s:^: :p" modules.order >&2 19 + sed -n "/\/$m/s:^: :p" "$1" >&2 20 20 exit_code=1 21 21 done 22 22 }
-8
scripts/test_dwarf5_support.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - # Test that the assembler doesn't need -Wa,-gdwarf-5 when presented with DWARF 5 - # v5 input, such as `.file 0` and `md5 0x00`. Should be fixed in GNU binutils 6 - # 2.35.2. https://sourceware.org/bugzilla/show_bug.cgi?id=25611 7 - echo '.file 0 "filename" md5 0x7a0b65214090b6693bd1dc24dd248245' | \ 8 - $* -gdwarf-5 -Wno-unused-command-line-argument -c -x assembler -o /dev/null -
+24
tools/build/Build.include
··· 100 100 ## HOSTCC C flags 101 101 102 102 host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(KBUILD_HOSTCFLAGS) -D"BUILD_STR(s)=\#s" $(HOSTCFLAGS_$(basetarget).o) $(HOSTCFLAGS_$(obj)) 103 + 104 + # output directory for tests below 105 + TMPOUT = .tmp_$$$$ 106 + 107 + # try-run 108 + # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) 109 + # Exit code chooses option. "$$TMP" serves as a temporary file and is 110 + # automatically cleaned up. 111 + try-run = $(shell set -e; \ 112 + TMP=$(TMPOUT)/tmp; \ 113 + mkdir -p $(TMPOUT); \ 114 + trap "rm -rf $(TMPOUT)" EXIT; \ 115 + if ($(1)) >/dev/null 2>&1; \ 116 + then echo "$(2)"; \ 117 + else echo "$(3)"; \ 118 + fi) 119 + 120 + # cc-option 121 + # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) 122 + cc-option = $(call try-run, \ 123 + $(CC) -Werror $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) 124 + 125 + # delete partially updated (i.e. corrupted) files on error 126 + .DELETE_ON_ERROR:
+1 -1
tools/testing/selftests/bpf/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - include ../../../../scripts/Kbuild.include 2 + include ../../../build/Build.include 3 3 include ../../../scripts/Makefile.arch 4 4 include ../../../scripts/Makefile.include 5 5
+1 -1
tools/testing/selftests/kvm/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 - include ../../../../scripts/Kbuild.include 2 + include ../../../build/Build.include 3 3 4 4 all: 5 5
+1 -1
tools/testing/selftests/powerpc/pmu/ebb/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - include ../../../../../../scripts/Kbuild.include 2 + include ../../../../../build/Build.include 3 3 4 4 noarg: 5 5 $(MAKE) -C ../../
+1 -1
tools/thermal/tmon/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # We need this for the "cc-option" macro. 3 - include ../../../scripts/Kbuild.include 3 + include ../../build/Build.include 4 4 5 5 VERSION = 1.0 6 6