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

Pull Kbuild updates from Masahiro Yamada:

- Improve performance in gendwarfksyms

- Remove deprecated EXTRA_*FLAGS and KBUILD_ENABLE_EXTRA_GCC_CHECKS

- Support CONFIG_HEADERS_INSTALL for ARCH=um

- Use more relative paths to sources files for better reproducibility

- Support the loong64 Debian architecture

- Add Kbuild bash completion

- Introduce intermediate vmlinux.unstripped for architectures that need
static relocations to be stripped from the final vmlinux

- Fix versioning in Debian packages for -rc releases

- Treat missing MODULE_DESCRIPTION() as an error

- Convert Nios2 Makefiles to use the generic rule for built-in DTB

- Add debuginfo support to the RPM package

* tag 'kbuild-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (40 commits)
kbuild: rpm-pkg: build a debuginfo RPM
kconfig: merge_config: use an empty file as initfile
nios2: migrate to the generic rule for built-in DTB
rust: kbuild: skip `--remap-path-prefix` for `rustdoc`
kbuild: pacman-pkg: hardcode module installation path
kbuild: deb-pkg: don't set KBUILD_BUILD_VERSION unconditionally
modpost: require a MODULE_DESCRIPTION()
kbuild: make all file references relative to source root
x86: drop unnecessary prefix map configuration
kbuild: deb-pkg: add comment about future removal of KDEB_COMPRESS
kbuild: Add a help message for "headers"
kbuild: deb-pkg: remove "version" variable in mkdebian
kbuild: deb-pkg: fix versioning for -rc releases
Documentation/kbuild: Fix indentation in modules.rst example
x86: Get rid of Makefile.postlink
kbuild: Create intermediate vmlinux build with relocations preserved
kbuild: Introduce Kconfig symbol for linking vmlinux with relocations
kbuild: link-vmlinux.sh: Make output file name configurable
kbuild: do not generate .tmp_vmlinux*.map when CONFIG_VMLINUX_MAP=y
Revert "kheaders: Ignore silly-rename files"
...

+891 -351
+1
.gitignore
··· 65 65 /vmlinux.32 66 66 /vmlinux.map 67 67 /vmlinux.symvers 68 + /vmlinux.unstripped 68 69 /vmlinux-gdb.py 69 70 /vmlinuz 70 71 /System.map
-18
Documentation/dev-tools/checkpatch.rst
··· 342 342 343 343 See: https://www.kernel.org/doc/html/latest/RCU/whatisRCU.html#full-list-of-rcu-apis 344 344 345 - **DEPRECATED_VARIABLE** 346 - EXTRA_{A,C,CPP,LD}FLAGS are deprecated and should be replaced by the new 347 - flags added via commit f77bf01425b1 ("kbuild: introduce ccflags-y, 348 - asflags-y and ldflags-y"). 349 - 350 - The following conversion scheme maybe used:: 351 - 352 - EXTRA_AFLAGS -> asflags-y 353 - EXTRA_CFLAGS -> ccflags-y 354 - EXTRA_CPPFLAGS -> cppflags-y 355 - EXTRA_LDFLAGS -> ldflags-y 356 - 357 - See: 358 - 359 - 1. https://lore.kernel.org/lkml/20070930191054.GA15876@uranus.ravnborg.org/ 360 - 2. https://lore.kernel.org/lkml/1313384834-24433-12-git-send-email-lacombar@gmail.com/ 361 - 3. https://www.kernel.org/doc/html/latest/kbuild/makefiles.html#compilation-flags 362 - 363 345 **DEVICE_ATTR_FUNCTIONS** 364 346 The function names used in DEVICE_ATTR is unusual. 365 347 Typically, the store and show functions are used with <attr>_store and
+65
Documentation/kbuild/bash-completion.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0-only 2 + 3 + ========================== 4 + Bash completion for Kbuild 5 + ========================== 6 + 7 + The kernel build system is written using Makefiles, and Bash completion 8 + for the `make` command is available through the `bash-completion`_ project. 9 + 10 + However, the Makefiles for the kernel build are complex. The generic completion 11 + rules for the `make` command do not provide meaningful suggestions for the 12 + kernel build system, except for the options of the `make` command itself. 13 + 14 + To enhance completion for various variables and targets, the kernel source 15 + includes its own completion script at `scripts/bash-completion/make`. 16 + 17 + This script provides additional completions when working within the kernel tree. 18 + Outside the kernel tree, it defaults to the generic completion rules for the 19 + `make` command. 20 + 21 + Prerequisites 22 + ============= 23 + 24 + The script relies on helper functions provided by `bash-completion`_ project. 25 + Please ensure it is installed on your system. On most distributions, you can 26 + install the `bash-completion` package through the standard package manager. 27 + 28 + How to use 29 + ========== 30 + 31 + You can source the script directly:: 32 + 33 + $ source scripts/bash-completion/make 34 + 35 + Or, you can copy it into the search path for Bash completion scripts. 36 + For example:: 37 + 38 + $ mkdir -p ~/.local/share/bash-completion/completions 39 + $ cp scripts/bash-completion/make ~/.local/share/bash-completion/completions/ 40 + 41 + Details 42 + ======= 43 + 44 + The additional completion for Kbuild is enabled in the following cases: 45 + 46 + - You are in the root directory of the kernel source. 47 + - You are in the top-level build directory created by the O= option 48 + (checked via the `source` symlink pointing to the kernel source). 49 + - The -C make option specifies the kernel source or build directory. 50 + - The -f make option specifies a file in the kernel source or build directory. 51 + 52 + If none of the above are met, it falls back to the generic completion rules. 53 + 54 + The completion supports: 55 + 56 + - Commonly used targets, such as `all`, `menuconfig`, `dtbs`, etc. 57 + - Make (or environment) variables, such as `ARCH`, `LLVM`, etc. 58 + - Single-target builds (`foo/bar/baz.o`) 59 + - Configuration files (`*_defconfig` and `*.config`) 60 + 61 + Some variables offer intelligent behavior. For instance, `CROSS_COMPILE=` 62 + followed by a TAB displays installed toolchains. The list of defconfig files 63 + shown depends on the value of the `ARCH=` variable. 64 + 65 + .. _bash-completion: https://github.com/scop/bash-completion/
+2
Documentation/kbuild/index.rst
··· 23 23 llvm 24 24 gendwarfksyms 25 25 26 + bash-completion 27 + 26 28 .. only:: subproject and html 27 29 28 30 Indices
+18 -11
Documentation/kbuild/kconfig-language.rst
··· 194 194 ability to hook into a secondary subsystem while allowing the user to 195 195 configure that subsystem out without also having to unset these drivers. 196 196 197 - Note: If the combination of FOO=y and BAZ=m causes a link error, 198 - you can guard the function call with IS_REACHABLE():: 199 - 200 - foo_init() 201 - { 202 - if (IS_REACHABLE(CONFIG_BAZ)) 203 - baz_register(&foo); 204 - ... 205 - } 206 - 207 197 Note: If the feature provided by BAZ is highly desirable for FOO, 208 198 FOO should imply not only BAZ, but also its dependency BAR:: 209 199 ··· 578 588 depends on BAR || !BAR 579 589 580 590 This means that there is either a dependency on BAR that disallows 581 - the combination of FOO=y with BAR=m, or BAR is completely disabled. 591 + the combination of FOO=y with BAR=m, or BAR is completely disabled. The BAR 592 + module must provide all the stubs for !BAR case. 593 + 582 594 For a more formalized approach if there are multiple drivers that have 583 595 the same dependency, a helper symbol can be used, like:: 584 596 ··· 590 598 591 599 config BAR_OPTIONAL 592 600 def_tristate BAR || !BAR 601 + 602 + Much less favorable way to express optional dependency is IS_REACHABLE() within 603 + the module code, useful for example when the module BAR does not provide 604 + !BAR stubs:: 605 + 606 + foo_init() 607 + { 608 + if (IS_REACHABLE(CONFIG_BAR)) 609 + bar_register(&foo); 610 + ... 611 + } 612 + 613 + IS_REACHABLE() is generally discouraged, because the code will be silently 614 + discarded, when CONFIG_BAR=m and this code is built-in. This is not what users 615 + usually expect when enabling BAR as module. 593 616 594 617 Kconfig recursive dependency limitations 595 618 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+14 -3
Documentation/kbuild/makefiles.rst
··· 318 318 These three flags apply only to the kbuild makefile in which they 319 319 are assigned. They are used for all the normal cc, as and ld 320 320 invocations happening during a recursive build. 321 - Note: Flags with the same behaviour were previously named: 322 - EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS. 323 - They are still supported but their usage is deprecated. 324 321 325 322 ccflags-y specifies options for compiling with $(CC). 326 323 ··· 666 669 CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu-) 667 670 endif 668 671 endif 672 + 673 + $(RUSTC) support functions 674 + -------------------------- 675 + 676 + rustc-min-version 677 + rustc-min-version tests if the value of $(CONFIG_RUSTC_VERSION) is greater 678 + than or equal to the provided value and evaluates to y if so. 679 + 680 + Example:: 681 + 682 + rustflags-$(call rustc-min-version, 108500) := -Cfoo 683 + 684 + In this example, rustflags-y will be assigned the value -Cfoo if 685 + $(CONFIG_RUSTC_VERSION) is >= 1.85.0. 669 686 670 687 $(LD) support functions 671 688 -----------------------
+1 -1
Documentation/kbuild/modules.rst
··· 318 318 | |__ include 319 319 | |__ hardwareif.h 320 320 |__ include 321 - |__ complex.h 321 + |__ complex.h 322 322 323 323 To build the module complex.ko, we then need the following 324 324 kbuild file::
-17
Documentation/kbuild/reproducible-builds.rst
··· 46 46 `KBUILD_BUILD_USER and KBUILD_BUILD_HOST`_ variables. If you are 47 47 building from a git commit, you could use its committer address. 48 48 49 - Absolute filenames 50 - ------------------ 51 - 52 - When the kernel is built out-of-tree, debug information may include 53 - absolute filenames for the source files. This must be overridden by 54 - including the ``-fdebug-prefix-map`` option in the `KCFLAGS`_ variable. 55 - 56 - Depending on the compiler used, the ``__FILE__`` macro may also expand 57 - to an absolute filename in an out-of-tree build. Kbuild automatically 58 - uses the ``-fmacro-prefix-map`` option to prevent this, if it is 59 - supported. 60 - 61 - The Reproducible Builds web site has more information about these 62 - `prefix-map options`_. 63 - 64 49 Generated files in source packages 65 50 ---------------------------------- 66 51 ··· 116 131 117 132 .. _KBUILD_BUILD_TIMESTAMP: kbuild.html#kbuild-build-timestamp 118 133 .. _KBUILD_BUILD_USER and KBUILD_BUILD_HOST: kbuild.html#kbuild-build-user-kbuild-build-host 119 - .. _KCFLAGS: kbuild.html#kcflags 120 - .. _prefix-map options: https://reproducible-builds.org/docs/build-path/ 121 134 .. _Reproducible Builds project: https://reproducible-builds.org/ 122 135 .. _SOURCE_DATE_EPOCH: https://reproducible-builds.org/docs/source-date-epoch/
+1
MAINTAINERS
··· 12850 12850 F: scripts/*vmlinux* 12851 12851 F: scripts/Kbuild* 12852 12852 F: scripts/Makefile* 12853 + F: scripts/bash-completion/ 12853 12854 F: scripts/basic/ 12854 12855 F: scripts/clang-tools/ 12855 12856 F: scripts/dummy-tools/
+16 -7
Makefile
··· 151 151 152 152 export KBUILD_EXTMOD 153 153 154 - # backward compatibility 155 - KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS) 156 - 157 154 ifeq ("$(origin W)", "command line") 158 155 KBUILD_EXTRA_WARN := $(W) 159 156 endif ··· 925 928 endif 926 929 endif 927 930 931 + # Explicitly clear padding bits during variable initialization 932 + KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all) 933 + 928 934 # While VLAs have been removed, GCC produces unreachable stack probes 929 935 # for the randomize_kstack_offset feature. Disable it for all compilers. 930 936 KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection) ··· 1070 1070 1071 1071 # change __FILE__ to the relative path to the source directory 1072 1072 ifdef building_out_of_srctree 1073 - KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=) 1073 + KBUILD_CPPFLAGS += $(call cc-option,-ffile-prefix-map=$(srcroot)/=) 1074 + KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/= 1074 1075 endif 1075 1076 1076 1077 # include additional Makefiles when needed ··· 1121 1120 # linker. All sections should be explicitly named in the linker script. 1122 1121 ifdef CONFIG_LD_ORPHAN_WARN 1123 1122 LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) 1123 + endif 1124 + 1125 + ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),) 1126 + LDFLAGS_vmlinux += --emit-relocs --discard-none 1124 1127 endif 1125 1128 1126 1129 # Align the bit size of userspace programs with the kernel ··· 1369 1364 1370 1365 PHONY += headers 1371 1366 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts 1372 - $(if $(filter um, $(SRCARCH)), $(error Headers not exportable for UML)) 1367 + ifdef HEADER_ARCH 1368 + $(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers 1369 + else 1373 1370 $(Q)$(MAKE) $(hdr-inst)=include/uapi 1374 1371 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi 1372 + endif 1375 1373 1376 1374 ifdef CONFIG_HEADERS_INSTALL 1377 1375 prepare: headers ··· 1572 1564 # Directories & files removed with 'make clean' 1573 1565 CLEAN_FILES += vmlinux.symvers modules-only.symvers \ 1574 1566 modules.builtin modules.builtin.modinfo modules.nsdeps \ 1575 - modules.builtin.ranges vmlinux.o.map \ 1567 + modules.builtin.ranges vmlinux.o.map vmlinux.unstripped \ 1576 1568 compile_commands.json rust/test \ 1577 1569 rust-project.json .vmlinux.objs .vmlinux.export.c \ 1578 1570 .builtin-dtbs-list .builtin-dtb.S ··· 1675 1667 @echo ' kernelrelease - Output the release version string (use with make -s)' 1676 1668 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)' 1677 1669 @echo ' image_name - Output the image name (use with make -s)' 1678 - @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ 1670 + @echo ' headers - Build ready-to-install UAPI headers in usr/include' 1671 + @echo ' headers_install - Install sanitised kernel UAPI headers to INSTALL_HDR_PATH'; \ 1679 1672 echo ' (default: $(INSTALL_HDR_PATH))'; \ 1680 1673 echo '' 1681 1674 @echo 'Static analysers:'
+7
arch/Kconfig
··· 1699 1699 Architectures that select this option can run floating-point code in 1700 1700 the kernel, as described in Documentation/core-api/floating-point.rst. 1701 1701 1702 + config ARCH_VMLINUX_NEEDS_RELOCS 1703 + bool 1704 + help 1705 + Whether the architecture needs vmlinux to be built with static 1706 + relocations preserved. This is used by some architectures to 1707 + construct bespoke relocation tables for KASLR. 1708 + 1702 1709 source "kernel/gcov/Kconfig" 1703 1710 1704 1711 source "scripts/gcc-plugins/Kconfig"
+1 -1
arch/arm64/Makefile
··· 48 48 KBUILD_CFLAGS += $(call cc-disable-warning, psabi) 49 49 KBUILD_AFLAGS += $(compat_vdso) 50 50 51 - ifeq ($(call test-ge, $(CONFIG_RUSTC_VERSION), 108500),y) 51 + ifeq ($(call rustc-min-version, 108500),y) 52 52 KBUILD_RUSTFLAGS += --target=aarch64-unknown-none-softfloat 53 53 else 54 54 KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"
+1
arch/mips/Kconfig
··· 2618 2618 CPU_MIPS32_R6 || CPU_MIPS64_R6 || \ 2619 2619 CPU_P5600 || CAVIUM_OCTEON_SOC || \ 2620 2620 CPU_LOONGSON64 2621 + select ARCH_VMLINUX_NEEDS_RELOCS 2621 2622 help 2622 2623 This builds a kernel image that retains relocation information 2623 2624 so it can be loaded someplace besides the default 1MB.
-4
arch/mips/Makefile
··· 100 100 KBUILD_AFLAGS_MODULE += -mlong-calls 101 101 KBUILD_CFLAGS_MODULE += -mlong-calls 102 102 103 - ifeq ($(CONFIG_RELOCATABLE),y) 104 - LDFLAGS_vmlinux += --emit-relocs 105 - endif 106 - 107 103 cflags-y += -ffreestanding 108 104 109 105 cflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB
+1 -1
arch/nios2/Kbuild
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 3 - obj-y += kernel/ mm/ platform/ boot/dts/ 3 + obj-y += kernel/ mm/ platform/ 4 4 5 5 # for cleaning 6 6 subdir- += boot
+2 -2
arch/nios2/boot/dts/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - obj-y := $(patsubst %.dts,%.dtb.o,$(CONFIG_NIOS2_DTB_SOURCE)) 3 + dtb-y := $(addsuffix .dtb, $(CONFIG_BUILTIN_DTB_NAME)) 4 4 5 - dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(src)/%.dts,%.dtb, $(wildcard $(src)/*.dts)) 5 + dtb-$(CONFIG_OF_ALL_DTBS) += $(patsubst $(src)/%.dts,%.dtb, $(wildcard $(src)/*.dts))
+1 -1
arch/nios2/kernel/prom.c
··· 32 32 } 33 33 #endif 34 34 35 - #ifdef CONFIG_NIOS2_DTB_SOURCE_BOOL 35 + #ifdef CONFIG_BUILTIN_DTB 36 36 if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER) 37 37 params = (void *)__dtb_start; 38 38 #endif
+6 -5
arch/nios2/platform/Kconfig.platform
··· 35 35 help 36 36 Physical address of a dtb blob. 37 37 38 - config NIOS2_DTB_SOURCE_BOOL 38 + config BUILTIN_DTB 39 39 bool "Compile and link device tree into kernel image" 40 40 depends on !COMPILE_TEST 41 + select GENERIC_BUILTIN_DTB 41 42 help 42 43 This allows you to specify a dts (device tree source) file 43 44 which will be compiled and linked into the kernel image. 44 45 45 - config NIOS2_DTB_SOURCE 46 - string "Device tree source file" 47 - depends on NIOS2_DTB_SOURCE_BOOL 46 + config BUILTIN_DTB_NAME 47 + string "Built-in device tree name" 48 + depends on BUILTIN_DTB 48 49 default "" 49 50 help 50 - Absolute path to the device tree source (dts) file describing your 51 + Relative path to the device tree without suffix describing your 51 52 system. 52 53 53 54 comment "Nios II instructions"
+1
arch/riscv/Kconfig
··· 1108 1108 bool "Build a relocatable kernel" 1109 1109 depends on !XIP_KERNEL 1110 1110 select MODULE_SECTIONS if MODULES 1111 + select ARCH_VMLINUX_NEEDS_RELOCS 1111 1112 help 1112 1113 This builds a kernel as a Position Independent Executable (PIE), 1113 1114 which retains all relocation metadata required to relocate the
+1 -1
arch/riscv/Makefile
··· 8 8 9 9 LDFLAGS_vmlinux := -z norelro 10 10 ifeq ($(CONFIG_RELOCATABLE),y) 11 - LDFLAGS_vmlinux += -shared -Bsymbolic -z notext --emit-relocs 11 + LDFLAGS_vmlinux += -shared -Bsymbolic -z notext 12 12 KBUILD_CFLAGS += -fPIE 13 13 endif 14 14 ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
+1 -4
arch/riscv/boot/Makefile
··· 32 32 endif 33 33 34 34 ifdef CONFIG_RELOCATABLE 35 - vmlinux.relocs: vmlinux 36 - @ (! [ -f vmlinux.relocs ] && echo "vmlinux.relocs can't be found, please remove vmlinux and try again") || true 37 - 38 - $(obj)/Image: vmlinux.relocs FORCE 35 + $(obj)/Image: vmlinux.unstripped FORCE 39 36 else 40 37 $(obj)/Image: vmlinux FORCE 41 38 endif
+1
arch/s390/Kconfig
··· 631 631 632 632 config RELOCATABLE 633 633 def_bool y 634 + select ARCH_VMLINUX_NEEDS_RELOCS 634 635 help 635 636 This builds a kernel image that retains relocation information 636 637 so it can be loaded at an arbitrary address.
+1 -1
arch/s390/Makefile
··· 15 15 KBUILD_AFLAGS += -m64 16 16 KBUILD_CFLAGS += -m64 17 17 KBUILD_CFLAGS += -fPIC 18 - LDFLAGS_vmlinux := $(call ld-option,-no-pie) --emit-relocs --discard-none 18 + LDFLAGS_vmlinux := $(call ld-option,-no-pie) 19 19 extra_tools := relocs 20 20 aflags_dwarf := -Wa,-gdwarf-2 21 21 KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
+1
arch/x86/Kconfig
··· 2138 2138 config X86_NEED_RELOCS 2139 2139 def_bool y 2140 2140 depends on RANDOMIZE_BASE || (X86_32 && RELOCATABLE) 2141 + select ARCH_VMLINUX_NEEDS_RELOCS 2141 2142 2142 2143 config PHYSICAL_ALIGN 2143 2144 hex "Alignment value to which kernel should be aligned"
-6
arch/x86/Makefile
··· 245 245 246 246 KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE) 247 247 248 - ifdef CONFIG_X86_NEED_RELOCS 249 - LDFLAGS_vmlinux := --emit-relocs --discard-none 250 - else 251 - LDFLAGS_vmlinux := 252 - endif 253 - 254 248 # 255 249 # The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to 256 250 # the linker to force 2MB page size regardless of the default page size used
-1
arch/x86/boot/Makefile
··· 53 53 54 54 KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP 55 55 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ 56 - KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) 57 56 KBUILD_CFLAGS += -fno-asynchronous-unwind-tables 58 57 KBUILD_CFLAGS += $(CONFIG_CC_IMPLICIT_FALLTHROUGH) 59 58
+6 -4
arch/x86/boot/compressed/Makefile
··· 38 38 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) 39 39 KBUILD_CFLAGS += $(call cc-disable-warning, gnu) 40 40 KBUILD_CFLAGS += -Wno-pointer-sign 41 - KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) 42 41 KBUILD_CFLAGS += -fno-asynchronous-unwind-tables 43 42 KBUILD_CFLAGS += -D__DISABLE_EXPORTS 44 43 # Disable relocation relaxation in case the link is not PIE. ··· 116 117 117 118 targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs 118 119 119 - # vmlinux.relocs is created by the vmlinux postlink step. 120 - $(obj)/vmlinux.relocs: vmlinux 121 - @true 120 + CMD_RELOCS = arch/x86/tools/relocs 121 + quiet_cmd_relocs = RELOCS $@ 122 + cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $< 123 + 124 + $(obj)/vmlinux.relocs: vmlinux.unstripped FORCE 125 + $(call if_changed,relocs) 122 126 123 127 vmlinux.bin.all-y := $(obj)/vmlinux.bin 124 128 vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
-1
kernel/gen_kheaders.sh
··· 89 89 90 90 # Create archive and try to normalize metadata for reproducibility. 91 91 tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \ 92 - --exclude=".__afs*" --exclude=".nfs*" \ 93 92 --owner=0 --group=0 --sort=name --numeric-owner --mode=u=rw,go=r,a+X \ 94 93 -I $XZ -cf $tarfile -C "${tmpdir}/" . > /dev/null 95 94
+3 -4
lib/Kconfig.debug
··· 335 335 Compress the debug information using zlib. Requires GCC 5.0+ or Clang 336 336 5.0+, binutils 2.26+, and zlib. 337 337 338 - Users of dpkg-deb via scripts/package/builddeb may find an increase in 338 + Users of dpkg-deb via debian/rules may find an increase in 339 339 size of their debug .deb packages with this config set, due to the 340 340 debug info being compressed with zlib, then the object files being 341 341 recompressed with a different compression scheme. But this is still 342 - preferable to setting $KDEB_COMPRESS to "none" which would be even 343 - larger. 342 + preferable to setting KDEB_COMPRESS or DPKG_DEB_COMPRESSOR_TYPE to 343 + "none" which would be even larger. 344 344 345 345 config DEBUG_INFO_COMPRESSED_ZSTD 346 346 bool "Compress debugging information with zstd" ··· 473 473 474 474 config HEADERS_INSTALL 475 475 bool "Install uapi headers to usr/include" 476 - depends on !UML 477 476 help 478 477 This option will install uapi headers (headers exported to user-space) 479 478 into the usr/include directory for use during the kernel build.
+6 -2
rust/Makefile
··· 60 60 core-cfgs = \ 61 61 --cfg no_fp_fmt_parse 62 62 63 + # `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only 64 + # since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust 65 + # 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both 66 + # issues skipping the flag. The former also applies to `RUSTDOC TK`. 63 67 quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< 64 68 cmd_rustdoc = \ 65 69 OBJTREE=$(abspath $(objtree)) \ 66 - $(RUSTDOC) $(filter-out $(skip_flags),$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \ 70 + $(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=%,$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \ 67 71 $(rustc_target_flags) -L$(objtree)/$(obj) \ 68 72 -Zunstable-options --generate-link-to-definition \ 69 73 --output $(rustdoc_output) \ ··· 203 199 rm -rf $(objtree)/$(obj)/test/doctests/kernel; \ 204 200 mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \ 205 201 OBJTREE=$(abspath $(objtree)) \ 206 - $(RUSTDOC) --test $(rust_flags) \ 202 + $(RUSTDOC) --test $(filter-out --remap-path-prefix=%,$(rust_flags)) \ 207 203 -L$(objtree)/$(obj) --extern ffi --extern pin_init \ 208 204 --extern kernel --extern build_error --extern macros \ 209 205 --extern bindings --extern uapi \
-4
scripts/Makefile.build
··· 20 20 targets := 21 21 subdir-y := 22 22 subdir-m := 23 - EXTRA_AFLAGS := 24 - EXTRA_CFLAGS := 25 - EXTRA_CPPFLAGS := 26 - EXTRA_LDFLAGS := 27 23 asflags-y := 28 24 ccflags-y := 29 25 rustflags-y :=
+4
scripts/Makefile.compiler
··· 67 67 # Usage: cflags-$(call clang-min-version, 110000) += -foo 68 68 clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1) 69 69 70 + # rustc-min-version 71 + # Usage: rustc-$(call rustc-min-version, 108500) += -Cfoo 72 + rustc-min-version = $(call test-ge, $(CONFIG_RUSTC_VERSION), $1) 73 + 70 74 # ld-option 71 75 # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) 72 76 ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
-3
scripts/Makefile.extrawarn
··· 82 82 # Warn if there is an enum types mismatch 83 83 KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion) 84 84 85 - # Explicitly clear padding bits during variable initialization 86 - KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all) 87 - 88 85 KBUILD_CFLAGS += -Wextra 89 86 KBUILD_CFLAGS += -Wunused 90 87
-8
scripts/Makefile.lib
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - # Backward compatibility 3 - asflags-y += $(EXTRA_AFLAGS) 4 - ccflags-y += $(EXTRA_CFLAGS) 5 - cppflags-y += $(EXTRA_CPPFLAGS) 6 - ldflags-y += $(EXTRA_LDFLAGS) 7 2 8 3 # flags that take effect in current and sub directories 9 4 KBUILD_AFLAGS += $(subdir-asflags-y) ··· 371 376 372 377 quiet_cmd_objcopy = OBJCOPY $@ 373 378 cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ 374 - 375 - quiet_cmd_strip_relocs = RSTRIP $@ 376 - cmd_strip_relocs = $(OBJCOPY) --remove-section='.rel*' $@ 377 379 378 380 # Gzip 379 381 # ---------------------------------------------------------------------------
+26 -8
scripts/Makefile.vmlinux
··· 9 9 10 10 targets := 11 11 12 + ifdef CONFIG_ARCH_VMLINUX_NEEDS_RELOCS 13 + vmlinux-final := vmlinux.unstripped 14 + 15 + quiet_cmd_strip_relocs = RSTRIP $@ 16 + cmd_strip_relocs = $(OBJCOPY) --remove-section='.rel*' $< $@ 17 + 18 + vmlinux: $(vmlinux-final) FORCE 19 + $(call if_changed,strip_relocs) 20 + 21 + targets += vmlinux 22 + else 23 + vmlinux-final := vmlinux 24 + endif 25 + 12 26 %.o: %.c FORCE 13 27 $(call if_changed_rule,cc_o_c) 14 28 ··· 61 47 62 48 ifdef CONFIG_GENERIC_BUILTIN_DTB 63 49 targets += .builtin-dtbs.S .builtin-dtbs.o 64 - vmlinux: .builtin-dtbs.o 50 + $(vmlinux-final): .builtin-dtbs.o 65 51 endif 66 52 67 53 # vmlinux ··· 69 55 70 56 ifdef CONFIG_MODULES 71 57 targets += .vmlinux.export.o 72 - vmlinux: .vmlinux.export.o 58 + $(vmlinux-final): .vmlinux.export.o 73 59 endif 74 60 75 61 ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX 76 - vmlinux: arch/$(SRCARCH)/tools/vmlinux.arch.o 62 + $(vmlinux-final): arch/$(SRCARCH)/tools/vmlinux.arch.o 77 63 78 64 arch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE 79 65 $(Q)$(MAKE) $(build)=arch/$(SRCARCH)/tools $@ ··· 83 69 84 70 # Final link of vmlinux with optional arch pass after final link 85 71 cmd_link_vmlinux = \ 86 - $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \ 72 + $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \ 87 73 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 88 74 89 - targets += vmlinux 90 - vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE 75 + targets += $(vmlinux-final) 76 + $(vmlinux-final): scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE 91 77 +$(call if_changed_dep,link_vmlinux) 92 78 ifdef CONFIG_DEBUG_INFO_BTF 93 - vmlinux: $(RESOLVE_BTFIDS) 79 + $(vmlinux-final): $(RESOLVE_BTFIDS) 80 + endif 81 + 82 + ifdef CONFIG_BUILDTIME_TABLE_SORT 83 + vmlinux: scripts/sorttable 94 84 endif 95 85 96 86 # module.builtin.ranges ··· 110 92 modules.builtin vmlinux.map vmlinux.o.map FORCE 111 93 $(call if_changed,modules_builtin_ranges) 112 94 113 - vmlinux.map: vmlinux 95 + vmlinux.map: $(vmlinux-final) 114 96 @: 115 97 116 98 endif
+451
scripts/bash-completion/make
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + # bash completion for GNU make with kbuild extension -*- shell-script -*- 3 + 4 + # Load the default completion script for make. It is typically located at 5 + # /usr/share/bash-completion/completions/make, but we do not rely on it. 6 + __kbuild_load_default_make_completion() 7 + { 8 + local -a dirs=("${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions") 9 + local ifs=$IFS IFS=: dir compfile this_dir 10 + 11 + for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do 12 + dirs+=("$dir"/bash-completion/completions) 13 + done 14 + IFS=$ifs 15 + 16 + this_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" 17 + 18 + for dir in "${dirs[@]}"; do 19 + if [[ ! -d ${dir} || ${dir} = "${this_dir}" ]]; then 20 + continue 21 + fi 22 + 23 + for compfile in make make.bash _make; do 24 + compfile=$dir/$compfile 25 + # Avoid trying to source dirs; https://bugzilla.redhat.com/903540 26 + if [[ -f ${compfile} ]] && . "${compfile}" &>/dev/null; then 27 + 28 + __kbuild_default_make_completion=$( 29 + # shellcheck disable=SC2046 # word splitting is the point here 30 + set -- $(complete -p make) 31 + 32 + while [[ $# -gt 1 && "$1" != -F ]]; do 33 + shift 34 + done 35 + 36 + if [[ "$1" = -F ]]; then 37 + echo "$2" 38 + fi 39 + ) 40 + 41 + return 42 + fi 43 + done 44 + done 45 + } 46 + 47 + __kbuild_load_default_make_completion 48 + 49 + __kbuild_handle_variable() 50 + { 51 + local var=${1%%=*} 52 + local cur=${cur#"${var}"=} 53 + local srctree=$2 54 + local keywords=() 55 + 56 + case $var in 57 + ARCH) 58 + # sub-directories under arch/ 59 + keywords+=($(find "${srctree}/arch" -mindepth 1 -maxdepth 1 -type d -printf '%P\n')) 60 + # architectures hard-coded in the top Makefile 61 + keywords+=(i386 x86_64 sparc32 sparc64 parisc64) 62 + ;; 63 + CROSS_COMPILE) 64 + # toolchains with a full path 65 + local cross_compile=() 66 + local c c2 67 + _filedir 68 + 69 + for c in "${COMPREPLY[@]}"; do 70 + # eval for tilde expansion 71 + # suppress error, as this fails when it contains a space 72 + eval "c2=${c}" 2>/dev/null || continue 73 + if [[ ${c} == *-elfedit && ! -d ${c2} && -x ${c2} ]]; then 74 + cross_compile+=("${c%elfedit}") 75 + fi 76 + done 77 + 78 + # toolchains in the PATH environment 79 + while read -r c; do 80 + if [[ ${c} == *-elfedit ]]; then 81 + keywords+=("${c%elfedit}") 82 + fi 83 + done < <(compgen -c) 84 + 85 + COMPREPLY=() 86 + _filedir -d 87 + 88 + # Add cross_compile directly without passing it to compgen. 89 + # Otherwise, toolchain paths with a tilde do not work. 90 + # e.g.) 91 + # CROSS_COMPILE=~/0day/gcc-14.2.0-nolibc/aarch64-linux/bin/aarch64-linux- 92 + COMPREPLY+=("${cross_compile[@]}") 93 + ;; 94 + LLVM) 95 + # LLVM=1 uses the default 'clang' etc. 96 + keywords+=(1) 97 + 98 + # suffix for a particular version. LLVM=-18 uses 'clang-18' etc. 99 + while read -r c; do 100 + if [[ ${c} == clang-[0-9]* ]]; then 101 + keywords+=("${c#clang}") 102 + fi 103 + done < <(compgen -c) 104 + 105 + # directory path to LLVM toolchains 106 + _filedir -d 107 + ;; 108 + KCONFIG_ALLCONFIG) 109 + # KCONFIG_ALLCONFIG=1 selects the default fragment 110 + keywords+=(1) 111 + # or the path to a fragment file 112 + _filedir 113 + ;; 114 + C | KBUILD_CHECKSRC) 115 + keywords+=(1 2) 116 + ;; 117 + V | KBUILD_VERBOSE) 118 + keywords+=({,1}{,2}) 119 + ;; 120 + W | KBUILD_EXTRA_WARN) 121 + keywords+=({,1}{,2}{,3}{,c}{,e}) 122 + ;; 123 + KBUILD_ABS_SRCTREE | KBUILD_MODPOST_NOFINAL | KBUILD_MODPOST_WARN | \ 124 + CLIPPY | KBUILD_CLIPPY | KCONFIG_NOSILENTUPDATE | \ 125 + KCONFIG_OVERWRITECONFIG | KCONFIG_WARN_UNKNOWN_SYMBOL | \ 126 + KCONFIG_WERROR ) 127 + keywords+=(1) 128 + ;; 129 + INSTALL_MOD_STRIP) 130 + keywords+=(1 --strip-debug --strip-unneeded) 131 + ;; 132 + O | KBUILD_OUTPUT | M | KBUILD_EXTMOD | MO | KBUILD_EXTMOD_OUTPUT | *_PATH) 133 + # variables that take a directory. 134 + _filedir -d 135 + return 136 + ;; 137 + KBUILD_EXTRA_SYMBOL | KBUILD_KCONFIG | KCONFIG_CONFIG) 138 + # variables that take a file. 139 + _filedir 140 + return 141 + esac 142 + 143 + COMPREPLY+=($(compgen -W "${keywords[*]}" -- "${cur}")) 144 + } 145 + 146 + # Check the -C, -f options and 'source' symlink. Return the source tree we are 147 + # working in. 148 + __kbuild_get_srctree() 149 + { 150 + local words=("$@") 151 + local cwd makef_dir 152 + 153 + # see if a path was specified with -C/--directory 154 + for ((i = 1; i < ${#words[@]}; i++)); do 155 + if [[ ${words[i]} == -@(C|-directory) ]]; then 156 + # eval for tilde expansion. 157 + # suppress error, as this fails when it contains a space 158 + eval "cwd=${words[i + 1]}" 2>/dev/null 159 + break 160 + fi 161 + done 162 + 163 + if [[ -z ${cwd} ]]; then 164 + cwd=. 165 + fi 166 + 167 + # see if a Makefile was specified with -f/--file/--makefile 168 + for ((i = 1; i < ${#words[@]}; i++)); do 169 + if [[ ${words[i]} == -@(f|-?(make)file) ]]; then 170 + # eval for tilde expansion 171 + # suppress error, as this fails when it contains a space 172 + eval "makef_dir=${words[i + 1]%/*}" 2>/dev/null 173 + break 174 + fi 175 + done 176 + 177 + if [ -z "${makef_dir}" ]; then 178 + makef_dir=${cwd} 179 + elif [[ ${makef_dir} != /* ]]; then 180 + makef_dir=${cwd}/${makef_dir} 181 + fi 182 + 183 + # If ${makef_dir} is a build directory created by the O= option, there 184 + # is a symbolic link 'source', which points to the kernel source tree. 185 + if [[ -L ${makef_dir}/source ]]; then 186 + makef_dir=$(readlink "${makef_dir}/source") 187 + fi 188 + 189 + echo "${makef_dir}" 190 + } 191 + 192 + # Get SRCARCH to do a little more clever things 193 + __kbuild_get_srcarch() 194 + { 195 + local words=("$@") 196 + local arch srcarch uname_m 197 + 198 + # see if ARCH= is explicitly specified 199 + for ((i = 1; i < ${#words[@]}; i++)); do 200 + if [[ ${words[i]} == ARCH=* ]]; then 201 + arch=${words[i]#ARCH=} 202 + break 203 + fi 204 + done 205 + 206 + # If ARCH= is not specified, check the build marchine's architecture 207 + if [[ -z ${arch} ]]; then 208 + uname_m=$(uname -m) 209 + 210 + # shellcheck disable=SC2209 # 'sh' is SuperH, not a shell command 211 + case ${uname_m} in 212 + arm64 | aarch64*) arch=arm64 ;; 213 + arm* | sa110) arch=arm ;; 214 + i?86 | x86_64) arch=x86 ;; 215 + loongarch*) arch=loongarch ;; 216 + mips*) arch=mips ;; 217 + ppc*) arch=powerpc ;; 218 + riscv*) arch=riscv ;; 219 + s390x) arch=s390 ;; 220 + sh[234]*) arch=sh ;; 221 + sun4u) arch=sparc64 ;; 222 + *) arch=${uname_m} ;; 223 + esac 224 + fi 225 + 226 + case ${arch} in 227 + parisc64) srcarch=parisc ;; 228 + sparc32 | sparc64) srcarch=sparc ;; 229 + i386 | x86_64) srcarch=x86 ;; 230 + *) srcarch=${arch} ;; 231 + esac 232 + 233 + echo "$srcarch" 234 + } 235 + 236 + # small Makefile to parse obj-* syntax 237 + __kbuild_tmp_makefile() 238 + { 239 + cat <<'EOF' 240 + .PHONY: __default 241 + __default: 242 + $(foreach m,$(obj-y) $(obj-m) $(obj-),$(foreach s, -objs -y -m -,$($(m:%.o=%$s))) $(m)) 243 + EOF 244 + echo "include ${1}" 245 + } 246 + 247 + _make_for_kbuild () 248 + { 249 + # shellcheck disable=SC2034 # these are set by _init_completion 250 + local cur prev words cword split 251 + _init_completion -s || return 252 + 253 + local srctree 254 + srctree=$(__kbuild_get_srctree "${words[@]}") 255 + 256 + # If 'kernel' and 'Documentation' directories are found, we assume this 257 + # is a kernel tree. Otherwise, we fall back to the generic rule provided 258 + # by the bash-completion project. 259 + if [[ ! -d ${srctree}/kernel || ! -d ${srctree}/Documentation ]]; then 260 + if [ -n "${__kbuild_default_make_completion}" ]; then 261 + "${__kbuild_default_make_completion}" "$@" 262 + fi 263 + return 264 + fi 265 + 266 + # make options with a parameter (copied from the bash-completion project) 267 + case ${prev} in 268 + --file | --makefile | --old-file | --assume-old | --what-if | --new-file | \ 269 + --assume-new | -!(-*)[foW]) 270 + _filedir 271 + return 272 + ;; 273 + --include-dir | --directory | -!(-*)[ICm]) 274 + _filedir -d 275 + return 276 + ;; 277 + -!(-*)E) 278 + COMPREPLY=($(compgen -v -- "$cur")) 279 + return 280 + ;; 281 + --eval | -!(-*)[DVx]) 282 + return 283 + ;; 284 + --jobs | -!(-*)j) 285 + COMPREPLY=($(compgen -W "{1..$(($(_ncpus) * 2))}" -- "$cur")) 286 + return 287 + ;; 288 + esac 289 + 290 + local keywords=() 291 + 292 + case ${cur} in 293 + -*) 294 + # make options (copied from the bash-completion project) 295 + local opts 296 + opts="$(_parse_help "$1")" 297 + COMPREPLY=($(compgen -W "${opts:-$(_parse_usage "$1")}" -- "$cur")) 298 + if [[ ${COMPREPLY-} == *= ]]; then 299 + compopt -o nospace 300 + fi 301 + return 302 + ;; 303 + *=*) 304 + __kbuild_handle_variable "${cur}" "${srctree}" 305 + return 306 + ;; 307 + KBUILD_*) 308 + # There are many variables prefixed with 'KBUILD_'. 309 + # Display them only when 'KBUILD_' is entered. 310 + # shellcheck disable=SC2191 # '=' is appended for variables 311 + keywords+=( 312 + KBUILD_{CHECKSRC,EXTMOD,EXTMOD_OUTPUT,OUTPUT,VERBOSE,EXTRA_WARN,CLIPPY}= 313 + KBUILD_BUILD_{USER,HOST,TIMESTAMP}= 314 + KBUILD_MODPOST_{NOFINAL,WARN}= 315 + KBUILD_{ABS_SRCTREE,EXTRA_SYMBOLS,KCONFIG}= 316 + ) 317 + ;; 318 + KCONFIG_*) 319 + # There are many variables prefixed with 'KCONFIG_'. 320 + # Display them only when 'KCONFIG_' is entered. 321 + # shellcheck disable=SC2191 # '=' is appended for variables 322 + keywords+=( 323 + KCONFIG_{CONFIG,ALLCONFIG,NOSILENTUPDATE,OVERWRITECONFIG}= 324 + KCONFIG_{SEED,PROBABILITY}= 325 + KCONFIG_WARN_UNKNOWN_SYMBOL= 326 + KCONFIG_WERROR= 327 + ) 328 + ;; 329 + *) 330 + # By default, hide KBUILD_* and KCONFIG_* variables. 331 + # Instead, display only the prefix parts. 332 + keywords+=(KBUILD_ KCONFIG_) 333 + ;; 334 + esac 335 + 336 + if [[ ${cur} != /* && ${cur} != *//* ]]; then 337 + local dir srcarch kbuild_file tmp 338 + srcarch=$(__kbuild_get_srcarch "${words[@]}") 339 + 340 + # single build 341 + dir=${cur} 342 + while true; do 343 + if [[ ${dir} == */* ]]; then 344 + dir=${dir%/*} 345 + else 346 + dir=. 347 + fi 348 + 349 + # Search for 'Kbuild' or 'Makefile' in the parent 350 + # directories (may not be a direct parent) 351 + if [[ -f ${srctree}/${dir}/Kbuild ]]; then 352 + kbuild_file=${srctree}/${dir}/Kbuild 353 + break 354 + fi 355 + if [[ -f ${srctree}/${dir}/Makefile ]]; then 356 + kbuild_file=${srctree}/${dir}/Makefile 357 + break 358 + fi 359 + 360 + if [[ ${dir} == . ]]; then 361 + break 362 + fi 363 + done 364 + 365 + if [[ -n ${kbuild_file} ]]; then 366 + tmp=($(__kbuild_tmp_makefile "${kbuild_file}" | 367 + SRCARCH=${srcarch} obj=${dir} src=${srctree}/${dir} \ 368 + "${1}" -n -f - 2>/dev/null)) 369 + 370 + # Add $(obj)/ prefix 371 + if [[ ${dir} != . ]]; then 372 + tmp=("${tmp[@]/#/${dir}\/}") 373 + fi 374 + 375 + keywords+=("${tmp[@]}") 376 + fi 377 + 378 + # *_defconfig and *.config files. These might be grouped into 379 + # subdirectories, e.g., arch/powerpc/configs/*/*_defconfig. 380 + if [[ ${cur} == */* ]]; then 381 + dir=${cur%/*} 382 + else 383 + dir=. 384 + fi 385 + 386 + tmp=($(find "${srctree}/arch/${srcarch}/configs/${dir}" \ 387 + "${srctree}/kernel/configs/${dir}" \ 388 + -mindepth 1 -maxdepth 1 -type d -printf '%P/\n' \ 389 + -o -printf '%P\n' 2>/dev/null)) 390 + 391 + if [[ ${dir} != . ]]; then 392 + tmp=("${tmp[@]/#/${dir}\/}") 393 + fi 394 + 395 + keywords+=("${tmp[@]}") 396 + fi 397 + 398 + # shellcheck disable=SC2191 # '=' is appended for variables 399 + keywords+=( 400 + # 401 + # variables (append =) 402 + # 403 + ARCH= 404 + CROSS_COMPILE= 405 + LLVM= 406 + C= M= MO= O= V= W= 407 + INSTALL{,_MOD,_HDR,_DTBS}_PATH= 408 + KERNELRELEASE= 409 + 410 + # 411 + # targets 412 + # 413 + all help 414 + clean mrproper distclean 415 + clang-{tidy,analyzer} compile_commands.json 416 + coccicheck 417 + dtbs{,_check,_install} dt_binding_{check,schemas} 418 + headers{,_install} 419 + vmlinux install 420 + modules{,_prepare,_install,_sign} 421 + vdso_install 422 + tags TAGS cscope gtags 423 + rust{available,fmt,fmtcheck} 424 + kernel{version,release} image_name 425 + kselftest{,-all,-install,-clean,-merge} 426 + 427 + # configuration 428 + {,old,olddef,sync,def,savedef,rand,listnew,helpnew,test,tiny}config 429 + {,build_}{menu,n,g,x}config 430 + local{mod,yes}config 431 + all{no,yes,mod,def}config 432 + {yes2mod,mod2yes,mod2no}config 433 + 434 + # docs 435 + {html,textinfo,info,latex,pdf,epub,xml,linkcheck,refcheck,clean}docs 436 + 437 + # package 438 + {,bin,src}{rpm,deb}-pkg 439 + {pacman,dir,tar}-pkg 440 + tar{,gz,bz2,xz,zst}-pkg 441 + perf-tar{,gz,bz2,xz,zst}-src-pkg 442 + ) 443 + 444 + COMPREPLY=($(compgen -W "${keywords[*]}" -- "${cur}")) 445 + 446 + # Do not append a space for variables, subdirs, "KBUILD_", "KCONFIG_". 447 + if [[ ${COMPREPLY-} == *[=/] || ${COMPREPLY-} =~ ^(KBUILD|KCONFIG)_$ ]]; then 448 + compopt -o nospace 449 + fi 450 + 451 + } && complete -F _make_for_kbuild make
-14
scripts/checkpatch.pl
··· 3690 3690 } 3691 3691 } 3692 3692 3693 - if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && 3694 - ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { 3695 - my $flag = $1; 3696 - my $replacement = { 3697 - 'EXTRA_AFLAGS' => 'asflags-y', 3698 - 'EXTRA_CFLAGS' => 'ccflags-y', 3699 - 'EXTRA_CPPFLAGS' => 'cppflags-y', 3700 - 'EXTRA_LDFLAGS' => 'ldflags-y', 3701 - }; 3702 - 3703 - WARN("DEPRECATED_VARIABLE", 3704 - "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag}); 3705 - } 3706 - 3707 3693 # check for DT compatible documentation 3708 3694 if (defined $root && 3709 3695 (($realfile =~ /\.dtsi?$/ && $line =~ /^\+\s*compatible\s*=\s*\"/) ||
+4 -4
scripts/clang-tools/gen_compile_commands.py
··· 167 167 root_directory or file_directory. 168 168 """ 169 169 # The .cmd files are intended to be included directly by Make, so they 170 - # escape the pound sign '#', either as '\#' or '$(pound)' (depending on the 171 - # kernel version). The compile_commands.json file is not interepreted 172 - # by Make, so this code replaces the escaped version with '#'. 173 - prefix = command_prefix.replace(r'\#', '#').replace('$(pound)', '#') 170 + # escape the pound sign '#' as '$(pound)'. The compile_commands.json file 171 + # is not interepreted by Make, so this code replaces the escaped version 172 + # with '#'. 173 + prefix = command_prefix.replace('$(pound)', '#') 174 174 175 175 # Return the canonical path, eliminating any symbolic links encountered in the path. 176 176 abs_path = os.path.realpath(os.path.join(root_directory, file_path))
+16 -10
scripts/config
··· 32 32 Disable option directly after other option 33 33 --module-after|-M beforeopt option 34 34 Turn option into module directly after other option 35 + --refresh Refresh the config using old settings 35 36 36 37 commands can be repeated multiple times 37 38 ··· 125 124 txt_delete "^# $name is not set" "$FN" 126 125 } 127 126 128 - if [ "$1" = "--file" ]; then 129 - FN="$2" 130 - if [ "$FN" = "" ] ; then 131 - usage 127 + FN=.config 128 + CMDS=() 129 + while [[ $# -gt 0 ]]; do 130 + if [ "$1" = "--file" ]; then 131 + if [ "$2" = "" ]; then 132 + usage 133 + fi 134 + FN="$2" 135 + shift 2 136 + else 137 + CMDS+=("$1") 138 + shift 132 139 fi 133 - shift 2 134 - else 135 - FN=.config 136 - fi 140 + done 137 141 142 + set -- "${CMDS[@]}" 138 143 if [ "$1" = "" ] ; then 139 144 usage 140 145 fi ··· 224 217 set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A" 225 218 ;; 226 219 227 - # undocumented because it ignores --file (fixme) 228 220 --refresh) 229 - yes "" | make oldconfig 221 + yes "" | make oldconfig KCONFIG_CONFIG=$FN 230 222 ;; 231 223 232 224 *)
+1 -1
scripts/gendwarfksyms/die.c
··· 6 6 #include <string.h> 7 7 #include "gendwarfksyms.h" 8 8 9 - #define DIE_HASH_BITS 15 9 + #define DIE_HASH_BITS 16 10 10 11 11 /* {die->addr, state} -> struct die * */ 12 12 static HASHTABLE_DEFINE(die_map, 1 << DIE_HASH_BITS);
+83 -71
scripts/gendwarfksyms/dwarf.c
··· 3 3 * Copyright (C) 2024 Google LLC 4 4 */ 5 5 6 + #define _GNU_SOURCE 6 7 #include <assert.h> 7 8 #include <inttypes.h> 8 9 #include <stdarg.h> ··· 194 193 va_end(args); 195 194 } 196 195 197 - #define MAX_FQN_SIZE 64 198 - 199 - /* Get a fully qualified name from DWARF scopes */ 200 - static char *get_fqn(Dwarf_Die *die) 201 - { 202 - const char *list[MAX_FQN_SIZE]; 203 - Dwarf_Die *scopes = NULL; 204 - bool has_name = false; 205 - char *fqn = NULL; 206 - char *p; 207 - int count = 0; 208 - int len = 0; 209 - int res; 210 - int i; 211 - 212 - res = checkp(dwarf_getscopes_die(die, &scopes)); 213 - if (!res) { 214 - list[count] = get_name_attr(die); 215 - 216 - if (!list[count]) 217 - return NULL; 218 - 219 - len += strlen(list[count]); 220 - count++; 221 - 222 - goto done; 223 - } 224 - 225 - for (i = res - 1; i >= 0 && count < MAX_FQN_SIZE; i--) { 226 - if (dwarf_tag(&scopes[i]) == DW_TAG_compile_unit) 227 - continue; 228 - 229 - list[count] = get_name_attr(&scopes[i]); 230 - 231 - if (list[count]) { 232 - has_name = true; 233 - } else { 234 - list[count] = "<anonymous>"; 235 - has_name = false; 236 - } 237 - 238 - len += strlen(list[count]); 239 - count++; 240 - 241 - if (i > 0) { 242 - list[count++] = "::"; 243 - len += 2; 244 - } 245 - } 246 - 247 - free(scopes); 248 - 249 - if (count == MAX_FQN_SIZE) 250 - warn("increase MAX_FQN_SIZE: reached the maximum"); 251 - 252 - /* Consider the DIE unnamed if the last scope doesn't have a name */ 253 - if (!has_name) 254 - return NULL; 255 - done: 256 - fqn = xmalloc(len + 1); 257 - *fqn = '\0'; 258 - 259 - p = fqn; 260 - for (i = 0; i < count; i++) 261 - p = stpcpy(p, list[i]); 262 - 263 - return fqn; 264 - } 265 - 266 196 static void update_fqn(struct die *cache, Dwarf_Die *die) 267 197 { 268 - if (!cache->fqn) 269 - cache->fqn = get_fqn(die) ?: ""; 198 + struct die *fqn; 199 + 200 + if (!cache->fqn) { 201 + if (!__die_map_get((uintptr_t)die->addr, DIE_FQN, &fqn) && 202 + *fqn->fqn) 203 + cache->fqn = xstrdup(fqn->fqn); 204 + else 205 + cache->fqn = ""; 206 + } 270 207 } 271 208 272 209 static void process_fqn(struct die *cache, Dwarf_Die *die) ··· 1087 1148 cache_free(&state.expansion_cache); 1088 1149 } 1089 1150 1151 + static int resolve_fqns(struct state *parent, struct die *unused, 1152 + Dwarf_Die *die) 1153 + { 1154 + struct state state; 1155 + struct die *cache; 1156 + const char *name; 1157 + bool use_prefix; 1158 + char *prefix = NULL; 1159 + char *fqn = ""; 1160 + int tag; 1161 + 1162 + if (!__die_map_get((uintptr_t)die->addr, DIE_FQN, &cache)) 1163 + return 0; 1164 + 1165 + tag = dwarf_tag(die); 1166 + 1167 + /* 1168 + * Only namespaces and structures need to pass a prefix to the next 1169 + * scope. 1170 + */ 1171 + use_prefix = tag == DW_TAG_namespace || tag == DW_TAG_class_type || 1172 + tag == DW_TAG_structure_type; 1173 + 1174 + state.expand.current_fqn = NULL; 1175 + name = get_name_attr(die); 1176 + 1177 + if (parent && parent->expand.current_fqn && (use_prefix || name)) { 1178 + /* 1179 + * The fqn for the current DIE, and if needed, a prefix for the 1180 + * next scope. 1181 + */ 1182 + if (asprintf(&prefix, "%s::%s", parent->expand.current_fqn, 1183 + name ? name : "<anonymous>") < 0) 1184 + error("asprintf failed"); 1185 + 1186 + if (use_prefix) 1187 + state.expand.current_fqn = prefix; 1188 + 1189 + /* 1190 + * Use fqn only if the DIE has a name. Otherwise fqn will 1191 + * remain empty. 1192 + */ 1193 + if (name) { 1194 + fqn = prefix; 1195 + /* prefix will be freed by die_map. */ 1196 + prefix = NULL; 1197 + } 1198 + } else if (name) { 1199 + /* No prefix from the previous scope. Use only the name. */ 1200 + fqn = xstrdup(name); 1201 + 1202 + if (use_prefix) 1203 + state.expand.current_fqn = fqn; 1204 + } 1205 + 1206 + /* If the DIE has a non-empty name, cache it. */ 1207 + if (*fqn) { 1208 + cache = die_map_get(die, DIE_FQN); 1209 + /* Move ownership of fqn to die_map. */ 1210 + cache->fqn = fqn; 1211 + cache->state = DIE_FQN; 1212 + } 1213 + 1214 + check(process_die_container(&state, NULL, die, resolve_fqns, 1215 + match_all)); 1216 + 1217 + free(prefix); 1218 + return 0; 1219 + } 1220 + 1090 1221 void process_cu(Dwarf_Die *cudie) 1091 1222 { 1223 + check(process_die_container(NULL, NULL, cudie, resolve_fqns, 1224 + match_all)); 1225 + 1092 1226 check(process_die_container(NULL, NULL, cudie, process_exported_symbols, 1093 1227 match_all)); 1094 1228
+2
scripts/gendwarfksyms/gendwarfksyms.h
··· 139 139 140 140 enum die_state { 141 141 DIE_INCOMPLETE, 142 + DIE_FQN, 142 143 DIE_UNEXPANDED, 143 144 DIE_COMPLETE, 144 145 DIE_SYMBOL, ··· 171 170 { 172 171 switch (state) { 173 172 CASE_CONST_TO_STR(DIE_INCOMPLETE) 173 + CASE_CONST_TO_STR(DIE_FQN) 174 174 CASE_CONST_TO_STR(DIE_UNEXPANDED) 175 175 CASE_CONST_TO_STR(DIE_COMPLETE) 176 176 CASE_CONST_TO_STR(DIE_SYMBOL)
+1 -1
scripts/gendwarfksyms/types.c
··· 248 248 warn("found incomplete cache entry: %p", cache); 249 249 return NULL; 250 250 } 251 - if (cache->state == DIE_SYMBOL) 251 + if (cache->state == DIE_SYMBOL || cache->state == DIE_FQN) 252 252 return NULL; 253 253 if (!cache->fqn || !*cache->fqn) 254 254 return NULL;
+5
scripts/generate_builtin_ranges.awk
··· 282 282 # section. 283 283 # 284 284 ARGIND == 2 && sect && NF == 4 && /^ [^ \*]/ && !($1 in sect_addend) { 285 + # There are a few sections with constant data (without symbols) that 286 + # can get resized during linking, so it is best to ignore them. 287 + if ($1 ~ /^\.rodata\.(cst|str)[0-9]/) 288 + next; 289 + 285 290 if (!($1 in sect_base)) { 286 291 sect_base[$1] = base; 287 292
+1 -5
scripts/genksyms/lex.l
··· 176 176 switch (lexstate) 177 177 { 178 178 case ST_NORMAL: 179 + APP; 179 180 switch (token) 180 181 { 181 182 case IDENT: 182 - APP; 183 183 { 184 184 int r = is_reserved_word(yytext, yyleng); 185 185 if (r >= 0) ··· 224 224 break; 225 225 226 226 case '[': 227 - APP; 228 227 lexstate = ST_BRACKET; 229 228 count = 1; 230 229 goto repeat; 231 230 232 231 case '{': 233 - APP; 234 232 if (dont_want_brace_phrase) 235 233 break; 236 234 lexstate = ST_BRACE; ··· 236 238 goto repeat; 237 239 238 240 case '=': case ':': 239 - APP; 240 241 lexstate = ST_EXPRESSION; 241 242 break; 242 243 243 244 default: 244 - APP; 245 245 break; 246 246 } 247 247 break;
+12 -7
scripts/kconfig/confdata.c
··· 385 385 386 386 def_flags = SYMBOL_DEF << def; 387 387 for_all_symbols(sym) { 388 - sym->flags &= ~(def_flags|SYMBOL_VALID); 388 + sym->flags &= ~def_flags; 389 389 switch (sym->type) { 390 390 case S_INT: 391 391 case S_HEX: ··· 398 398 } 399 399 } 400 400 401 - expr_invalidate_all(); 401 + if (def == S_DEF_USER) { 402 + for_all_symbols(sym) 403 + sym->flags &= ~SYMBOL_VALID; 404 + expr_invalidate_all(); 405 + } 402 406 403 407 while (getline_stripped(&line, &line_asize, in) != -1) { 404 408 struct menu *choice; ··· 466 462 conf_warning("override: reassigning to symbol %s", sym->name); 467 463 468 464 if (conf_set_sym_val(sym, def, def_flags, val)) 465 + continue; 466 + 467 + if (def != S_DEF_USER) 469 468 continue; 470 469 471 470 /* ··· 974 967 depfile_path[depfile_prefix_len] = 0; 975 968 976 969 conf_read_simple(name, S_DEF_AUTO); 977 - sym_calc_value(modules_sym); 978 970 979 971 for_all_symbols(sym) { 980 - sym_calc_value(sym); 981 972 if (sym_is_choice(sym)) 982 973 continue; 983 974 if (sym->flags & SYMBOL_WRITE) { ··· 1089 1084 if (ret) 1090 1085 return -1; 1091 1086 1092 - if (conf_touch_deps()) 1093 - return 1; 1094 - 1095 1087 for_all_symbols(sym) 1096 1088 sym_calc_value(sym); 1089 + 1090 + if (conf_touch_deps()) 1091 + return 1; 1097 1092 1098 1093 ret = __conf_write_autoconf(conf_get_autoheader_name(), 1099 1094 print_symbol_for_c,
+2 -2
scripts/kconfig/merge_config.sh
··· 112 112 shift; 113 113 114 114 if [ ! -r "$INITFILE" ]; then 115 - echo "The base file '$INITFILE' does not exist. Exit." >&2 116 - exit 1 115 + echo "The base file '$INITFILE' does not exist. Creating one..." >&2 116 + touch "$INITFILE" 117 117 fi 118 118 119 119 MERGE_LIST=$*
+1 -1
scripts/kconfig/symbol.c
··· 879 879 default: 880 880 ; 881 881 } 882 - return (const char *)sym->curr.val; 882 + return sym->curr.val; 883 883 } 884 884 885 885 bool sym_is_changeable(const struct symbol *sym)
+20 -25
scripts/mod/modpost.c
··· 98 98 return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; 99 99 } 100 100 101 + /** 102 + * get_basename - return the last part of a pathname. 103 + * 104 + * @path: path to extract the filename from. 105 + */ 106 + const char *get_basename(const char *path) 107 + { 108 + const char *tail = strrchr(path, '/'); 109 + 110 + return tail ? tail + 1 : path; 111 + } 112 + 101 113 char *read_text_file(const char *filename) 102 114 { 103 115 struct stat st; ··· 1473 1461 const char *base; 1474 1462 int dirlen, ret; 1475 1463 1476 - base = strrchr(object, '/'); 1477 - if (base) { 1478 - base++; 1479 - dirlen = base - object; 1480 - } else { 1481 - dirlen = 0; 1482 - base = object; 1483 - } 1464 + base = get_basename(object); 1465 + dirlen = base - object; 1484 1466 1485 1467 ret = snprintf(cmd_file, sizeof(cmd_file), "%.*s.%s.cmd", 1486 1468 dirlen, object, base); ··· 1602 1596 namespace); 1603 1597 } 1604 1598 1605 - if (extra_warn && !get_modinfo(&info, "description")) 1606 - warn("missing MODULE_DESCRIPTION() in %s\n", modname); 1599 + if (!get_modinfo(&info, "description")) 1600 + error("missing MODULE_DESCRIPTION() in %s\n", modname); 1607 1601 } 1608 1602 1609 1603 for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { ··· 1709 1703 s->crc_valid = exp->crc_valid; 1710 1704 s->crc = exp->crc; 1711 1705 1712 - basename = strrchr(mod->name, '/'); 1713 - if (basename) 1714 - basename++; 1715 - else 1716 - basename = mod->name; 1706 + basename = get_basename(mod->name); 1717 1707 1718 1708 if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) { 1719 1709 modpost_log(!allow_missing_ns_imports, ··· 1767 1765 { 1768 1766 const char *mod_name; 1769 1767 1770 - mod_name = strrchr(mod->name, '/'); 1771 - if (mod_name == NULL) 1772 - mod_name = mod->name; 1773 - else 1774 - mod_name++; 1768 + mod_name = get_basename(mod->name); 1769 + 1775 1770 if (strlen(mod_name) >= MODULE_NAME_LEN) 1776 1771 error("module name is too long [%s.ko]\n", mod->name); 1777 1772 } ··· 1945 1946 continue; 1946 1947 1947 1948 s->module->seen = true; 1948 - p = strrchr(s->module->name, '/'); 1949 - if (p) 1950 - p++; 1951 - else 1952 - p = s->module->name; 1949 + p = get_basename(s->module->name); 1953 1950 buf_printf(b, "%s%s", first ? "" : ",", p); 1954 1951 first = 0; 1955 1952 }
+1
scripts/mod/modpost.h
··· 216 216 /* from modpost.c */ 217 217 extern bool target_is_big_endian; 218 218 extern bool host_is_big_endian; 219 + const char *get_basename(const char *path); 219 220 char *read_text_file(const char *filename); 220 221 char *get_line(char **stringp); 221 222 void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym);
+6 -11
scripts/mod/sumversion.c
··· 309 309 310 310 cmd = xmalloc(strlen(objfile) + sizeof("..cmd")); 311 311 312 - base = strrchr(objfile, '/'); 313 - if (base) { 314 - base++; 315 - dirlen = base - objfile; 316 - sprintf(cmd, "%.*s.%s.cmd", dirlen, objfile, base); 317 - } else { 318 - dirlen = 0; 319 - sprintf(cmd, ".%s.cmd", objfile); 320 - } 312 + base = get_basename(objfile); 313 + dirlen = base - objfile; 314 + sprintf(cmd, "%.*s.%s.cmd", dirlen, objfile, base); 315 + 321 316 dir = xmalloc(dirlen + 1); 322 317 strncpy(dir, objfile, dirlen); 323 318 dir[dirlen] = '\0'; ··· 330 335 line++; 331 336 p = line; 332 337 333 - if (strncmp(line, "source_", sizeof("source_")-1) == 0) { 338 + if (strstarts(line, "source_")) { 334 339 p = strrchr(line, ' '); 335 340 if (!p) { 336 341 warn("malformed line: %s\n", line); ··· 344 349 } 345 350 continue; 346 351 } 347 - if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) { 352 + if (strstarts(line, "deps_")) { 348 353 check_files = 1; 349 354 continue; 350 355 }
+3 -3
scripts/package/PKGBUILD
··· 53 53 _package() { 54 54 pkgdesc="The ${pkgdesc} kernel and modules" 55 55 56 - local modulesdir="${pkgdir}/usr/${MODLIB}" 56 + local modulesdir="${pkgdir}/usr/lib/modules/${KERNELRELEASE}" 57 57 58 58 _prologue 59 59 ··· 81 81 _package-headers() { 82 82 pkgdesc="Headers and scripts for building modules for the ${pkgdesc} kernel" 83 83 84 - local builddir="${pkgdir}/usr/${MODLIB}/build" 84 + local builddir="${pkgdir}/usr/lib/modules/${KERNELRELEASE}/build" 85 85 86 86 _prologue 87 87 ··· 114 114 pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel" 115 115 116 116 local debugdir="${pkgdir}/usr/src/debug/${pkgbase}" 117 - local builddir="${pkgdir}/usr/${MODLIB}/build" 117 + local builddir="${pkgdir}/usr/lib/modules/${KERNELRELEASE}/build" 118 118 119 119 _prologue 120 120
+8 -2
scripts/package/debian/rules
··· 21 21 endif 22 22 endif 23 23 24 - revision = $(lastword $(subst -, ,$(shell dpkg-parsechangelog -S Version))) 24 + revision = $(shell dpkg-parsechangelog -S Version | sed -n 's/.*-//p') 25 25 CROSS_COMPILE ?= $(filter-out $(DEB_BUILD_GNU_TYPE)-, $(DEB_HOST_GNU_TYPE)-) 26 - make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) KBUILD_BUILD_VERSION=$(revision) $(addprefix CROSS_COMPILE=,$(CROSS_COMPILE)) 26 + make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) \ 27 + $(addprefix KBUILD_BUILD_VERSION=,$(revision)) \ 28 + $(addprefix CROSS_COMPILE=,$(CROSS_COMPILE)) 27 29 28 30 binary-targets := $(addprefix binary-, image image-dbg headers libc-dev) 29 31 ··· 43 41 # which package is being processed in the build log. 44 42 DH_OPTIONS = -p$(package) 45 43 44 + # Note: future removal of KDEB_COMPRESS 45 + # dpkg-deb >= 1.21.10 supports the DPKG_DEB_COMPRESSOR_TYPE environment 46 + # variable, which provides the same functionality as KDEB_COMPRESS. The 47 + # KDEB_COMPRESS variable will be removed in the future. 46 48 define binary 47 49 $(Q)dh_testdir $(DH_OPTIONS) 48 50 $(Q)dh_testroot $(DH_OPTIONS)
+44 -2
scripts/package/kernel.spec
··· 2 2 %{!?_arch: %define _arch dummy} 3 3 %{!?make: %define make make} 4 4 %define makeflags %{?_smp_mflags} ARCH=%{ARCH} 5 - %define __spec_install_post /usr/lib/rpm/brp-compress || : 6 - %define debug_package %{nil} 7 5 8 6 Name: kernel 9 7 Summary: The Linux Kernel ··· 43 45 This package provides kernel headers and makefiles sufficient to build modules 44 46 against the %{version} kernel package. 45 47 %endif 48 + 49 + %if %{with_debuginfo} 50 + # list of debuginfo-related options taken from distribution kernel.spec 51 + # files 52 + %undefine _include_minidebuginfo 53 + %undefine _find_debuginfo_dwz_opts 54 + %undefine _unique_build_ids 55 + %undefine _unique_debug_names 56 + %undefine _unique_debug_srcs 57 + %undefine _debugsource_packages 58 + %undefine _debuginfo_subpackages 59 + %global _find_debuginfo_opts -r 60 + %global _missing_build_ids_terminate_build 1 61 + %global _no_recompute_build_ids 1 62 + %{debug_package} 63 + %endif 64 + # some (but not all) versions of rpmbuild emit %%debug_package with 65 + # %%install. since we've already emitted it manually, that would cause 66 + # a package redefinition error. ensure that doesn't happen 67 + %define debug_package %{nil} 68 + 69 + # later, we make all modules executable so that find-debuginfo.sh strips 70 + # them up. but they don't actually need to be executable, so remove the 71 + # executable bit, taking care to do it _after_ find-debuginfo.sh has run 72 + %define __spec_install_post \ 73 + %{?__debug_package:%{__debug_install_post}} \ 74 + %{__arch_install_post} \ 75 + %{__os_install_post} \ 76 + find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \\\ 77 + | xargs --no-run-if-empty chmod u-x 46 78 47 79 %prep 48 80 %setup -q -n linux ··· 117 89 echo "%exclude /lib/modules/%{KERNELRELEASE}/build" 118 90 } > %{buildroot}/kernel.list 119 91 92 + # make modules executable so that find-debuginfo.sh strips them. this 93 + # will be undone later in %%__spec_install_post 94 + find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \ 95 + | xargs --no-run-if-empty chmod u+x 96 + 97 + %if %{with_debuginfo} 98 + # copying vmlinux directly to the debug directory means it will not get 99 + # stripped (but its source paths will still be collected + fixed up) 100 + mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE} 101 + cp vmlinux %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE} 102 + %endif 103 + 120 104 %clean 121 105 rm -rf %{buildroot} 106 + rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \ 107 + elfbins.list 122 108 123 109 %post 124 110 if [ -x /usr/bin/kernel-install ]; then
+13 -10
scripts/package/mkdebian
··· 77 77 debarch=i386 78 78 fi 79 79 ;; 80 + loongarch64) 81 + debarch=loong64 ;; 80 82 esac 81 83 if [ -z "$debarch" ]; then 82 84 debarch=$(dpkg-architecture -qDEB_HOST_ARCH) ··· 157 155 done 158 156 159 157 # Some variables and settings used throughout the script 160 - version=$KERNELRELEASE 161 158 if [ "${KDEB_PKGVERSION:+set}" ]; then 162 159 packageversion=$KDEB_PKGVERSION 163 160 else 164 - packageversion=$(${srctree}/scripts/setlocalversion --no-local ${srctree})-$($srctree/scripts/build-version) 161 + upstream_version=$("${srctree}/scripts/setlocalversion" --no-local "${srctree}" | sed 's/-\(rc[1-9]\)/~\1/') 162 + debian_revision=$("${srctree}/scripts/build-version") 163 + packageversion=${upstream_version}-${debian_revision} 165 164 fi 166 165 sourcename=${KDEB_SOURCENAME:-linux-upstream} 167 166 ··· 215 212 python3:native, rsync 216 213 Homepage: https://www.kernel.org/ 217 214 218 - Package: $packagename-$version 215 + Package: $packagename-${KERNELRELEASE} 219 216 Architecture: $debarch 220 - Description: Linux kernel, version $version 217 + Description: Linux kernel, version ${KERNELRELEASE} 221 218 This package contains the Linux kernel, modules and corresponding other 222 - files, version: $version. 219 + files, version: ${KERNELRELEASE}. 223 220 EOF 224 221 225 222 if [ "${SRCARCH}" != um ]; then ··· 238 235 if is_enabled CONFIG_MODULES; then 239 236 cat <<EOF >> debian/control 240 237 241 - Package: linux-headers-$version 238 + Package: linux-headers-${KERNELRELEASE} 242 239 Architecture: $debarch 243 240 Build-Profiles: <!pkg.${sourcename}.nokernelheaders> 244 - Description: Linux kernel headers for $version on $debarch 245 - This package provides kernel header files for $version on $debarch 241 + Description: Linux kernel headers for ${KERNELRELEASE} on $debarch 242 + This package provides kernel header files for ${KERNELRELEASE} on $debarch 246 243 . 247 244 This is useful for people who need to build external modules 248 245 EOF ··· 252 249 if is_enabled CONFIG_DEBUG_INFO; then 253 250 cat <<EOF >> debian/control 254 251 255 - Package: linux-image-$version-dbg 252 + Package: linux-image-${KERNELRELEASE}-dbg 256 253 Section: debug 257 254 Architecture: $debarch 258 255 Build-Profiles: <!pkg.${sourcename}.nokerneldbg> 259 - Description: Linux kernel debugging symbols for $version 256 + Description: Linux kernel debugging symbols for ${KERNELRELEASE} 260 257 This package will come in handy if you need to debug the kernel. It provides 261 258 all the necessary debug symbols for the kernel and its modules. 262 259 EOF
+10
scripts/package/mkspec
··· 23 23 echo '%define with_devel 0' 24 24 fi 25 25 26 + # debuginfo package generation uses find-debuginfo.sh under the hood, 27 + # which only works on uncompressed modules that contain debuginfo 28 + if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf && 29 + (! grep -q CONFIG_MODULE_COMPRESS=y include/config/auto.conf) && 30 + (! grep -q CONFIG_DEBUG_INFO_SPLIT=y include/config/auto.conf); then 31 + echo '%define with_debuginfo %{?_without_debuginfo: 0} %{?!_without_debuginfo: 1}' 32 + else 33 + echo '%define with_debuginfo 0' 34 + fi 35 + 26 36 cat<<EOF 27 37 %define ARCH ${ARCH} 28 38 %define KERNELRELEASE ${KERNELRELEASE}
+1 -1
scripts/show_delta
··· 1 - #!/usr/bin/env python 1 + #!/usr/bin/env python3 2 2 # SPDX-License-Identifier: GPL-2.0-only 3 3 # 4 4 # show_deltas: Read list of printk messages instrumented with