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

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

Pull Kbuild updates from Masahiro Yamada:

- Support 'make compile_commands.json' to generate the compilation
database more easily, avoiding stale entries

- Support 'make clang-analyzer' and 'make clang-tidy' for static checks
using clang-tidy

- Preprocess scripts/modules.lds.S to allow CONFIG options in the
module linker script

- Drop cc-option tests from compiler flags supported by our minimal
GCC/Clang versions

- Use always 12-digits commit hash for CONFIG_LOCALVERSION_AUTO=y

- Use sha1 build id for both BFD linker and LLD

- Improve deb-pkg for reproducible builds and rootless builds

- Remove stale, useless scripts/namespace.pl

- Turn -Wreturn-type warning into error

- Fix build error of deb-pkg when CONFIG_MODULES=n

- Replace 'hostname' command with more portable 'uname -n'

- Various Makefile cleanups

* tag 'kbuild-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (34 commits)
kbuild: Use uname for LINUX_COMPILE_HOST detection
kbuild: Only add -fno-var-tracking-assignments for old GCC versions
kbuild: remove leftover comment for filechk utility
treewide: remove DISABLE_LTO
kbuild: deb-pkg: clean up package name variables
kbuild: deb-pkg: do not build linux-headers package if CONFIG_MODULES=n
kbuild: enforce -Werror=return-type
scripts: remove namespace.pl
builddeb: Add support for all required debian/rules targets
builddeb: Enable rootless builds
builddeb: Pass -n to gzip for reproducible packages
kbuild: split the build log of kallsyms
kbuild: explicitly specify the build id style
scripts/setlocalversion: make git describe output more reliable
kbuild: remove cc-option test of -Werror=date-time
kbuild: remove cc-option test of -fno-stack-check
kbuild: remove cc-option test of -fno-strict-overflow
kbuild: move CFLAGS_{KASAN,UBSAN,KCSAN} exports to relevant Makefiles
kbuild: remove redundant CONFIG_KASAN check from scripts/Makefile.kasan
kbuild: do not create built-in objects for external module builds
...

+511 -751
+1 -2
Documentation/process/submit-checklist.rst
··· 53 53 54 54 9) Check cleanly with sparse. 55 55 56 - 10) Use ``make checkstack`` and ``make namespacecheck`` and fix any problems 57 - that they find. 56 + 10) Use ``make checkstack`` and fix any problems that it finds. 58 57 59 58 .. note:: 60 59
+1
MAINTAINERS
··· 4273 4273 B: https://github.com/ClangBuiltLinux/linux/issues 4274 4274 C: irc://chat.freenode.net/clangbuiltlinux 4275 4275 F: Documentation/kbuild/llvm.rst 4276 + F: scripts/clang-tools/ 4276 4277 K: \b(?i:clang|llvm)\b 4277 4278 4278 4279 CLEANCACHE API
+70 -24
Makefile
··· 497 497 KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ 498 498 -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ 499 499 -Werror=implicit-function-declaration -Werror=implicit-int \ 500 - -Wno-format-security \ 500 + -Werror=return-type -Wno-format-security \ 501 501 -std=gnu89 502 502 KBUILD_CPPFLAGS := -D__KERNEL__ 503 503 KBUILD_AFLAGS_KERNEL := ··· 505 505 KBUILD_AFLAGS_MODULE := -DMODULE 506 506 KBUILD_CFLAGS_MODULE := -DMODULE 507 507 KBUILD_LDFLAGS_MODULE := 508 - export KBUILD_LDS_MODULE := $(srctree)/scripts/module-common.lds 509 508 KBUILD_LDFLAGS := 510 509 CLANG_FLAGS := 511 510 ··· 516 517 517 518 export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS 518 519 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE 519 - export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN CFLAGS_KCSAN 520 520 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE 521 521 export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE 522 522 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL ··· 632 634 # in addition to whatever we do anyway. 633 635 # Just "make" or "make all" shall build modules as well 634 636 635 - ifneq ($(filter all modules nsdeps,$(MAKECMDGOALS)),) 637 + ifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),) 636 638 KBUILD_MODULES := 1 637 639 endif 638 640 ··· 705 707 # This exploits the 'multi-target pattern rule' trick. 706 708 # The syncconfig should be executed only once to make all the targets. 707 709 # (Note: use the grouped target '&:' when we bump to GNU Make 4.3) 710 + quiet_cmd_syncconfig = SYNC $@ 711 + cmd_syncconfig = $(MAKE) -f $(srctree)/Makefile syncconfig 712 + 708 713 %/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h: $(KCONFIG_CONFIG) 709 - $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig 714 + +$(call cmd,syncconfig) 710 715 else # !may-sync-config 711 716 # External modules and some install targets need include/generated/autoconf.h 712 717 # and include/config/auto.conf but do not care if they are up-to-date. ··· 814 813 KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang 815 814 endif 816 815 817 - DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments) 816 + # Workaround for GCC versions < 5.0 817 + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801 818 + ifdef CONFIG_CC_IS_GCC 819 + DEBUG_CFLAGS := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments)) 820 + endif 818 821 819 822 ifdef CONFIG_DEBUG_INFO 823 + 820 824 ifdef CONFIG_DEBUG_INFO_SPLIT 821 825 DEBUG_CFLAGS += -gsplit-dwarf 822 826 else 823 827 DEBUG_CFLAGS += -g 824 828 endif 829 + 825 830 KBUILD_AFLAGS += -Wa,-gdwarf-2 826 - endif 831 + 827 832 ifdef CONFIG_DEBUG_INFO_DWARF4 828 833 DEBUG_CFLAGS += -gdwarf-4 829 834 endif ··· 844 837 KBUILD_AFLAGS += -gz=zlib 845 838 KBUILD_LDFLAGS += --compress-debug-sections=zlib 846 839 endif 840 + 841 + endif # CONFIG_DEBUG_INFO 847 842 848 843 KBUILD_CFLAGS += $(DEBUG_CFLAGS) 849 844 export DEBUG_CFLAGS ··· 928 919 KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) 929 920 930 921 # disable invalid "can't wrap" optimizations for signed / pointers 931 - KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) 922 + KBUILD_CFLAGS += -fno-strict-overflow 932 923 933 924 # Make sure -fstack-check isn't enabled (like gentoo apparently did) 934 - KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,) 925 + KBUILD_CFLAGS += -fno-stack-check 935 926 936 927 # conserve stack if available 937 928 KBUILD_CFLAGS += $(call cc-option,-fconserve-stack) 938 929 939 930 # Prohibit date/time macros, which would make the build non-deterministic 940 - KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) 931 + KBUILD_CFLAGS += -Werror=date-time 941 932 942 933 # enforce correct pointer usage 943 934 KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) ··· 973 964 KBUILD_AFLAGS += $(KAFLAGS) 974 965 KBUILD_CFLAGS += $(KCFLAGS) 975 966 976 - KBUILD_LDFLAGS_MODULE += --build-id 977 - LDFLAGS_vmlinux += --build-id 967 + KBUILD_LDFLAGS_MODULE += --build-id=sha1 968 + LDFLAGS_vmlinux += --build-id=sha1 978 969 979 970 ifeq ($(CONFIG_STRIP_ASM_SYMS),y) 980 971 LDFLAGS_vmlinux += $(call ld-option, -X,) ··· 1386 1377 # using awk while concatenating to the final file. 1387 1378 1388 1379 PHONY += modules 1389 - modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check 1380 + modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare 1390 1381 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1391 1382 1392 1383 PHONY += modules_check ··· 1403 1394 # Target to prepare building external modules 1404 1395 PHONY += modules_prepare 1405 1396 modules_prepare: prepare 1397 + $(Q)$(MAKE) $(build)=scripts scripts/module.lds 1406 1398 1407 1399 # Target to install modules 1408 1400 PHONY += modules_install ··· 1462 1452 1463 1453 # Directories & files removed with 'make clean' 1464 1454 CLEAN_FILES += include/ksym vmlinux.symvers \ 1465 - modules.builtin modules.builtin.modinfo modules.nsdeps 1455 + modules.builtin modules.builtin.modinfo modules.nsdeps \ 1456 + compile_commands.json 1466 1457 1467 1458 # Directories & files removed with 'make mrproper' 1468 1459 MRPROPER_FILES += include/config include/generated \ ··· 1569 1558 echo '' 1570 1559 @echo 'Static analysers:' 1571 1560 @echo ' checkstack - Generate a list of stack hogs' 1572 - @echo ' namespacecheck - Name space analysis on compiled kernel' 1573 1561 @echo ' versioncheck - Sanity check on version.h usage' 1574 1562 @echo ' includecheck - Check for duplicate included header files' 1575 1563 @echo ' export_report - List the usages of all exported symbols' 1576 1564 @echo ' headerdep - Detect inclusion cycles in headers' 1577 1565 @echo ' coccicheck - Check with Coccinelle' 1566 + @echo ' clang-analyzer - Check with clang static analyzer' 1567 + @echo ' clang-tidy - Check with clang-tidy' 1578 1568 @echo '' 1579 1569 @echo 'Tools:' 1580 1570 @echo ' nsdeps - Generate missing symbol namespace dependencies' ··· 1693 1681 # Install the modules built in the module directory 1694 1682 # Assumes install directory is already created 1695 1683 1696 - # We are always building modules 1684 + # We are always building only modules. 1685 + KBUILD_BUILTIN := 1697 1686 KBUILD_MODULES := 1 1698 1687 1699 1688 build-dirs := $(KBUILD_EXTMOD) 1700 1689 PHONY += modules 1701 - modules: descend 1690 + modules: $(MODORDER) 1702 1691 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1692 + 1693 + $(MODORDER): descend 1694 + @: 1703 1695 1704 1696 PHONY += modules_install 1705 1697 modules_install: _emodinst_ _emodinst_post ··· 1718 1702 _emodinst_post: _emodinst_ 1719 1703 $(call cmd,depmod) 1720 1704 1705 + compile_commands.json: $(extmod-prefix)compile_commands.json 1706 + PHONY += compile_commands.json 1707 + 1721 1708 clean-dirs := $(KBUILD_EXTMOD) 1722 - clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps 1709 + clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \ 1710 + $(KBUILD_EXTMOD)/compile_commands.json 1723 1711 1724 1712 PHONY += help 1725 1713 help: ··· 1735 1715 @echo ' clean - remove generated files in module directory only' 1736 1716 @echo '' 1737 1717 1738 - PHONY += prepare 1718 + # no-op for external module builds 1719 + PHONY += prepare modules_prepare 1720 + 1739 1721 endif # KBUILD_EXTMOD 1740 1722 1741 1723 # Single targets ··· 1770 1748 endif 1771 1749 1772 1750 PHONY += single_modpost 1773 - single_modpost: $(single-no-ko) 1751 + single_modpost: $(single-no-ko) modules_prepare 1774 1752 $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER) 1775 1753 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1776 1754 ··· 1838 1816 nsdeps: modules 1839 1817 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/nsdeps 1840 1818 1819 + # Clang Tooling 1820 + # --------------------------------------------------------------------------- 1821 + 1822 + quiet_cmd_gen_compile_commands = GEN $@ 1823 + cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs)) 1824 + 1825 + $(extmod-prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \ 1826 + $(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \ 1827 + $(if $(CONFIG_MODULES), $(MODORDER)) FORCE 1828 + $(call if_changed,gen_compile_commands) 1829 + 1830 + targets += $(extmod-prefix)compile_commands.json 1831 + 1832 + PHONY += clang-tidy clang-analyzer 1833 + 1834 + ifdef CONFIG_CC_IS_CLANG 1835 + quiet_cmd_clang_tools = CHECK $< 1836 + cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $< 1837 + 1838 + clang-tidy clang-analyzer: $(extmod-prefix)compile_commands.json 1839 + $(call cmd,clang_tools) 1840 + else 1841 + clang-tidy clang-analyzer: 1842 + @echo "$@ requires CC=clang" >&2 1843 + @false 1844 + endif 1845 + 1841 1846 # Scripts to check various things for consistency 1842 1847 # --------------------------------------------------------------------------- 1843 1848 1844 - PHONY += includecheck versioncheck coccicheck namespacecheck export_report 1849 + PHONY += includecheck versioncheck coccicheck export_report 1845 1850 1846 1851 includecheck: 1847 1852 find $(srctree)/* $(RCS_FIND_IGNORE) \ ··· 1882 1833 1883 1834 coccicheck: 1884 1835 $(Q)$(BASH) $(srctree)/scripts/$@ 1885 - 1886 - namespacecheck: 1887 - $(PERL) $(srctree)/scripts/namespace.pl 1888 1836 1889 1837 export_report: 1890 1838 $(PERL) $(srctree)/scripts/export_report.pl
-4
arch/arm/Makefile
··· 20 20 # linker. All sections should be explicitly named in the linker script. 21 21 LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn) 22 22 23 - ifeq ($(CONFIG_ARM_MODULE_PLTS),y) 24 - KBUILD_LDS_MODULE += $(srctree)/arch/arm/kernel/module.lds 25 - endif 26 - 27 23 GZFLAGS :=-9 28 24 #KBUILD_CFLAGS +=-pipe 29 25
+2
arch/arm/kernel/module.lds arch/arm/include/asm/module.lds.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifdef CONFIG_ARM_MODULE_PLTS 2 3 SECTIONS { 3 4 .plt : { BYTE(0) } 4 5 .init.plt : { BYTE(0) } 5 6 } 7 + #endif
+1 -1
arch/arm/vdso/Makefile
··· 19 19 ldflags-$(CONFIG_CPU_ENDIAN_BE8) := --be8 20 20 ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \ 21 21 -z max-page-size=4096 -nostdlib -shared $(ldflags-y) \ 22 - --hash-style=sysv --build-id \ 22 + --hash-style=sysv --build-id=sha1 \ 23 23 -T 24 24 25 25 obj-$(CONFIG_VDSO) += vdso.o
-4
arch/arm64/Makefile
··· 126 126 127 127 CHECKFLAGS += -D__aarch64__ 128 128 129 - ifeq ($(CONFIG_ARM64_MODULE_PLTS),y) 130 - KBUILD_LDS_MODULE += $(srctree)/arch/arm64/kernel/module.lds 131 - endif 132 - 133 129 ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_REGS),y) 134 130 KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY 135 131 CC_FLAGS_FTRACE := -fpatchable-function-entry=2
+2
arch/arm64/kernel/module.lds arch/arm64/include/asm/module.lds.h
··· 1 + #ifdef CONFIG_ARM64_MODULE_PLTS 1 2 SECTIONS { 2 3 .plt (NOLOAD) : { BYTE(0) } 3 4 .init.plt (NOLOAD) : { BYTE(0) } 4 5 .text.ftrace_trampoline (NOLOAD) : { BYTE(0) } 5 6 } 7 + #endif
+2 -3
arch/arm64/kernel/vdso/Makefile
··· 24 24 # routines, as x86 does (see 6f121e548f83 ("x86, vdso: Reimplement vdso.so 25 25 # preparation in build-time C")). 26 26 ldflags-y := -shared -nostdlib -soname=linux-vdso.so.1 --hash-style=sysv \ 27 - -Bsymbolic $(call ld-option, --no-eh-frame-hdr) --build-id -n \ 27 + -Bsymbolic $(call ld-option, --no-eh-frame-hdr) --build-id=sha1 -n \ 28 28 $(btildflags-y) -T 29 29 30 30 ccflags-y := -fno-common -fno-builtin -fno-stack-protector -ffixed-x18 31 31 ccflags-y += -DDISABLE_BRANCH_PROFILING 32 32 33 33 CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) $(GCC_PLUGINS_CFLAGS) 34 - KBUILD_CFLAGS += $(DISABLE_LTO) 35 34 KASAN_SANITIZE := n 36 35 UBSAN_SANITIZE := n 37 36 OBJECT_FILES_NON_STANDARD := y ··· 46 47 GCOV_PROFILE := n 47 48 48 49 obj-y += vdso.o 49 - extra-y += vdso.lds 50 + targets += vdso.lds 50 51 CPPFLAGS_vdso.lds += -P -C -U$(ARCH) 51 52 52 53 # Force dependency (incbin is bad)
+4 -4
arch/arm64/kernel/vdso32/Makefile
··· 90 90 # Some useful compiler-dependent flags from top-level Makefile 91 91 VDSO_CFLAGS += $(call cc32-option,-Wdeclaration-after-statement,) 92 92 VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign) 93 - VDSO_CFLAGS += $(call cc32-option,-fno-strict-overflow) 93 + VDSO_CFLAGS += -fno-strict-overflow 94 94 VDSO_CFLAGS += $(call cc32-option,-Werror=strict-prototypes) 95 - VDSO_CFLAGS += $(call cc32-option,-Werror=date-time) 95 + VDSO_CFLAGS += -Werror=date-time 96 96 VDSO_CFLAGS += $(call cc32-option,-Werror=incompatible-pointer-types) 97 97 98 98 # The 32-bit compiler does not provide 128-bit integers, which are used in ··· 128 128 VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 129 129 VDSO_LDFLAGS += -nostdlib -shared -mfloat-abi=soft 130 130 VDSO_LDFLAGS += -Wl,--hash-style=sysv 131 - VDSO_LDFLAGS += -Wl,--build-id 131 + VDSO_LDFLAGS += -Wl,--build-id=sha1 132 132 VDSO_LDFLAGS += $(call cc32-ldoption,-fuse-ld=bfd) 133 133 134 134 ··· 155 155 obj-vdso := $(c-obj-vdso) $(c-obj-vdso-gettimeofday) $(asm-obj-vdso) 156 156 157 157 obj-y += vdso.o 158 - extra-y += vdso.lds 158 + targets += vdso.lds 159 159 CPPFLAGS_vdso.lds += -P -C -U$(ARCH) 160 160 161 161 # Force dependency (vdso.s includes vdso.so through incbin)
-1
arch/ia64/Makefile
··· 20 20 21 21 OBJCOPYFLAGS := --strip-all 22 22 LDFLAGS_vmlinux := -static 23 - KBUILD_LDS_MODULE += $(srctree)/arch/ia64/module.lds 24 23 KBUILD_AFLAGS_KERNEL := -mconstant-gp 25 24 EXTRA := 26 25
arch/ia64/module.lds arch/ia64/include/asm/module.lds.h
-1
arch/m68k/Makefile
··· 75 75 endif 76 76 77 77 KBUILD_LDFLAGS := -m m68kelf 78 - KBUILD_LDS_MODULE += $(srctree)/arch/m68k/kernel/module.lds 79 78 80 79 ifdef CONFIG_SUN3 81 80 LDFLAGS_vmlinux = -N
arch/m68k/kernel/module.lds arch/m68k/include/asm/module.lds.h
+1 -1
arch/mips/vdso/Makefile
··· 61 61 # VDSO linker flags. 62 62 ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \ 63 63 $(filter -E%,$(KBUILD_CFLAGS)) -nostdlib -shared \ 64 - -G 0 --eh-frame-hdr --hash-style=sysv --build-id -T 64 + -G 0 --eh-frame-hdr --hash-style=sysv --build-id=sha1 -T 65 65 66 66 CFLAGS_REMOVE_vdso.o = -pg 67 67
+1 -1
arch/nds32/kernel/vdso/Makefile
··· 20 20 21 21 22 22 obj-y += vdso.o 23 - extra-y += vdso.lds 23 + targets += vdso.lds 24 24 CPPFLAGS_vdso.lds += -P -C -U$(ARCH) 25 25 26 26 # Force dependency
-1
arch/powerpc/Makefile
··· 65 65 ifdef CONFIG_PPC32 66 66 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o 67 67 else 68 - KBUILD_LDS_MODULE += $(srctree)/arch/powerpc/kernel/module.lds 69 68 ifeq ($(call ld-ifversion, -ge, 225000000, y),y) 70 69 # Have the linker provide sfpr if possible. 71 70 # There is a corresponding test in arch/powerpc/lib/Makefile
arch/powerpc/kernel/module.lds arch/powerpc/include/asm/module.lds.h
+1 -1
arch/powerpc/kernel/vdso32/Makefile
··· 29 29 asflags-y := -D__VDSO32__ -s 30 30 31 31 obj-y += vdso32_wrapper.o 32 - extra-y += vdso32.lds 32 + targets += vdso32.lds 33 33 CPPFLAGS_vdso32.lds += -P -C -Upowerpc 34 34 35 35 # Force dependency (incbin is bad)
+1 -1
arch/powerpc/kernel/vdso64/Makefile
··· 17 17 asflags-y := -D__VDSO64__ -s 18 18 19 19 obj-y += vdso64_wrapper.o 20 - extra-y += vdso64.lds 20 + targets += vdso64.lds 21 21 CPPFLAGS_vdso64.lds += -P -C -U$(ARCH) 22 22 23 23 # Force dependency (incbin is bad)
-3
arch/riscv/Makefile
··· 53 53 ifeq ($(CONFIG_CMODEL_MEDANY),y) 54 54 KBUILD_CFLAGS += -mcmodel=medany 55 55 endif 56 - ifeq ($(CONFIG_MODULE_SECTIONS),y) 57 - KBUILD_LDS_MODULE += $(srctree)/arch/riscv/kernel/module.lds 58 - endif 59 56 ifeq ($(CONFIG_PERF_EVENTS),y) 60 57 KBUILD_CFLAGS += -fno-omit-frame-pointer 61 58 endif
+2 -1
arch/riscv/kernel/module.lds arch/riscv/include/asm/module.lds.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* Copyright (C) 2017 Andes Technology Corporation */ 3 - 3 + #ifdef CONFIG_MODULE_SECTIONS 4 4 SECTIONS { 5 5 .plt (NOLOAD) : { BYTE(0) } 6 6 .got (NOLOAD) : { BYTE(0) } 7 7 .got.plt (NOLOAD) : { BYTE(0) } 8 8 } 9 + #endif
+1 -1
arch/riscv/kernel/vdso/Makefile
··· 49 49 # refer to these symbols in the kernel code rather than hand-coded addresses. 50 50 51 51 SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \ 52 - -Wl,--build-id -Wl,--hash-style=both 52 + -Wl,--build-id=sha1 -Wl,--hash-style=both 53 53 $(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE 54 54 $(call if_changed,vdsold) 55 55
+2 -2
arch/s390/kernel/vdso64/Makefile
··· 25 25 KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) 26 26 KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin 27 27 ldflags-y := -fPIC -shared -nostdlib -soname=linux-vdso64.so.1 \ 28 - --hash-style=both --build-id -T 28 + --hash-style=both --build-id=sha1 -T 29 29 30 30 $(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64) 31 31 $(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64) 32 32 33 33 obj-y += vdso64_wrapper.o 34 - extra-y += vdso64.lds 34 + targets += vdso64.lds 35 35 CPPFLAGS_vdso64.lds += -P -C -U$(ARCH) 36 36 37 37 # Disable gcov profiling, ubsan and kasan for VDSO code
+1 -3
arch/sparc/vdso/Makefile
··· 3 3 # Building vDSO images for sparc. 4 4 # 5 5 6 - KBUILD_CFLAGS += $(DISABLE_LTO) 7 - 8 6 VDSO64-$(CONFIG_SPARC64) := y 9 7 VDSOCOMPAT-$(CONFIG_COMPAT) := y 10 8 ··· 113 115 -T $(filter %.lds,$^) $(filter %.o,$^) && \ 114 116 sh $(srctree)/$(src)/checkundef.sh '$(OBJDUMP)' '$@' 115 117 116 - VDSO_LDFLAGS = -shared --hash-style=both --build-id -Bsymbolic 118 + VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic 117 119 GCOV_PROFILE := n 118 120 119 121 #
+1
arch/um/include/asm/Kbuild
··· 16 16 generic-y += mcs_spinlock.h 17 17 generic-y += mm-arch-hooks.h 18 18 generic-y += mmiowb.h 19 + generic-y += module.lds.h 19 20 generic-y += param.h 20 21 generic-y += pci.h 21 22 generic-y += percpu.h
+1 -3
arch/x86/entry/vdso/Makefile
··· 9 9 ARCH_REL_TYPE_ABS += R_386_GLOB_DAT|R_386_JMP_SLOT|R_386_RELATIVE 10 10 include $(srctree)/lib/vdso/Makefile 11 11 12 - KBUILD_CFLAGS += $(DISABLE_LTO) 13 - 14 12 # Sanitizer runtimes are unavailable and cannot be linked here. 15 13 KASAN_SANITIZE := n 16 14 UBSAN_SANITIZE := n ··· 174 176 -T $(filter %.lds,$^) $(filter %.o,$^) && \ 175 177 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' 176 178 177 - VDSO_LDFLAGS = -shared --hash-style=both --build-id \ 179 + VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 \ 178 180 $(call ld-option, --eh-frame-hdr) -Bsymbolic 179 181 GCOV_PROFILE := n 180 182
+1
include/asm-generic/Kbuild
··· 39 39 mandatory-y += mmu.h 40 40 mandatory-y += mmu_context.h 41 41 mandatory-y += module.h 42 + mandatory-y += module.lds.h 42 43 mandatory-y += msi.h 43 44 mandatory-y += pci.h 44 45 mandatory-y += percpu.h
+10
include/asm-generic/module.lds.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + #ifndef __ASM_GENERIC_MODULE_LDS_H 3 + #define __ASM_GENERIC_MODULE_LDS_H 4 + 5 + /* 6 + * <asm/module.lds.h> can specify arch-specific sections for linking modules. 7 + * Empty for the asm-generic header. 8 + */ 9 + 10 + #endif /* __ASM_GENERIC_MODULE_LDS_H */
-3
kernel/Makefile
··· 38 38 KCSAN_SANITIZE_kcov.o := n 39 39 CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack) -fno-stack-protector 40 40 41 - # cond_syscall is currently not LTO compatible 42 - CFLAGS_sys_ni.o = $(DISABLE_LTO) 43 - 44 41 obj-y += sched/ 45 42 obj-y += locking/ 46 43 obj-y += power/
+4 -6
lib/Kconfig.debug
··· 212 212 213 213 If unsure, say N. 214 214 215 + if DEBUG_INFO 216 + 215 217 config DEBUG_INFO_REDUCED 216 218 bool "Reduce debugging information" 217 - depends on DEBUG_INFO 218 219 help 219 220 If you say Y here gcc is instructed to generate less debugging 220 221 information for structure types. This means that tools that ··· 228 227 229 228 config DEBUG_INFO_COMPRESSED 230 229 bool "Compressed debugging information" 231 - depends on DEBUG_INFO 232 230 depends on $(cc-option,-gz=zlib) 233 231 depends on $(ld-option,--compress-debug-sections=zlib) 234 232 help ··· 243 243 244 244 config DEBUG_INFO_SPLIT 245 245 bool "Produce split debuginfo in .dwo files" 246 - depends on DEBUG_INFO 247 246 depends on $(cc-option,-gsplit-dwarf) 248 247 help 249 248 Generate debug info into separate .dwo files. This significantly ··· 258 259 259 260 config DEBUG_INFO_DWARF4 260 261 bool "Generate dwarf4 debuginfo" 261 - depends on DEBUG_INFO 262 262 depends on $(cc-option,-gdwarf-4) 263 263 help 264 264 Generate dwarf4 debug info. This requires recent versions ··· 267 269 268 270 config DEBUG_INFO_BTF 269 271 bool "Generate BTF typeinfo" 270 - depends on DEBUG_INFO 271 272 depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED 272 273 depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST 273 274 help ··· 276 279 277 280 config GDB_SCRIPTS 278 281 bool "Provide GDB scripts for kernel debugging" 279 - depends on DEBUG_INFO 280 282 help 281 283 This creates the required links to GDB helper scripts in the 282 284 build directory. If you load vmlinux into gdb, the helper ··· 283 287 additional functions are available to analyze a Linux kernel 284 288 instance. See Documentation/dev-tools/gdb-kernel-debugging.rst 285 289 for further details. 290 + 291 + endif # DEBUG_INFO 286 292 287 293 config ENABLE_MUST_CHECK 288 294 bool "Enable __must_check logic"
+1
scripts/.gitignore
··· 8 8 extract-cert 9 9 sign-file 10 10 insert-sys-cert 11 + /module.lds
-2
scripts/Kbuild.include
··· 56 56 # - If no file exist it is created 57 57 # - If the content differ the new file is used 58 58 # - If they are equal no change, and no timestamp update 59 - # - stdin is piped in from the first prerequisite ($<) so one has 60 - # to specify a valid file as first prerequisite (often the kbuild file) 61 59 define filechk 62 60 $(Q)set -e; \ 63 61 mkdir -p $(dir $@); \
+3
scripts/Makefile
··· 29 29 # The following programs are only built on demand 30 30 hostprogs += unifdef 31 31 32 + # The module linker script is preprocessed on demand 33 + targets += module.lds 34 + 32 35 subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins 33 36 subdir-$(CONFIG_MODVERSIONS) += genksyms 34 37 subdir-$(CONFIG_SECURITY_SELINUX) += selinux
+1 -1
scripts/Makefile.build
··· 111 111 # --------------------------------------------------------------------------- 112 112 113 113 quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ 114 - cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< 114 + cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) -fverbose-asm -S -o $@ $< 115 115 116 116 $(obj)/%.s: $(src)/%.c FORCE 117 117 $(call if_changed_dep,cc_s_c)
+2 -2
scripts/Makefile.kasan
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - ifdef CONFIG_KASAN 3 2 CFLAGS_KASAN_NOSANITIZE := -fno-builtin 4 3 KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET) 5 - endif 6 4 7 5 ifdef CONFIG_KASAN_GENERIC 8 6 ··· 47 49 $(instrumentation_flags) 48 50 49 51 endif # CONFIG_KASAN_SW_TAGS 52 + 53 + export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE
+1 -1
scripts/Makefile.kcsan
··· 9 9 10 10 # Keep most options here optional, to allow enabling more compilers if absence 11 11 # of some options does not break KCSAN nor causes false positive reports. 12 - CFLAGS_KCSAN := -fsanitize=thread \ 12 + export CFLAGS_KCSAN := -fsanitize=thread \ 13 13 $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \ 14 14 $(call cc-option,$(call cc-param,tsan-compound-read-before-write=1),$(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1))) \ 15 15 $(call cc-param,tsan-distinguish-volatile=1)
+2 -3
scripts/Makefile.modfinal
··· 33 33 cmd_ld_ko_o = \ 34 34 $(LD) -r $(KBUILD_LDFLAGS) \ 35 35 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ 36 - $(addprefix -T , $(KBUILD_LDS_MODULE)) \ 37 - -o $@ $(filter %.o, $^); \ 36 + -T scripts/module.lds -o $@ $(filter %.o, $^); \ 38 37 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 39 38 40 - $(modules): %.ko: %.o %.mod.o $(KBUILD_LDS_MODULE) FORCE 39 + $(modules): %.ko: %.o %.mod.o scripts/module.lds FORCE 41 40 +$(call if_changed,ld_ko_o) 42 41 43 42 targets += $(modules) $(modules:.ko=.mod.o)
+3
scripts/Makefile.ubsan
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 + 3 + export CFLAGS_UBSAN := 4 + 2 5 ifdef CONFIG_UBSAN_ALIGNMENT 3 6 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment) 4 7 endif
+236
scripts/clang-tools/gen_compile_commands.py
··· 1 + #!/usr/bin/env python 2 + # SPDX-License-Identifier: GPL-2.0 3 + # 4 + # Copyright (C) Google LLC, 2018 5 + # 6 + # Author: Tom Roeder <tmroeder@google.com> 7 + # 8 + """A tool for generating compile_commands.json in the Linux kernel.""" 9 + 10 + import argparse 11 + import json 12 + import logging 13 + import os 14 + import re 15 + import subprocess 16 + 17 + _DEFAULT_OUTPUT = 'compile_commands.json' 18 + _DEFAULT_LOG_LEVEL = 'WARNING' 19 + 20 + _FILENAME_PATTERN = r'^\..*\.cmd$' 21 + _LINE_PATTERN = r'^cmd_[^ ]*\.o := (.* )([^ ]*\.c)$' 22 + _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] 23 + 24 + 25 + def parse_arguments(): 26 + """Sets up and parses command-line arguments. 27 + 28 + Returns: 29 + log_level: A logging level to filter log output. 30 + directory: The work directory where the objects were built. 31 + ar: Command used for parsing .a archives. 32 + output: Where to write the compile-commands JSON file. 33 + paths: The list of files/directories to handle to find .cmd files. 34 + """ 35 + usage = 'Creates a compile_commands.json database from kernel .cmd files' 36 + parser = argparse.ArgumentParser(description=usage) 37 + 38 + directory_help = ('specify the output directory used for the kernel build ' 39 + '(defaults to the working directory)') 40 + parser.add_argument('-d', '--directory', type=str, default='.', 41 + help=directory_help) 42 + 43 + output_help = ('path to the output command database (defaults to ' + 44 + _DEFAULT_OUTPUT + ')') 45 + parser.add_argument('-o', '--output', type=str, default=_DEFAULT_OUTPUT, 46 + help=output_help) 47 + 48 + log_level_help = ('the level of log messages to produce (defaults to ' + 49 + _DEFAULT_LOG_LEVEL + ')') 50 + parser.add_argument('--log_level', choices=_VALID_LOG_LEVELS, 51 + default=_DEFAULT_LOG_LEVEL, help=log_level_help) 52 + 53 + ar_help = 'command used for parsing .a archives' 54 + parser.add_argument('-a', '--ar', type=str, default='llvm-ar', help=ar_help) 55 + 56 + paths_help = ('directories to search or files to parse ' 57 + '(files should be *.o, *.a, or modules.order). ' 58 + 'If nothing is specified, the current directory is searched') 59 + parser.add_argument('paths', type=str, nargs='*', help=paths_help) 60 + 61 + args = parser.parse_args() 62 + 63 + return (args.log_level, 64 + os.path.abspath(args.directory), 65 + args.output, 66 + args.ar, 67 + args.paths if len(args.paths) > 0 else [args.directory]) 68 + 69 + 70 + def cmdfiles_in_dir(directory): 71 + """Generate the iterator of .cmd files found under the directory. 72 + 73 + Walk under the given directory, and yield every .cmd file found. 74 + 75 + Args: 76 + directory: The directory to search for .cmd files. 77 + 78 + Yields: 79 + The path to a .cmd file. 80 + """ 81 + 82 + filename_matcher = re.compile(_FILENAME_PATTERN) 83 + 84 + for dirpath, _, filenames in os.walk(directory): 85 + for filename in filenames: 86 + if filename_matcher.match(filename): 87 + yield os.path.join(dirpath, filename) 88 + 89 + 90 + def to_cmdfile(path): 91 + """Return the path of .cmd file used for the given build artifact 92 + 93 + Args: 94 + Path: file path 95 + 96 + Returns: 97 + The path to .cmd file 98 + """ 99 + dir, base = os.path.split(path) 100 + return os.path.join(dir, '.' + base + '.cmd') 101 + 102 + 103 + def cmdfiles_for_o(obj): 104 + """Generate the iterator of .cmd files associated with the object 105 + 106 + Yield the .cmd file used to build the given object 107 + 108 + Args: 109 + obj: The object path 110 + 111 + Yields: 112 + The path to .cmd file 113 + """ 114 + yield to_cmdfile(obj) 115 + 116 + 117 + def cmdfiles_for_a(archive, ar): 118 + """Generate the iterator of .cmd files associated with the archive. 119 + 120 + Parse the given archive, and yield every .cmd file used to build it. 121 + 122 + Args: 123 + archive: The archive to parse 124 + 125 + Yields: 126 + The path to every .cmd file found 127 + """ 128 + for obj in subprocess.check_output([ar, '-t', archive]).decode().split(): 129 + yield to_cmdfile(obj) 130 + 131 + 132 + def cmdfiles_for_modorder(modorder): 133 + """Generate the iterator of .cmd files associated with the modules.order. 134 + 135 + Parse the given modules.order, and yield every .cmd file used to build the 136 + contained modules. 137 + 138 + Args: 139 + modorder: The modules.order file to parse 140 + 141 + Yields: 142 + The path to every .cmd file found 143 + """ 144 + with open(modorder) as f: 145 + for line in f: 146 + ko = line.rstrip() 147 + base, ext = os.path.splitext(ko) 148 + if ext != '.ko': 149 + sys.exit('{}: module path must end with .ko'.format(ko)) 150 + mod = base + '.mod' 151 + # The first line of *.mod lists the objects that compose the module. 152 + with open(mod) as m: 153 + for obj in m.readline().split(): 154 + yield to_cmdfile(obj) 155 + 156 + 157 + def process_line(root_directory, command_prefix, file_path): 158 + """Extracts information from a .cmd line and creates an entry from it. 159 + 160 + Args: 161 + root_directory: The directory that was searched for .cmd files. Usually 162 + used directly in the "directory" entry in compile_commands.json. 163 + command_prefix: The extracted command line, up to the last element. 164 + file_path: The .c file from the end of the extracted command. 165 + Usually relative to root_directory, but sometimes absolute. 166 + 167 + Returns: 168 + An entry to append to compile_commands. 169 + 170 + Raises: 171 + ValueError: Could not find the extracted file based on file_path and 172 + root_directory or file_directory. 173 + """ 174 + # The .cmd files are intended to be included directly by Make, so they 175 + # escape the pound sign '#', either as '\#' or '$(pound)' (depending on the 176 + # kernel version). The compile_commands.json file is not interepreted 177 + # by Make, so this code replaces the escaped version with '#'. 178 + prefix = command_prefix.replace('\#', '#').replace('$(pound)', '#') 179 + 180 + # Use os.path.abspath() to normalize the path resolving '.' and '..' . 181 + abs_path = os.path.abspath(os.path.join(root_directory, file_path)) 182 + if not os.path.exists(abs_path): 183 + raise ValueError('File %s not found' % abs_path) 184 + return { 185 + 'directory': root_directory, 186 + 'file': abs_path, 187 + 'command': prefix + file_path, 188 + } 189 + 190 + 191 + def main(): 192 + """Walks through the directory and finds and parses .cmd files.""" 193 + log_level, directory, output, ar, paths = parse_arguments() 194 + 195 + level = getattr(logging, log_level) 196 + logging.basicConfig(format='%(levelname)s: %(message)s', level=level) 197 + 198 + line_matcher = re.compile(_LINE_PATTERN) 199 + 200 + compile_commands = [] 201 + 202 + for path in paths: 203 + # If 'path' is a directory, handle all .cmd files under it. 204 + # Otherwise, handle .cmd files associated with the file. 205 + # Most of built-in objects are linked via archives (built-in.a or lib.a) 206 + # but some objects are linked to vmlinux directly. 207 + # Modules are listed in modules.order. 208 + if os.path.isdir(path): 209 + cmdfiles = cmdfiles_in_dir(path) 210 + elif path.endswith('.o'): 211 + cmdfiles = cmdfiles_for_o(path) 212 + elif path.endswith('.a'): 213 + cmdfiles = cmdfiles_for_a(path, ar) 214 + elif path.endswith('modules.order'): 215 + cmdfiles = cmdfiles_for_modorder(path) 216 + else: 217 + sys.exit('{}: unknown file type'.format(path)) 218 + 219 + for cmdfile in cmdfiles: 220 + with open(cmdfile, 'rt') as f: 221 + result = line_matcher.match(f.readline()) 222 + if result: 223 + try: 224 + entry = process_line(directory, result.group(1), 225 + result.group(2)) 226 + compile_commands.append(entry) 227 + except ValueError as err: 228 + logging.info('Could not add line from %s: %s', 229 + cmdfile, err) 230 + 231 + with open(output, 'wt') as f: 232 + json.dump(compile_commands, f, indent=2, sort_keys=True) 233 + 234 + 235 + if __name__ == '__main__': 236 + main()
+74
scripts/clang-tools/run-clang-tools.py
··· 1 + #!/usr/bin/env python 2 + # SPDX-License-Identifier: GPL-2.0 3 + # 4 + # Copyright (C) Google LLC, 2020 5 + # 6 + # Author: Nathan Huckleberry <nhuck@google.com> 7 + # 8 + """A helper routine run clang-tidy and the clang static-analyzer on 9 + compile_commands.json. 10 + """ 11 + 12 + import argparse 13 + import json 14 + import multiprocessing 15 + import os 16 + import subprocess 17 + import sys 18 + 19 + 20 + def parse_arguments(): 21 + """Set up and parses command-line arguments. 22 + Returns: 23 + args: Dict of parsed args 24 + Has keys: [path, type] 25 + """ 26 + usage = """Run clang-tidy or the clang static-analyzer on a 27 + compilation database.""" 28 + parser = argparse.ArgumentParser(description=usage) 29 + 30 + type_help = "Type of analysis to be performed" 31 + parser.add_argument("type", 32 + choices=["clang-tidy", "clang-analyzer"], 33 + help=type_help) 34 + path_help = "Path to the compilation database to parse" 35 + parser.add_argument("path", type=str, help=path_help) 36 + 37 + return parser.parse_args() 38 + 39 + 40 + def init(l, a): 41 + global lock 42 + global args 43 + lock = l 44 + args = a 45 + 46 + 47 + def run_analysis(entry): 48 + # Disable all checks, then re-enable the ones we want 49 + checks = "-checks=-*," 50 + if args.type == "clang-tidy": 51 + checks += "linuxkernel-*" 52 + else: 53 + checks += "clang-analyzer-*" 54 + p = subprocess.run(["clang-tidy", "-p", args.path, checks, entry["file"]], 55 + stdout=subprocess.PIPE, 56 + stderr=subprocess.STDOUT, 57 + cwd=entry["directory"]) 58 + with lock: 59 + sys.stderr.buffer.write(p.stdout) 60 + 61 + 62 + def main(): 63 + args = parse_arguments() 64 + 65 + lock = multiprocessing.Lock() 66 + pool = multiprocessing.Pool(initializer=init, initargs=(lock, args)) 67 + # Read JSON data into the datastore variable 68 + with open(args.path, "r") as f: 69 + datastore = json.load(f) 70 + pool.map(run_analysis, datastore) 71 + 72 + 73 + if __name__ == "__main__": 74 + main()
-151
scripts/gen_compile_commands.py
··· 1 - #!/usr/bin/env python 2 - # SPDX-License-Identifier: GPL-2.0 3 - # 4 - # Copyright (C) Google LLC, 2018 5 - # 6 - # Author: Tom Roeder <tmroeder@google.com> 7 - # 8 - """A tool for generating compile_commands.json in the Linux kernel.""" 9 - 10 - import argparse 11 - import json 12 - import logging 13 - import os 14 - import re 15 - 16 - _DEFAULT_OUTPUT = 'compile_commands.json' 17 - _DEFAULT_LOG_LEVEL = 'WARNING' 18 - 19 - _FILENAME_PATTERN = r'^\..*\.cmd$' 20 - _LINE_PATTERN = r'^cmd_[^ ]*\.o := (.* )([^ ]*\.c)$' 21 - _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] 22 - 23 - # A kernel build generally has over 2000 entries in its compile_commands.json 24 - # database. If this code finds 300 or fewer, then warn the user that they might 25 - # not have all the .cmd files, and they might need to compile the kernel. 26 - _LOW_COUNT_THRESHOLD = 300 27 - 28 - 29 - def parse_arguments(): 30 - """Sets up and parses command-line arguments. 31 - 32 - Returns: 33 - log_level: A logging level to filter log output. 34 - directory: The directory to search for .cmd files. 35 - output: Where to write the compile-commands JSON file. 36 - """ 37 - usage = 'Creates a compile_commands.json database from kernel .cmd files' 38 - parser = argparse.ArgumentParser(description=usage) 39 - 40 - directory_help = ('Path to the kernel source directory to search ' 41 - '(defaults to the working directory)') 42 - parser.add_argument('-d', '--directory', type=str, help=directory_help) 43 - 44 - output_help = ('The location to write compile_commands.json (defaults to ' 45 - 'compile_commands.json in the search directory)') 46 - parser.add_argument('-o', '--output', type=str, help=output_help) 47 - 48 - log_level_help = ('The level of log messages to produce (one of ' + 49 - ', '.join(_VALID_LOG_LEVELS) + '; defaults to ' + 50 - _DEFAULT_LOG_LEVEL + ')') 51 - parser.add_argument( 52 - '--log_level', type=str, default=_DEFAULT_LOG_LEVEL, 53 - help=log_level_help) 54 - 55 - args = parser.parse_args() 56 - 57 - log_level = args.log_level 58 - if log_level not in _VALID_LOG_LEVELS: 59 - raise ValueError('%s is not a valid log level' % log_level) 60 - 61 - directory = args.directory or os.getcwd() 62 - output = args.output or os.path.join(directory, _DEFAULT_OUTPUT) 63 - directory = os.path.abspath(directory) 64 - 65 - return log_level, directory, output 66 - 67 - 68 - def process_line(root_directory, file_directory, command_prefix, relative_path): 69 - """Extracts information from a .cmd line and creates an entry from it. 70 - 71 - Args: 72 - root_directory: The directory that was searched for .cmd files. Usually 73 - used directly in the "directory" entry in compile_commands.json. 74 - file_directory: The path to the directory the .cmd file was found in. 75 - command_prefix: The extracted command line, up to the last element. 76 - relative_path: The .c file from the end of the extracted command. 77 - Usually relative to root_directory, but sometimes relative to 78 - file_directory and sometimes neither. 79 - 80 - Returns: 81 - An entry to append to compile_commands. 82 - 83 - Raises: 84 - ValueError: Could not find the extracted file based on relative_path and 85 - root_directory or file_directory. 86 - """ 87 - # The .cmd files are intended to be included directly by Make, so they 88 - # escape the pound sign '#', either as '\#' or '$(pound)' (depending on the 89 - # kernel version). The compile_commands.json file is not interepreted 90 - # by Make, so this code replaces the escaped version with '#'. 91 - prefix = command_prefix.replace('\#', '#').replace('$(pound)', '#') 92 - 93 - cur_dir = root_directory 94 - expected_path = os.path.join(cur_dir, relative_path) 95 - if not os.path.exists(expected_path): 96 - # Try using file_directory instead. Some of the tools have a different 97 - # style of .cmd file than the kernel. 98 - cur_dir = file_directory 99 - expected_path = os.path.join(cur_dir, relative_path) 100 - if not os.path.exists(expected_path): 101 - raise ValueError('File %s not in %s or %s' % 102 - (relative_path, root_directory, file_directory)) 103 - return { 104 - 'directory': cur_dir, 105 - 'file': relative_path, 106 - 'command': prefix + relative_path, 107 - } 108 - 109 - 110 - def main(): 111 - """Walks through the directory and finds and parses .cmd files.""" 112 - log_level, directory, output = parse_arguments() 113 - 114 - level = getattr(logging, log_level) 115 - logging.basicConfig(format='%(levelname)s: %(message)s', level=level) 116 - 117 - filename_matcher = re.compile(_FILENAME_PATTERN) 118 - line_matcher = re.compile(_LINE_PATTERN) 119 - 120 - compile_commands = [] 121 - for dirpath, _, filenames in os.walk(directory): 122 - for filename in filenames: 123 - if not filename_matcher.match(filename): 124 - continue 125 - filepath = os.path.join(dirpath, filename) 126 - 127 - with open(filepath, 'rt') as f: 128 - for line in f: 129 - result = line_matcher.match(line) 130 - if not result: 131 - continue 132 - 133 - try: 134 - entry = process_line(directory, dirpath, 135 - result.group(1), result.group(2)) 136 - compile_commands.append(entry) 137 - except ValueError as err: 138 - logging.info('Could not add line from %s: %s', 139 - filepath, err) 140 - 141 - with open(output, 'wt') as f: 142 - json.dump(compile_commands, f, indent=2, sort_keys=True) 143 - 144 - count = len(compile_commands) 145 - if count < _LOW_COUNT_THRESHOLD: 146 - logging.warning( 147 - 'Found %s entries. Have you compiled the kernel?', count) 148 - 149 - 150 - if __name__ == '__main__': 151 - main()
+8 -8
scripts/kconfig/Makefile
··· 20 20 unexport CONFIG_ 21 21 22 22 xconfig: $(obj)/qconf 23 - $< $(silent) $(Kconfig) 23 + $(Q)$< $(silent) $(Kconfig) 24 24 25 25 gconfig: $(obj)/gconf 26 - $< $(silent) $(Kconfig) 26 + $(Q)$< $(silent) $(Kconfig) 27 27 28 28 menuconfig: $(obj)/mconf 29 - $< $(silent) $(Kconfig) 29 + $(Q)$< $(silent) $(Kconfig) 30 30 31 31 config: $(obj)/conf 32 - $< $(silent) --oldaskconfig $(Kconfig) 32 + $(Q)$< $(silent) --oldaskconfig $(Kconfig) 33 33 34 34 nconfig: $(obj)/nconf 35 - $< $(silent) $(Kconfig) 35 + $(Q)$< $(silent) $(Kconfig) 36 36 37 37 build_menuconfig: $(obj)/mconf 38 38 ··· 68 68 PHONY += $(simple-targets) 69 69 70 70 $(simple-targets): $(obj)/conf 71 - $< $(silent) --$@ $(Kconfig) 71 + $(Q)$< $(silent) --$@ $(Kconfig) 72 72 73 73 PHONY += savedefconfig defconfig 74 74 75 75 savedefconfig: $(obj)/conf 76 - $< $(silent) --$@=defconfig $(Kconfig) 76 + $(Q)$< $(silent) --$@=defconfig $(Kconfig) 77 77 78 78 defconfig: $(obj)/conf 79 79 ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) ··· 111 111 # CHECK: -o cache_dir=<path> working? 112 112 PHONY += testconfig 113 113 testconfig: $(obj)/conf 114 - $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 114 + $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 115 115 -o cache_dir=$(abspath $(obj)/tests/.cache) \ 116 116 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) 117 117 clean-files += tests/.cache
+1 -1
scripts/mkcompile_h
··· 35 35 LINUX_COMPILE_BY=$KBUILD_BUILD_USER 36 36 fi 37 37 if test -z "$KBUILD_BUILD_HOST"; then 38 - LINUX_COMPILE_HOST=`hostname` 38 + LINUX_COMPILE_HOST=`uname -n` 39 39 else 40 40 LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST 41 41 fi
+3
scripts/module-common.lds scripts/module.lds.S
··· 24 24 25 25 __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) } 26 26 } 27 + 28 + /* bring in arch-specific sections */ 29 + #include <asm/module.lds.h>
-473
scripts/namespace.pl
··· 1 - #!/usr/bin/env perl 2 - # 3 - # namespace.pl. Mon Aug 30 2004 4 - # 5 - # Perform a name space analysis on the linux kernel. 6 - # 7 - # Copyright Keith Owens <kaos@ocs.com.au>. GPL. 8 - # 9 - # Invoke by changing directory to the top of the kernel object 10 - # tree then namespace.pl, no parameters. 11 - # 12 - # Tuned for 2.1.x kernels with the new module handling, it will 13 - # work with 2.0 kernels as well. 14 - # 15 - # Last change 2.6.9-rc1, adding support for separate source and object 16 - # trees. 17 - # 18 - # The source must be compiled/assembled first, the object files 19 - # are the primary input to this script. Incomplete or missing 20 - # objects will result in a flawed analysis. Compile both vmlinux 21 - # and modules. 22 - # 23 - # Even with complete objects, treat the result of the analysis 24 - # with caution. Some external references are only used by 25 - # certain architectures, others with certain combinations of 26 - # configuration parameters. Ideally the source should include 27 - # something like 28 - # 29 - # #ifndef CONFIG_... 30 - # static 31 - # #endif 32 - # symbol_definition; 33 - # 34 - # so the symbols are defined as static unless a particular 35 - # CONFIG_... requires it to be external. 36 - # 37 - # A symbol that is suffixed with '(export only)' has these properties 38 - # 39 - # * It is global. 40 - # * It is marked EXPORT_SYMBOL or EXPORT_SYMBOL_GPL, either in the same 41 - # source file or a different source file. 42 - # * Given the current .config, nothing uses the symbol. 43 - # 44 - # The symbol is a candidate for conversion to static, plus removal of the 45 - # export. But be careful that a different .config might use the symbol. 46 - # 47 - # 48 - # Name space analysis and cleanup is an iterative process. You cannot 49 - # expect to find all the problems in a single pass. 50 - # 51 - # * Identify possibly unnecessary global declarations, verify that they 52 - # really are unnecessary and change them to static. 53 - # * Compile and fix up gcc warnings about static, removing dead symbols 54 - # as necessary. 55 - # * make clean and rebuild with different configs (especially 56 - # CONFIG_MODULES=n) to see which symbols are being defined when the 57 - # config does not require them. These symbols bloat the kernel object 58 - # for no good reason, which is frustrating for embedded systems. 59 - # * Wrap config sensitive symbols in #ifdef CONFIG_foo, as long as the 60 - # code does not get too ugly. 61 - # * Repeat the name space analysis until you can live with with the 62 - # result. 63 - # 64 - 65 - use warnings; 66 - use strict; 67 - use File::Find; 68 - use File::Spec; 69 - 70 - my $nm = ($ENV{'NM'} || "nm") . " -p"; 71 - my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment"; 72 - my $srctree = File::Spec->curdir(); 73 - my $objtree = File::Spec->curdir(); 74 - $srctree = File::Spec->rel2abs($ENV{'srctree'}) if (exists($ENV{'srctree'})); 75 - $objtree = File::Spec->rel2abs($ENV{'objtree'}) if (exists($ENV{'objtree'})); 76 - 77 - if ($#ARGV != -1) { 78 - print STDERR "usage: $0 takes no parameters\n"; 79 - die("giving up\n"); 80 - } 81 - 82 - my %nmdata = (); # nm data for each object 83 - my %def = (); # all definitions for each name 84 - my %ksymtab = (); # names that appear in __ksymtab_ 85 - my %ref = (); # $ref{$name} exists if there is a true external reference to $name 86 - my %export = (); # $export{$name} exists if there is an EXPORT_... of $name 87 - 88 - my %nmexception = ( 89 - 'fs/ext3/bitmap' => 1, 90 - 'fs/ext4/bitmap' => 1, 91 - 'arch/x86/lib/thunk_32' => 1, 92 - 'arch/x86/lib/cmpxchg' => 1, 93 - 'arch/x86/vdso/vdso32/note' => 1, 94 - 'lib/irq_regs' => 1, 95 - 'usr/initramfs_data' => 1, 96 - 'drivers/scsi/aic94xx/aic94xx_dump' => 1, 97 - 'drivers/scsi/libsas/sas_dump' => 1, 98 - 'lib/dec_and_lock' => 1, 99 - 'drivers/ide/ide-probe-mini' => 1, 100 - 'usr/initramfs_data' => 1, 101 - 'drivers/acpi/acpia/exdump' => 1, 102 - 'drivers/acpi/acpia/rsdump' => 1, 103 - 'drivers/acpi/acpia/nsdumpdv' => 1, 104 - 'drivers/acpi/acpia/nsdump' => 1, 105 - 'arch/ia64/sn/kernel/sn2/io' => 1, 106 - 'arch/ia64/kernel/gate-data' => 1, 107 - 'security/capability' => 1, 108 - 'fs/ntfs/sysctl' => 1, 109 - 'fs/jfs/jfs_debug' => 1, 110 - ); 111 - 112 - my %nameexception = ( 113 - 'mod_use_count_' => 1, 114 - '__initramfs_end' => 1, 115 - '__initramfs_start' => 1, 116 - '_einittext' => 1, 117 - '_sinittext' => 1, 118 - 'kallsyms_names' => 1, 119 - 'kallsyms_num_syms' => 1, 120 - 'kallsyms_addresses'=> 1, 121 - 'kallsyms_offsets' => 1, 122 - 'kallsyms_relative_base'=> 1, 123 - '__this_module' => 1, 124 - '_etext' => 1, 125 - '_edata' => 1, 126 - '_end' => 1, 127 - '__bss_start' => 1, 128 - '_text' => 1, 129 - '_stext' => 1, 130 - '__gp' => 1, 131 - 'ia64_unw_start' => 1, 132 - 'ia64_unw_end' => 1, 133 - '__init_begin' => 1, 134 - '__init_end' => 1, 135 - '__bss_stop' => 1, 136 - '__nosave_begin' => 1, 137 - '__nosave_end' => 1, 138 - 'pg0' => 1, 139 - 'vdso_enabled' => 1, 140 - '__stack_chk_fail' => 1, 141 - 'VDSO32_PRELINK' => 1, 142 - 'VDSO32_vsyscall' => 1, 143 - 'VDSO32_rt_sigreturn'=>1, 144 - 'VDSO32_sigreturn' => 1, 145 - ); 146 - 147 - 148 - &find(\&linux_objects, '.'); # find the objects and do_nm on them 149 - &list_multiply_defined(); 150 - &resolve_external_references(); 151 - &list_extra_externals(); 152 - 153 - exit(0); 154 - 155 - sub linux_objects 156 - { 157 - # Select objects, ignoring objects which are only created by 158 - # merging other objects. Also ignore all of modules, scripts 159 - # and compressed. Most conglomerate objects are handled by do_nm, 160 - # this list only contains the special cases. These include objects 161 - # that are linked from just one other object and objects for which 162 - # there is really no permanent source file. 163 - my $basename = $_; 164 - $_ = $File::Find::name; 165 - s:^\./::; 166 - if (/.*\.o$/ && 167 - ! ( 168 - m:/built-in.a$: 169 - || m:arch/x86/vdso/: 170 - || m:arch/x86/boot/: 171 - || m:arch/ia64/ia32/ia32.o$: 172 - || m:arch/ia64/kernel/gate-syms.o$: 173 - || m:arch/ia64/lib/__divdi3.o$: 174 - || m:arch/ia64/lib/__divsi3.o$: 175 - || m:arch/ia64/lib/__moddi3.o$: 176 - || m:arch/ia64/lib/__modsi3.o$: 177 - || m:arch/ia64/lib/__udivdi3.o$: 178 - || m:arch/ia64/lib/__udivsi3.o$: 179 - || m:arch/ia64/lib/__umoddi3.o$: 180 - || m:arch/ia64/lib/__umodsi3.o$: 181 - || m:arch/ia64/scripts/check_gas_for_hint.o$: 182 - || m:arch/ia64/sn/kernel/xp.o$: 183 - || m:boot/bbootsect.o$: 184 - || m:boot/bsetup.o$: 185 - || m:/bootsect.o$: 186 - || m:/boot/setup.o$: 187 - || m:/compressed/: 188 - || m:drivers/cdrom/driver.o$: 189 - || m:drivers/char/drm/tdfx_drv.o$: 190 - || m:drivers/ide/ide-detect.o$: 191 - || m:drivers/ide/pci/idedriver-pci.o$: 192 - || m:drivers/media/media.o$: 193 - || m:drivers/scsi/sd_mod.o$: 194 - || m:drivers/video/video.o$: 195 - || m:fs/devpts/devpts.o$: 196 - || m:fs/exportfs/exportfs.o$: 197 - || m:fs/hugetlbfs/hugetlbfs.o$: 198 - || m:fs/msdos/msdos.o$: 199 - || m:fs/nls/nls.o$: 200 - || m:fs/ramfs/ramfs.o$: 201 - || m:fs/romfs/romfs.o$: 202 - || m:fs/vfat/vfat.o$: 203 - || m:init/mounts.o$: 204 - || m:^modules/: 205 - || m:net/netlink/netlink.o$: 206 - || m:net/sched/sched.o$: 207 - || m:/piggy.o$: 208 - || m:^scripts/: 209 - || m:sound/.*/snd-: 210 - || m:^.*/\.tmp_: 211 - || m:^\.tmp_: 212 - || m:/vmlinux-obj.o$: 213 - || m:^tools/: 214 - ) 215 - ) { 216 - do_nm($basename, $_); 217 - } 218 - $_ = $basename; # File::Find expects $_ untouched (undocumented) 219 - } 220 - 221 - sub do_nm 222 - { 223 - my ($basename, $fullname) = @_; 224 - my ($source, $type, $name); 225 - if (! -e $basename) { 226 - printf STDERR "$basename does not exist\n"; 227 - return; 228 - } 229 - if ($fullname !~ /\.o$/) { 230 - printf STDERR "$fullname is not an object file\n"; 231 - return; 232 - } 233 - ($source = $basename) =~ s/\.o$//; 234 - if (-e "$source.c" || -e "$source.S") { 235 - $source = File::Spec->catfile($objtree, $File::Find::dir, $source) 236 - } else { 237 - $source = File::Spec->catfile($srctree, $File::Find::dir, $source) 238 - } 239 - if (! -e "$source.c" && ! -e "$source.S") { 240 - # No obvious source, exclude the object if it is conglomerate 241 - open(my $objdumpdata, "$objdump $basename|") 242 - or die "$objdump $fullname failed $!\n"; 243 - 244 - my $comment; 245 - while (<$objdumpdata>) { 246 - chomp(); 247 - if (/^In archive/) { 248 - # Archives are always conglomerate 249 - $comment = "GCC:GCC:"; 250 - last; 251 - } 252 - next if (! /^[ 0-9a-f]{5,} /); 253 - $comment .= substr($_, 43); 254 - } 255 - close($objdumpdata); 256 - 257 - if (!defined($comment) || $comment !~ /GCC\:.*GCC\:/m) { 258 - printf STDERR "No source file found for $fullname\n"; 259 - } 260 - return; 261 - } 262 - open (my $nmdata, "$nm $basename|") 263 - or die "$nm $fullname failed $!\n"; 264 - 265 - my @nmdata; 266 - while (<$nmdata>) { 267 - chop; 268 - ($type, $name) = (split(/ +/, $_, 3))[1..2]; 269 - # Expected types 270 - # A absolute symbol 271 - # B weak external reference to data that has been resolved 272 - # C global variable, uninitialised 273 - # D global variable, initialised 274 - # G global variable, initialised, small data section 275 - # R global array, initialised 276 - # S global variable, uninitialised, small bss 277 - # T global label/procedure 278 - # U external reference 279 - # W weak external reference to text that has been resolved 280 - # V similar to W, but the value of the weak symbol becomes zero with no error. 281 - # a assembler equate 282 - # b static variable, uninitialised 283 - # d static variable, initialised 284 - # g static variable, initialised, small data section 285 - # r static array, initialised 286 - # s static variable, uninitialised, small bss 287 - # t static label/procedures 288 - # w weak external reference to text that has not been resolved 289 - # v similar to w 290 - # ? undefined type, used a lot by modules 291 - if ($type !~ /^[ABCDGRSTUWVabdgrstwv?]$/) { 292 - printf STDERR "nm output for $fullname contains unknown type '$_'\n"; 293 - } 294 - elsif ($name =~ /\./) { 295 - # name with '.' is local static 296 - } 297 - else { 298 - $type = 'R' if ($type eq '?'); # binutils replaced ? with R at one point 299 - # binutils keeps changing the type for exported symbols, force it to R 300 - $type = 'R' if ($name =~ /^__ksymtab/ || $name =~ /^__kstrtab/); 301 - $name =~ s/_R[a-f0-9]{8}$//; # module versions adds this 302 - if ($type =~ /[ABCDGRSTWV]/ && 303 - $name ne 'init_module' && 304 - $name ne 'cleanup_module' && 305 - $name ne 'Using_Versions' && 306 - $name !~ /^Version_[0-9]+$/ && 307 - $name !~ /^__parm_/ && 308 - $name !~ /^__kstrtab/ && 309 - $name !~ /^__ksymtab/ && 310 - $name !~ /^__kcrctab_/ && 311 - $name !~ /^__exitcall_/ && 312 - $name !~ /^__initcall_/ && 313 - $name !~ /^__kdb_initcall_/ && 314 - $name !~ /^__kdb_exitcall_/ && 315 - $name !~ /^__module_/ && 316 - $name !~ /^__mod_/ && 317 - $name !~ /^__crc_/ && 318 - $name ne '__this_module' && 319 - $name ne 'kernel_version') { 320 - if (!exists($def{$name})) { 321 - $def{$name} = []; 322 - } 323 - push(@{$def{$name}}, $fullname); 324 - } 325 - push(@nmdata, "$type $name"); 326 - if ($name =~ /^__ksymtab_/) { 327 - $name = substr($name, 10); 328 - if (!exists($ksymtab{$name})) { 329 - $ksymtab{$name} = []; 330 - } 331 - push(@{$ksymtab{$name}}, $fullname); 332 - } 333 - } 334 - } 335 - close($nmdata); 336 - 337 - if ($#nmdata < 0) { 338 - printf "No nm data for $fullname\n" 339 - unless $nmexception{$fullname}; 340 - return; 341 - } 342 - $nmdata{$fullname} = \@nmdata; 343 - } 344 - 345 - sub drop_def 346 - { 347 - my ($object, $name) = @_; 348 - my $nmdata = $nmdata{$object}; 349 - my ($i, $j); 350 - for ($i = 0; $i <= $#{$nmdata}; ++$i) { 351 - if ($name eq (split(' ', $nmdata->[$i], 2))[1]) { 352 - splice(@{$nmdata{$object}}, $i, 1); 353 - my $def = $def{$name}; 354 - for ($j = 0; $j < $#{$def{$name}}; ++$j) { 355 - if ($def{$name}[$j] eq $object) { 356 - splice(@{$def{$name}}, $j, 1); 357 - } 358 - } 359 - last; 360 - } 361 - } 362 - } 363 - 364 - sub list_multiply_defined 365 - { 366 - foreach my $name (keys(%def)) { 367 - if ($#{$def{$name}} > 0) { 368 - # Special case for cond_syscall 369 - if ($#{$def{$name}} == 1 && 370 - ($name =~ /^sys_/ || $name =~ /^compat_sys_/ || 371 - $name =~ /^sys32_/)) { 372 - if($def{$name}[0] eq "kernel/sys_ni.o" || 373 - $def{$name}[1] eq "kernel/sys_ni.o") { 374 - &drop_def("kernel/sys_ni.o", $name); 375 - next; 376 - } 377 - } 378 - 379 - printf "$name is multiply defined in :-\n"; 380 - foreach my $module (@{$def{$name}}) { 381 - printf "\t$module\n"; 382 - } 383 - } 384 - } 385 - } 386 - 387 - sub resolve_external_references 388 - { 389 - my ($kstrtab, $ksymtab, $export); 390 - 391 - printf "\n"; 392 - foreach my $object (keys(%nmdata)) { 393 - my $nmdata = $nmdata{$object}; 394 - for (my $i = 0; $i <= $#{$nmdata}; ++$i) { 395 - my ($type, $name) = split(' ', $nmdata->[$i], 2); 396 - if ($type eq "U" || $type eq "w") { 397 - if (exists($def{$name}) || exists($ksymtab{$name})) { 398 - # add the owning object to the nmdata 399 - $nmdata->[$i] = "$type $name $object"; 400 - # only count as a reference if it is not EXPORT_... 401 - $kstrtab = "R __kstrtab_$name"; 402 - $ksymtab = "R __ksymtab_$name"; 403 - $export = 0; 404 - for (my $j = 0; $j <= $#{$nmdata}; ++$j) { 405 - if ($nmdata->[$j] eq $kstrtab || 406 - $nmdata->[$j] eq $ksymtab) { 407 - $export = 1; 408 - last; 409 - } 410 - } 411 - if ($export) { 412 - $export{$name} = ""; 413 - } 414 - else { 415 - $ref{$name} = "" 416 - } 417 - } 418 - elsif ( ! $nameexception{$name} 419 - && $name !~ /^__sched_text_/ 420 - && $name !~ /^__start_/ 421 - && $name !~ /^__end_/ 422 - && $name !~ /^__stop_/ 423 - && $name !~ /^__scheduling_functions_.*_here/ 424 - && $name !~ /^__.*initcall_/ 425 - && $name !~ /^__.*per_cpu_start/ 426 - && $name !~ /^__.*per_cpu_end/ 427 - && $name !~ /^__alt_instructions/ 428 - && $name !~ /^__setup_/ 429 - && $name !~ /^__mod_timer/ 430 - && $name !~ /^__mod_page_state/ 431 - && $name !~ /^init_module/ 432 - && $name !~ /^cleanup_module/ 433 - ) { 434 - printf "Cannot resolve "; 435 - printf "weak " if ($type eq "w"); 436 - printf "reference to $name from $object\n"; 437 - } 438 - } 439 - } 440 - } 441 - } 442 - 443 - sub list_extra_externals 444 - { 445 - my %noref = (); 446 - 447 - foreach my $name (keys(%def)) { 448 - if (! exists($ref{$name})) { 449 - my @module = @{$def{$name}}; 450 - foreach my $module (@module) { 451 - if (! exists($noref{$module})) { 452 - $noref{$module} = []; 453 - } 454 - push(@{$noref{$module}}, $name); 455 - } 456 - } 457 - } 458 - if (%noref) { 459 - printf "\nExternally defined symbols with no external references\n"; 460 - foreach my $module (sort(keys(%noref))) { 461 - printf " $module\n"; 462 - foreach (sort(@{$noref{$module}})) { 463 - my $export; 464 - if (exists($export{$_})) { 465 - $export = " (export only)"; 466 - } else { 467 - $export = ""; 468 - } 469 - printf " $_$export\n"; 470 - } 471 - } 472 - } 473 - }
+13 -6
scripts/package/builddeb
··· 26 26 27 27 create_package() { 28 28 local pname="$1" pdir="$2" 29 + local dpkg_deb_opts 29 30 30 31 mkdir -m 755 -p "$pdir/DEBIAN" 31 32 mkdir -p "$pdir/usr/share/doc/$pname" 32 33 cp debian/copyright "$pdir/usr/share/doc/$pname/" 33 34 cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian" 34 - gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian" 35 + gzip -n -9 "$pdir/usr/share/doc/$pname/changelog.Debian" 35 36 sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \ 36 37 | xargs -r0 md5sum > DEBIAN/md5sums" 37 38 38 39 # Fix ownership and permissions 39 - chown -R root:root "$pdir" 40 + if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then 41 + dpkg_deb_opts="--root-owner-group" 42 + else 43 + chown -R root:root "$pdir" 44 + fi 40 45 chmod -R go-w "$pdir" 41 46 # in case we are in a restrictive umask environment like 0077 42 47 chmod -R a+rX "$pdir" 43 48 44 49 # Create the package 45 50 dpkg-gencontrol -p$pname -P"$pdir" 46 - dpkg-deb ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. 51 + dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. 47 52 } 48 53 49 54 deploy_kernel_headers () { ··· 60 55 cd $srctree 61 56 find . arch/$SRCARCH -maxdepth 1 -name Makefile\* 62 57 find include scripts -type f -o -type l 63 - find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform 58 + find arch/$SRCARCH -name Kbuild.platforms -o -name Platform 64 59 find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f 65 60 ) > debian/hdrsrcfiles 66 61 ··· 207 202 done 208 203 209 204 if [ "$ARCH" != "um" ]; then 210 - deploy_kernel_headers debian/linux-headers 211 - create_package linux-headers-$version debian/linux-headers 205 + if is_enabled CONFIG_MODULES; then 206 + deploy_kernel_headers debian/linux-headers 207 + create_package linux-headers-$version debian/linux-headers 208 + fi 212 209 213 210 deploy_libc_headers debian/linux-libc-dev 214 211 create_package linux-libc-dev debian/linux-libc-dev
+27 -17
scripts/package/mkdebian
··· 94 94 packageversion=$version-$revision 95 95 fi 96 96 sourcename=$KDEB_SOURCENAME 97 - packagename=linux-image-$version 98 - kernel_headers_packagename=linux-headers-$version 99 - dbg_packagename=$packagename-dbg 100 - debarch= 101 - set_debarch 102 97 103 98 if [ "$ARCH" = "um" ] ; then 104 - packagename=user-mode-linux-$version 99 + packagename=user-mode-linux 100 + else 101 + packagename=linux-image 105 102 fi 103 + 104 + debarch= 105 + set_debarch 106 106 107 107 email=${DEBEMAIL-$EMAIL} 108 108 ··· 174 174 Section: kernel 175 175 Priority: optional 176 176 Maintainer: $maintainer 177 + Rules-Requires-Root: no 177 178 Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends 178 179 Homepage: https://www.kernel.org/ 179 180 180 - Package: $packagename 181 + Package: $packagename-$version 181 182 Architecture: $debarch 182 183 Description: Linux kernel, version $version 183 184 This package contains the Linux kernel, modules and corresponding other 184 185 files, version: $version. 185 - 186 - Package: $kernel_headers_packagename 187 - Architecture: $debarch 188 - Description: Linux kernel headers for $version on $debarch 189 - This package provides kernel header files for $version on $debarch 190 - . 191 - This is useful for people who need to build external modules 192 186 193 187 Package: linux-libc-dev 194 188 Section: devel ··· 194 200 Multi-Arch: same 195 201 EOF 196 202 203 + if is_enabled CONFIG_MODULES; then 204 + cat <<EOF >> debian/control 205 + 206 + Package: linux-headers-$version 207 + Architecture: $debarch 208 + Description: Linux kernel headers for $version on $debarch 209 + This package provides kernel header files for $version on $debarch 210 + . 211 + This is useful for people who need to build external modules 212 + EOF 213 + fi 214 + 197 215 if is_enabled CONFIG_DEBUG_INFO; then 198 216 cat <<EOF >> debian/control 199 217 200 - Package: $dbg_packagename 218 + Package: linux-image-$version-dbg 201 219 Section: debug 202 220 Architecture: $debarch 203 221 Description: Linux kernel debugging symbols for $version ··· 223 217 224 218 srctree ?= . 225 219 226 - build: 220 + build-indep: 221 + build-arch: 227 222 \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ 228 223 KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile 229 224 230 - binary-arch: 225 + build: build-arch 226 + 227 + binary-indep: 228 + binary-arch: build-arch 231 229 \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ 232 230 KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg 233 231
+15 -4
scripts/setlocalversion
··· 45 45 46 46 # Check for git and a git repo. 47 47 if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && 48 - head=$(git rev-parse --verify --short HEAD 2>/dev/null); then 48 + head=$(git rev-parse --verify HEAD 2>/dev/null); then 49 49 50 50 # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore 51 51 # it, because this version is defined in the top level Makefile. ··· 59 59 fi 60 60 # If we are past a tagged commit (like 61 61 # "v2.6.30-rc5-302-g72357d5"), we pretty print it. 62 - if atag="$(git describe 2>/dev/null)"; then 63 - echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' 62 + # 63 + # Ensure the abbreviated sha1 has exactly 12 64 + # hex characters, to make the output 65 + # independent of git version, local 66 + # core.abbrev settings and/or total number of 67 + # objects in the current repository - passing 68 + # --abbrev=12 ensures a minimum of 12, and the 69 + # awk substr() then picks the 'g' and first 12 70 + # hex chars. 71 + if atag="$(git describe --abbrev=12 2>/dev/null)"; then 72 + echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),substr($(NF),0,13))}' 64 73 65 - # If we don't have a tag at all we print -g{commitish}. 74 + # If we don't have a tag at all we print -g{commitish}, 75 + # again using exactly 12 hex chars. 66 76 else 77 + head="$(echo $head | cut -c1-12)" 67 78 printf '%s%s' -g $head 68 79 fi 69 80 fi
+1 -1
tools/testing/selftests/bpf/Makefile
··· 134 134 135 135 $(OUTPUT)/urandom_read: urandom_read.c 136 136 $(call msg,BINARY,,$@) 137 - $(Q)$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS) -Wl,--build-id 137 + $(Q)$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS) -Wl,--build-id=sha1 138 138 139 139 $(OUTPUT)/test_stub.o: test_stub.c $(BPFOBJ) 140 140 $(call msg,CC,,$@)