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"
  ...
This commit is contained in:
Linus Torvalds
2025-04-05 15:46:50 -07:00
62 changed files with 891 additions and 351 deletions
+1
View File
@@ -65,6 +65,7 @@ modules.order
/vmlinux.32
/vmlinux.map
/vmlinux.symvers
/vmlinux.unstripped
/vmlinux-gdb.py
/vmlinuz
/System.map
-18
View File
@@ -342,24 +342,6 @@ API usage
See: https://www.kernel.org/doc/html/latest/RCU/whatisRCU.html#full-list-of-rcu-apis
**DEPRECATED_VARIABLE**
EXTRA_{A,C,CPP,LD}FLAGS are deprecated and should be replaced by the new
flags added via commit f77bf01425b1 ("kbuild: introduce ccflags-y,
asflags-y and ldflags-y").
The following conversion scheme maybe used::
EXTRA_AFLAGS -> asflags-y
EXTRA_CFLAGS -> ccflags-y
EXTRA_CPPFLAGS -> cppflags-y
EXTRA_LDFLAGS -> ldflags-y
See:
1. https://lore.kernel.org/lkml/20070930191054.GA15876@uranus.ravnborg.org/
2. https://lore.kernel.org/lkml/1313384834-24433-12-git-send-email-lacombar@gmail.com/
3. https://www.kernel.org/doc/html/latest/kbuild/makefiles.html#compilation-flags
**DEVICE_ATTR_FUNCTIONS**
The function names used in DEVICE_ATTR is unusual.
Typically, the store and show functions are used with <attr>_store and
+65
View File
@@ -0,0 +1,65 @@
.. SPDX-License-Identifier: GPL-2.0-only
==========================
Bash completion for Kbuild
==========================
The kernel build system is written using Makefiles, and Bash completion
for the `make` command is available through the `bash-completion`_ project.
However, the Makefiles for the kernel build are complex. The generic completion
rules for the `make` command do not provide meaningful suggestions for the
kernel build system, except for the options of the `make` command itself.
To enhance completion for various variables and targets, the kernel source
includes its own completion script at `scripts/bash-completion/make`.
This script provides additional completions when working within the kernel tree.
Outside the kernel tree, it defaults to the generic completion rules for the
`make` command.
Prerequisites
=============
The script relies on helper functions provided by `bash-completion`_ project.
Please ensure it is installed on your system. On most distributions, you can
install the `bash-completion` package through the standard package manager.
How to use
==========
You can source the script directly::
$ source scripts/bash-completion/make
Or, you can copy it into the search path for Bash completion scripts.
For example::
$ mkdir -p ~/.local/share/bash-completion/completions
$ cp scripts/bash-completion/make ~/.local/share/bash-completion/completions/
Details
=======
The additional completion for Kbuild is enabled in the following cases:
- You are in the root directory of the kernel source.
- You are in the top-level build directory created by the O= option
(checked via the `source` symlink pointing to the kernel source).
- The -C make option specifies the kernel source or build directory.
- The -f make option specifies a file in the kernel source or build directory.
If none of the above are met, it falls back to the generic completion rules.
The completion supports:
- Commonly used targets, such as `all`, `menuconfig`, `dtbs`, etc.
- Make (or environment) variables, such as `ARCH`, `LLVM`, etc.
- Single-target builds (`foo/bar/baz.o`)
- Configuration files (`*_defconfig` and `*.config`)
Some variables offer intelligent behavior. For instance, `CROSS_COMPILE=`
followed by a TAB displays installed toolchains. The list of defconfig files
shown depends on the value of the `ARCH=` variable.
.. _bash-completion: https://github.com/scop/bash-completion/
+2
View File
@@ -23,6 +23,8 @@ Kernel Build System
llvm
gendwarfksyms
bash-completion
.. only:: subproject and html
Indices
+18 -11
View File
@@ -194,16 +194,6 @@ applicable everywhere (see syntax).
ability to hook into a secondary subsystem while allowing the user to
configure that subsystem out without also having to unset these drivers.
Note: If the combination of FOO=y and BAZ=m causes a link error,
you can guard the function call with IS_REACHABLE()::
foo_init()
{
if (IS_REACHABLE(CONFIG_BAZ))
baz_register(&foo);
...
}
Note: If the feature provided by BAZ is highly desirable for FOO,
FOO should imply not only BAZ, but also its dependency BAR::
@@ -588,7 +578,9 @@ uses the slightly counterintuitive::
depends on BAR || !BAR
This means that there is either a dependency on BAR that disallows
the combination of FOO=y with BAR=m, or BAR is completely disabled.
the combination of FOO=y with BAR=m, or BAR is completely disabled. The BAR
module must provide all the stubs for !BAR case.
For a more formalized approach if there are multiple drivers that have
the same dependency, a helper symbol can be used, like::
@@ -599,6 +591,21 @@ the same dependency, a helper symbol can be used, like::
config BAR_OPTIONAL
def_tristate BAR || !BAR
Much less favorable way to express optional dependency is IS_REACHABLE() within
the module code, useful for example when the module BAR does not provide
!BAR stubs::
foo_init()
{
if (IS_REACHABLE(CONFIG_BAR))
bar_register(&foo);
...
}
IS_REACHABLE() is generally discouraged, because the code will be silently
discarded, when CONFIG_BAR=m and this code is built-in. This is not what users
usually expect when enabling BAR as module.
Kconfig recursive dependency limitations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+14 -3
View File
@@ -318,9 +318,6 @@ ccflags-y, asflags-y and ldflags-y
These three flags apply only to the kbuild makefile in which they
are assigned. They are used for all the normal cc, as and ld
invocations happening during a recursive build.
Note: Flags with the same behaviour were previously named:
EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS.
They are still supported but their usage is deprecated.
ccflags-y specifies options for compiling with $(CC).
@@ -670,6 +667,20 @@ cc-cross-prefix
endif
endif
$(RUSTC) support functions
--------------------------
rustc-min-version
rustc-min-version tests if the value of $(CONFIG_RUSTC_VERSION) is greater
than or equal to the provided value and evaluates to y if so.
Example::
rustflags-$(call rustc-min-version, 108500) := -Cfoo
In this example, rustflags-y will be assigned the value -Cfoo if
$(CONFIG_RUSTC_VERSION) is >= 1.85.0.
$(LD) support functions
-----------------------
+1 -1
View File
@@ -318,7 +318,7 @@ Several Subdirectories
| |__ include
| |__ hardwareif.h
|__ include
|__ complex.h
|__ complex.h
To build the module complex.ko, we then need the following
kbuild file::
@@ -46,21 +46,6 @@ The kernel embeds the building user and host names in
`KBUILD_BUILD_USER and KBUILD_BUILD_HOST`_ variables. If you are
building from a git commit, you could use its committer address.
Absolute filenames
------------------
When the kernel is built out-of-tree, debug information may include
absolute filenames for the source files. This must be overridden by
including the ``-fdebug-prefix-map`` option in the `KCFLAGS`_ variable.
Depending on the compiler used, the ``__FILE__`` macro may also expand
to an absolute filename in an out-of-tree build. Kbuild automatically
uses the ``-fmacro-prefix-map`` option to prevent this, if it is
supported.
The Reproducible Builds web site has more information about these
`prefix-map options`_.
Generated files in source packages
----------------------------------
@@ -131,7 +116,5 @@ See ``scripts/setlocalversion`` for details.
.. _KBUILD_BUILD_TIMESTAMP: kbuild.html#kbuild-build-timestamp
.. _KBUILD_BUILD_USER and KBUILD_BUILD_HOST: kbuild.html#kbuild-build-user-kbuild-build-host
.. _KCFLAGS: kbuild.html#kcflags
.. _prefix-map options: https://reproducible-builds.org/docs/build-path/
.. _Reproducible Builds project: https://reproducible-builds.org/
.. _SOURCE_DATE_EPOCH: https://reproducible-builds.org/docs/source-date-epoch/
+1
View File
@@ -12850,6 +12850,7 @@ F: Makefile
F: scripts/*vmlinux*
F: scripts/Kbuild*
F: scripts/Makefile*
F: scripts/bash-completion/
F: scripts/basic/
F: scripts/clang-tools/
F: scripts/dummy-tools/
+16 -7
View File
@@ -151,9 +151,6 @@ endif
export KBUILD_EXTMOD
# backward compatibility
KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
ifeq ("$(origin W)", "command line")
KBUILD_EXTRA_WARN := $(W)
endif
@@ -928,6 +925,9 @@ KBUILD_CFLAGS += $(CC_AUTO_VAR_INIT_ZERO_ENABLER)
endif
endif
# Explicitly clear padding bits during variable initialization
KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
# While VLAs have been removed, GCC produces unreachable stack probes
# for the randomize_kstack_offset feature. Disable it for all compilers.
KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
@@ -1070,7 +1070,8 @@ endif
# change __FILE__ to the relative path to the source directory
ifdef building_out_of_srctree
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=)
KBUILD_CPPFLAGS += $(call cc-option,-ffile-prefix-map=$(srcroot)/=)
KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/=
endif
# include additional Makefiles when needed
@@ -1122,6 +1123,10 @@ ifdef CONFIG_LD_ORPHAN_WARN
LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
endif
ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),)
LDFLAGS_vmlinux += --emit-relocs --discard-none
endif
# Align the bit size of userspace programs with the kernel
KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
@@ -1364,9 +1369,12 @@ hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
PHONY += headers
headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
$(if $(filter um, $(SRCARCH)), $(error Headers not exportable for UML))
ifdef HEADER_ARCH
$(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers
else
$(Q)$(MAKE) $(hdr-inst)=include/uapi
$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
endif
ifdef CONFIG_HEADERS_INSTALL
prepare: headers
@@ -1564,7 +1572,7 @@ endif # CONFIG_MODULES
# Directories & files removed with 'make clean'
CLEAN_FILES += vmlinux.symvers modules-only.symvers \
modules.builtin modules.builtin.modinfo modules.nsdeps \
modules.builtin.ranges vmlinux.o.map \
modules.builtin.ranges vmlinux.o.map vmlinux.unstripped \
compile_commands.json rust/test \
rust-project.json .vmlinux.objs .vmlinux.export.c \
.builtin-dtbs-list .builtin-dtb.S
@@ -1667,7 +1675,8 @@ help:
@echo ' kernelrelease - Output the release version string (use with make -s)'
@echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
@echo ' image_name - Output the image name (use with make -s)'
@echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
@echo ' headers - Build ready-to-install UAPI headers in usr/include'
@echo ' headers_install - Install sanitised kernel UAPI headers to INSTALL_HDR_PATH'; \
echo ' (default: $(INSTALL_HDR_PATH))'; \
echo ''
@echo 'Static analysers:'
+7
View File
@@ -1699,6 +1699,13 @@ config ARCH_HAS_KERNEL_FPU_SUPPORT
Architectures that select this option can run floating-point code in
the kernel, as described in Documentation/core-api/floating-point.rst.
config ARCH_VMLINUX_NEEDS_RELOCS
bool
help
Whether the architecture needs vmlinux to be built with static
relocations preserved. This is used by some architectures to
construct bespoke relocation tables for KASLR.
source "kernel/gcov/Kconfig"
source "scripts/gcc-plugins/Kconfig"
+1 -1
View File
@@ -48,7 +48,7 @@ KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \
KBUILD_CFLAGS += $(call cc-disable-warning, psabi)
KBUILD_AFLAGS += $(compat_vdso)
ifeq ($(call test-ge, $(CONFIG_RUSTC_VERSION), 108500),y)
ifeq ($(call rustc-min-version, 108500),y)
KBUILD_RUSTFLAGS += --target=aarch64-unknown-none-softfloat
else
KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"
+1
View File
@@ -2618,6 +2618,7 @@ config RELOCATABLE
CPU_MIPS32_R6 || CPU_MIPS64_R6 || \
CPU_P5600 || CAVIUM_OCTEON_SOC || \
CPU_LOONGSON64
select ARCH_VMLINUX_NEEDS_RELOCS
help
This builds a kernel image that retains relocation information
so it can be loaded someplace besides the default 1MB.
-4
View File
@@ -100,10 +100,6 @@ LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
KBUILD_AFLAGS_MODULE += -mlong-calls
KBUILD_CFLAGS_MODULE += -mlong-calls
ifeq ($(CONFIG_RELOCATABLE),y)
LDFLAGS_vmlinux += --emit-relocs
endif
cflags-y += -ffreestanding
cflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB
+1 -1
View File
@@ -22,7 +22,7 @@ quiet_cmd_relocs = RELOCS $@
# `@true` prevents complaint when there is nothing to be done
vmlinux: FORCE
vmlinux vmlinux.unstripped: FORCE
@true
ifeq ($(CONFIG_CPU_LOONGSON3_WORKAROUNDS),y)
$(call if_changed,ls3_llsc)
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += kernel/ mm/ platform/ boot/dts/
obj-y += kernel/ mm/ platform/
# for cleaning
subdir- += boot
+2 -2
View File
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
obj-y := $(patsubst %.dts,%.dtb.o,$(CONFIG_NIOS2_DTB_SOURCE))
dtb-y := $(addsuffix .dtb, $(CONFIG_BUILTIN_DTB_NAME))
dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(src)/%.dts,%.dtb, $(wildcard $(src)/*.dts))
dtb-$(CONFIG_OF_ALL_DTBS) += $(patsubst $(src)/%.dts,%.dtb, $(wildcard $(src)/*.dts))
+1 -1
View File
@@ -32,7 +32,7 @@ void __init early_init_devtree(void *params)
}
#endif
#ifdef CONFIG_NIOS2_DTB_SOURCE_BOOL
#ifdef CONFIG_BUILTIN_DTB
if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER)
params = (void *)__dtb_start;
#endif
+6 -5
View File
@@ -35,19 +35,20 @@ config NIOS2_DTB_PHYS_ADDR
help
Physical address of a dtb blob.
config NIOS2_DTB_SOURCE_BOOL
config BUILTIN_DTB
bool "Compile and link device tree into kernel image"
depends on !COMPILE_TEST
select GENERIC_BUILTIN_DTB
help
This allows you to specify a dts (device tree source) file
which will be compiled and linked into the kernel image.
config NIOS2_DTB_SOURCE
string "Device tree source file"
depends on NIOS2_DTB_SOURCE_BOOL
config BUILTIN_DTB_NAME
string "Built-in device tree name"
depends on BUILTIN_DTB
default ""
help
Absolute path to the device tree source (dts) file describing your
Relative path to the device tree without suffix describing your
system.
comment "Nios II instructions"
+1
View File
@@ -1108,6 +1108,7 @@ config RELOCATABLE
bool "Build a relocatable kernel"
depends on !XIP_KERNEL
select MODULE_SECTIONS if MODULES
select ARCH_VMLINUX_NEEDS_RELOCS
help
This builds a kernel as a Position Independent Executable (PIE),
which retains all relocation metadata required to relocate the

Some files were not shown because too many files have changed in this diff Show More