Skip to content

Commit f4d2ef4

Browse files
committed
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" ...
2 parents 758e4c8 + a7c699d commit f4d2ef4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+890
-350
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ modules.order
6565
/vmlinux.32
6666
/vmlinux.map
6767
/vmlinux.symvers
68+
/vmlinux.unstripped
6869
/vmlinux-gdb.py
6970
/vmlinuz
7071
/System.map

Diff for: Documentation/dev-tools/checkpatch.rst

-18
Original file line numberDiff line numberDiff line change
@@ -342,24 +342,6 @@ API usage
342342

343343
See: https://www.kernel.org/doc/html/latest/RCU/whatisRCU.html#full-list-of-rcu-apis
344344

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/[email protected]/
360-
2. https://lore.kernel.org/lkml/[email protected]/
361-
3. https://www.kernel.org/doc/html/latest/kbuild/makefiles.html#compilation-flags
362-
363345
**DEVICE_ATTR_FUNCTIONS**
364346
The function names used in DEVICE_ATTR is unusual.
365347
Typically, the store and show functions are used with <attr>_store and

Diff for: Documentation/kbuild/bash-completion.rst

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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/

Diff for: Documentation/kbuild/index.rst

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Kernel Build System
2323
llvm
2424
gendwarfksyms
2525

26+
bash-completion
27+
2628
.. only:: subproject and html
2729

2830
Indices

Diff for: Documentation/kbuild/kconfig-language.rst

+18-11
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,6 @@ applicable everywhere (see syntax).
194194
ability to hook into a secondary subsystem while allowing the user to
195195
configure that subsystem out without also having to unset these drivers.
196196

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-
207197
Note: If the feature provided by BAZ is highly desirable for FOO,
208198
FOO should imply not only BAZ, but also its dependency BAR::
209199

@@ -588,7 +578,9 @@ uses the slightly counterintuitive::
588578
depends on BAR || !BAR
589579

590580
This means that there is either a dependency on BAR that disallows
591-
the combination of FOO=y with BAR=m, or BAR is completely disabled.
581+
the combination of FOO=y with BAR=m, or BAR is completely disabled. The BAR
582+
module must provide all the stubs for !BAR case.
583+
592584
For a more formalized approach if there are multiple drivers that have
593585
the same dependency, a helper symbol can be used, like::
594586

@@ -599,6 +591,21 @@ the same dependency, a helper symbol can be used, like::
599591
config BAR_OPTIONAL
600592
def_tristate BAR || !BAR
601593

594+
Much less favorable way to express optional dependency is IS_REACHABLE() within
595+
the module code, useful for example when the module BAR does not provide
596+
!BAR stubs::
597+
598+
foo_init()
599+
{
600+
if (IS_REACHABLE(CONFIG_BAR))
601+
bar_register(&foo);
602+
...
603+
}
604+
605+
IS_REACHABLE() is generally discouraged, because the code will be silently
606+
discarded, when CONFIG_BAR=m and this code is built-in. This is not what users
607+
usually expect when enabling BAR as module.
608+
602609
Kconfig recursive dependency limitations
603610
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
604611

Diff for: Documentation/kbuild/makefiles.rst

+14-3
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,6 @@ ccflags-y, asflags-y and ldflags-y
318318
These three flags apply only to the kbuild makefile in which they
319319
are assigned. They are used for all the normal cc, as and ld
320320
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.
324321

325322
ccflags-y specifies options for compiling with $(CC).
326323

@@ -670,6 +667,20 @@ cc-cross-prefix
670667
endif
671668
endif
672669

670+
$(RUSTC) support functions
671+
--------------------------
672+
673+
rustc-min-version
674+
rustc-min-version tests if the value of $(CONFIG_RUSTC_VERSION) is greater
675+
than or equal to the provided value and evaluates to y if so.
676+
677+
Example::
678+
679+
rustflags-$(call rustc-min-version, 108500) := -Cfoo
680+
681+
In this example, rustflags-y will be assigned the value -Cfoo if
682+
$(CONFIG_RUSTC_VERSION) is >= 1.85.0.
683+
673684
$(LD) support functions
674685
-----------------------
675686

Diff for: Documentation/kbuild/modules.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ Several Subdirectories
318318
| |__ include
319319
| |__ hardwareif.h
320320
|__ include
321-
|__ complex.h
321+
|__ complex.h
322322

323323
To build the module complex.ko, we then need the following
324324
kbuild file::

Diff for: Documentation/kbuild/reproducible-builds.rst

-17
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,6 @@ The kernel embeds the building user and host names in
4646
`KBUILD_BUILD_USER and KBUILD_BUILD_HOST`_ variables. If you are
4747
building from a git commit, you could use its committer address.
4848

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-
6449
Generated files in source packages
6550
----------------------------------
6651

@@ -131,7 +116,5 @@ See ``scripts/setlocalversion`` for details.
131116

132117
.. _KBUILD_BUILD_TIMESTAMP: kbuild.html#kbuild-build-timestamp
133118
.. _KBUILD_BUILD_USER and KBUILD_BUILD_HOST: kbuild.html#kbuild-build-user-kbuild-build-host
134-
.. _KCFLAGS: kbuild.html#kcflags
135-
.. _prefix-map options: https://reproducible-builds.org/docs/build-path/
136119
.. _Reproducible Builds project: https://reproducible-builds.org/
137120
.. _SOURCE_DATE_EPOCH: https://reproducible-builds.org/docs/source-date-epoch/

Diff for: MAINTAINERS

+1
Original file line numberDiff line numberDiff line change
@@ -12850,6 +12850,7 @@ F: Makefile
1285012850
F: scripts/*vmlinux*
1285112851
F: scripts/Kbuild*
1285212852
F: scripts/Makefile*
12853+
F: scripts/bash-completion/
1285312854
F: scripts/basic/
1285412855
F: scripts/clang-tools/
1285512856
F: scripts/dummy-tools/

Diff for: Makefile

+16-7
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ endif
151151

152152
export KBUILD_EXTMOD
153153

154-
# backward compatibility
155-
KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
156-
157154
ifeq ("$(origin W)", "command line")
158155
KBUILD_EXTRA_WARN := $(W)
159156
endif
@@ -928,6 +925,9 @@ KBUILD_CFLAGS += $(CC_AUTO_VAR_INIT_ZERO_ENABLER)
928925
endif
929926
endif
930927

928+
# Explicitly clear padding bits during variable initialization
929+
KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
930+
931931
# While VLAs have been removed, GCC produces unreachable stack probes
932932
# for the randomize_kstack_offset feature. Disable it for all compilers.
933933
KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
@@ -1070,7 +1070,8 @@ endif
10701070

10711071
# change __FILE__ to the relative path to the source directory
10721072
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)/=
10741075
endif
10751076

10761077
# include additional Makefiles when needed
@@ -1122,6 +1123,10 @@ ifdef CONFIG_LD_ORPHAN_WARN
11221123
LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
11231124
endif
11241125

1126+
ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),)
1127+
LDFLAGS_vmlinux += --emit-relocs --discard-none
1128+
endif
1129+
11251130
# Align the bit size of userspace programs with the kernel
11261131
KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
11271132
KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
@@ -1364,9 +1369,12 @@ hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
13641369

13651370
PHONY += headers
13661371
headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
1367-
$(if $(filter um, $(SRCARCH)), $(error Headers not exportable for UML))
1372+
ifdef HEADER_ARCH
1373+
$(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers
1374+
else
13681375
$(Q)$(MAKE) $(hdr-inst)=include/uapi
13691376
$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1377+
endif
13701378

13711379
ifdef CONFIG_HEADERS_INSTALL
13721380
prepare: headers
@@ -1564,7 +1572,7 @@ endif # CONFIG_MODULES
15641572
# Directories & files removed with 'make clean'
15651573
CLEAN_FILES += vmlinux.symvers modules-only.symvers \
15661574
modules.builtin modules.builtin.modinfo modules.nsdeps \
1567-
modules.builtin.ranges vmlinux.o.map \
1575+
modules.builtin.ranges vmlinux.o.map vmlinux.unstripped \
15681576
compile_commands.json rust/test \
15691577
rust-project.json .vmlinux.objs .vmlinux.export.c \
15701578
.builtin-dtbs-list .builtin-dtb.S
@@ -1667,7 +1675,8 @@ help:
16671675
@echo ' kernelrelease - Output the release version string (use with make -s)'
16681676
@echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
16691677
@echo ' image_name - Output the image name (use with make -s)'
1670-
@echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1678+
@echo ' headers - Build ready-to-install UAPI headers in usr/include'
1679+
@echo ' headers_install - Install sanitised kernel UAPI headers to INSTALL_HDR_PATH'; \
16711680
echo ' (default: $(INSTALL_HDR_PATH))'; \
16721681
echo ''
16731682
@echo 'Static analysers:'

Diff for: arch/Kconfig

+7
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,13 @@ config ARCH_HAS_KERNEL_FPU_SUPPORT
16991699
Architectures that select this option can run floating-point code in
17001700
the kernel, as described in Documentation/core-api/floating-point.rst.
17011701

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+
17021709
source "kernel/gcov/Kconfig"
17031710

17041711
source "scripts/gcc-plugins/Kconfig"

Diff for: arch/arm64/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \
4848
KBUILD_CFLAGS += $(call cc-disable-warning, psabi)
4949
KBUILD_AFLAGS += $(compat_vdso)
5050

51-
ifeq ($(call test-ge, $(CONFIG_RUSTC_VERSION), 108500),y)
51+
ifeq ($(call rustc-min-version, 108500),y)
5252
KBUILD_RUSTFLAGS += --target=aarch64-unknown-none-softfloat
5353
else
5454
KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"

Diff for: arch/mips/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -2618,6 +2618,7 @@ config RELOCATABLE
26182618
CPU_MIPS32_R6 || CPU_MIPS64_R6 || \
26192619
CPU_P5600 || CAVIUM_OCTEON_SOC || \
26202620
CPU_LOONGSON64
2621+
select ARCH_VMLINUX_NEEDS_RELOCS
26212622
help
26222623
This builds a kernel image that retains relocation information
26232624
so it can be loaded someplace besides the default 1MB.

Diff for: arch/mips/Makefile

-4
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
100100
KBUILD_AFLAGS_MODULE += -mlong-calls
101101
KBUILD_CFLAGS_MODULE += -mlong-calls
102102

103-
ifeq ($(CONFIG_RELOCATABLE),y)
104-
LDFLAGS_vmlinux += --emit-relocs
105-
endif
106-
107103
cflags-y += -ffreestanding
108104

109105
cflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB

Diff for: arch/mips/Makefile.postlink

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ quiet_cmd_relocs = RELOCS $@
2222

2323
# `@true` prevents complaint when there is nothing to be done
2424

25-
vmlinux: FORCE
25+
vmlinux vmlinux.unstripped: FORCE
2626
@true
2727
ifeq ($(CONFIG_CPU_LOONGSON3_WORKAROUNDS),y)
2828
$(call if_changed,ls3_llsc)

Diff for: arch/nios2/Kbuild

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22

3-
obj-y += kernel/ mm/ platform/ boot/dts/
3+
obj-y += kernel/ mm/ platform/
44

55
# for cleaning
66
subdir- += boot

Diff for: arch/nios2/boot/dts/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3-
obj-y := $(patsubst %.dts,%.dtb.o,$(CONFIG_NIOS2_DTB_SOURCE))
3+
dtb-y := $(addsuffix .dtb, $(CONFIG_BUILTIN_DTB_NAME))
44

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

Diff for: arch/nios2/kernel/prom.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void __init early_init_devtree(void *params)
3232
}
3333
#endif
3434

35-
#ifdef CONFIG_NIOS2_DTB_SOURCE_BOOL
35+
#ifdef CONFIG_BUILTIN_DTB
3636
if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER)
3737
params = (void *)__dtb_start;
3838
#endif

0 commit comments

Comments
 (0)