Skip to content

Commit 6feb57c

Browse files
committed
Merge tag 'kbuild-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada: - Support zstd-compressed debug info - Allow W=1 builds to detect objects shared among multiple modules - Add srcrpm-pkg target to generate a source RPM package - Make the -s option detection work for future GNU Make versions - Add -Werror to KBUILD_CPPFLAGS when CONFIG_WERROR=y - Allow W=1 builds to detect -Wundef warnings in any preprocessed files - Raise the minimum supported version of binutils to 2.25 - Use $(intcmp ...) to compare integers if GNU Make >= 4.4 is used - Use $(file ...) to read a file if GNU Make >= 4.2 is used - Print error if GNU Make older than 3.82 is used - Allow modpost to detect section mismatches with Clang LTO - Include vmlinuz.efi into kernel tarballs for arm64 CONFIG_EFI_ZBOOT=y * tag 'kbuild-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (29 commits) buildtar: fix tarballs with EFI_ZBOOT enabled modpost: Include '.text.*' in TEXT_SECTIONS padata: Mark padata_work_init() as __ref kbuild: ensure Make >= 3.82 is used kbuild: refactor the prerequisites of the modpost rule kbuild: change module.order to list *.o instead of *.ko kbuild: use .NOTINTERMEDIATE for future GNU Make versions kconfig: refactor Makefile to reduce process forks kbuild: add read-file macro kbuild: do not sort after reading modules.order kbuild: add test-{ge,gt,le,lt} macros Documentation: raise minimum supported version of binutils to 2.25 kbuild: add -Wundef to KBUILD_CPPFLAGS for W=1 builds kbuild: move -Werror from KBUILD_CFLAGS to KBUILD_CPPFLAGS kbuild: Port silent mode detection to future gnu make. init/version.c: remove #include <generated/utsrelease.h> firmware_loader: remove #include <generated/utsrelease.h> modpost: Mark uuid_le type to be suitable only for MEI kbuild: add ability to make source rpm buildable using koji kbuild: warn objects shared among multiple modules ...
2 parents 158738e + 731c4ea commit 6feb57c

Some content is hidden

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

42 files changed

+286
-156
lines changed

Documentation/process/changes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Rust (optional) 1.62.0 rustc --version
3535
bindgen (optional) 0.56.0 bindgen --version
3636
GNU make 3.82 make --version
3737
bash 4.2 bash --version
38-
binutils 2.23 ld -v
38+
binutils 2.25 ld -v
3939
flex 2.5.35 flex --version
4040
bison 2.0 bison --version
4141
pahole 1.16 pahole --version
@@ -119,7 +119,7 @@ Bash 4.2 or newer is needed.
119119
Binutils
120120
--------
121121

122-
Binutils 2.23 or newer is needed to build the kernel.
122+
Binutils 2.25 or newer is needed to build the kernel.
123123

124124
pkg-config
125125
----------

Makefile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ NAME = Hurr durr I'ma ninja sloth
1111
# Comments in this file are targeted only to the developer, do not
1212
# expect to learn how to build the kernel reading this file.
1313

14+
ifeq ($(filter undefine,$(.FEATURES)),)
15+
$(error GNU Make >= 3.82 is required. Your Make version is $(MAKE_VERSION))
16+
endif
17+
1418
$(if $(filter __%, $(MAKECMDGOALS)), \
1519
$(error targets prefixed with '__' are only for internal use))
1620

@@ -93,10 +97,17 @@ endif
9397

9498
# If the user is running make -s (silent mode), suppress echoing of
9599
# commands
100+
# make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS.
96101

97-
ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
98-
quiet=silent_
99-
KBUILD_VERBOSE = 0
102+
ifeq ($(filter 3.%,$(MAKE_VERSION)),)
103+
silence:=$(findstring s,$(firstword -$(MAKEFLAGS)))
104+
else
105+
silence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS)))
106+
endif
107+
108+
ifeq ($(silence),s)
109+
quiet=silent_
110+
KBUILD_VERBOSE = 0
100111
endif
101112

102113
export quiet Q KBUILD_VERBOSE
@@ -369,7 +380,7 @@ else # !mixed-build
369380
include $(srctree)/scripts/Kbuild.include
370381

371382
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
372-
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
383+
KERNELRELEASE = $(call read-file, include/config/kernel.release)
373384
KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
374385
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
375386

@@ -859,7 +870,8 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
859870

860871
KBUILD_CFLAGS += $(stackp-flags-y)
861872

862-
KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
873+
KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
874+
KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)
863875
KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
864876

865877
KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings
@@ -990,7 +1002,7 @@ KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
9901002
# Check for frame size exceeding threshold during prolog/epilog insertion
9911003
# when using lld < 13.0.0.
9921004
ifneq ($(CONFIG_FRAME_WARN),0)
993-
ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
1005+
ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
9941006
KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
9951007
endif
9961008
endif
@@ -1560,7 +1572,7 @@ __modinst_pre:
15601572
rm -f $(MODLIB)/build ; \
15611573
ln -s $(CURDIR) $(MODLIB)/build ; \
15621574
fi
1563-
@sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
1575+
@sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
15641576
@cp -f modules.builtin $(MODLIB)/
15651577
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
15661578

arch/riscv/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ else
3737
endif
3838

3939
ifeq ($(CONFIG_LD_IS_LLD),y)
40-
ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
40+
ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
4141
KBUILD_CFLAGS += -mno-relax
4242
KBUILD_AFLAGS += -mno-relax
4343
ifndef CONFIG_AS_IS_LLVM

arch/x86/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ endif
217217
KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
218218

219219
ifdef CONFIG_LTO_CLANG
220-
ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
220+
ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
221221
KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
222222
endif
223223
endif

drivers/base/firmware_loader/firmware.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <linux/list.h>
1010
#include <linux/completion.h>
1111

12-
#include <generated/utsrelease.h>
13-
1412
/**
1513
* enum fw_opt - options to control firmware loading behaviour
1614
*

init/version.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/printk.h>
1616
#include <linux/uts.h>
1717
#include <linux/utsname.h>
18-
#include <generated/utsrelease.h>
1918
#include <linux/proc_ns.h>
2019

2120
static int __init early_hostname(char *arg)

kernel/padata.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,16 @@ static struct padata_work *padata_work_alloc(void)
8383
return pw;
8484
}
8585

86-
static void padata_work_init(struct padata_work *pw, work_func_t work_fn,
87-
void *data, int flags)
86+
/*
87+
* This function is marked __ref because this function may be optimized in such
88+
* a way that it directly refers to work_fn's address, which causes modpost to
89+
* complain when work_fn is marked __init. This scenario was observed with clang
90+
* LTO, where padata_work_init() was optimized to refer directly to
91+
* padata_mt_helper() because the calls to padata_work_init() with other work_fn
92+
* values were eliminated or inlined.
93+
*/
94+
static void __ref padata_work_init(struct padata_work *pw, work_func_t work_fn,
95+
void *data, int flags)
8896
{
8997
if (flags & PADATA_WORK_ONSTACK)
9098
INIT_WORK_ONSTACK(&pw->pw_work, work_fn);

lib/Kconfig.debug

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,21 @@ config DEBUG_INFO_REDUCED
312312
DEBUG_INFO build and compile times are reduced too.
313313
Only works with newer gcc versions.
314314

315-
config DEBUG_INFO_COMPRESSED
316-
bool "Compressed debugging information"
315+
choice
316+
prompt "Compressed Debug information"
317+
help
318+
Compress the resulting debug info. Results in smaller debug info sections,
319+
but requires that consumers are able to decompress the results.
320+
321+
If unsure, choose DEBUG_INFO_COMPRESSED_NONE.
322+
323+
config DEBUG_INFO_COMPRESSED_NONE
324+
bool "Don't compress debug information"
325+
help
326+
Don't compress debug info sections.
327+
328+
config DEBUG_INFO_COMPRESSED_ZLIB
329+
bool "Compress debugging information with zlib"
317330
depends on $(cc-option,-gz=zlib)
318331
depends on $(ld-option,--compress-debug-sections=zlib)
319332
help
@@ -327,6 +340,18 @@ config DEBUG_INFO_COMPRESSED
327340
preferable to setting $KDEB_COMPRESS to "none" which would be even
328341
larger.
329342

343+
config DEBUG_INFO_COMPRESSED_ZSTD
344+
bool "Compress debugging information with zstd"
345+
depends on $(cc-option,-gz=zstd)
346+
depends on $(ld-option,--compress-debug-sections=zstd)
347+
help
348+
Compress the debug information using zstd. This may provide better
349+
compression than zlib, for about the same time costs, but requires newer
350+
toolchain support. Requires GCC 13.0+ or Clang 16.0+, binutils 2.40+, and
351+
zstd.
352+
353+
endchoice # "Compressed Debug information"
354+
330355
config DEBUG_INFO_SPLIT
331356
bool "Produce split debuginfo in .dwo files"
332357
depends on $(cc-option,-gsplit-dwarf)

scripts/Kbuild.include

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,26 @@ empty :=
1010
space := $(empty) $(empty)
1111
space_escape := _-_SPACE_-_
1212
pound := \#
13+
define newline
14+
15+
16+
endef
17+
18+
###
19+
# Comparison macros.
20+
# Usage: $(call test-lt, $(CONFIG_LLD_VERSION), 150000)
21+
#
22+
# Use $(intcmp ...) if supported. (Make >= 4.4)
23+
# Otherwise, fall back to the 'test' shell command.
24+
ifeq ($(intcmp 1,0,,,y),y)
25+
test-ge = $(intcmp $(strip $1)0, $(strip $2)0,,y,y)
26+
test-gt = $(intcmp $(strip $1)0, $(strip $2)0,,,y)
27+
else
28+
test-ge = $(shell test $(strip $1)0 -ge $(strip $2)0 && echo y)
29+
test-gt = $(shell test $(strip $1)0 -gt $(strip $2)0 && echo y)
30+
endif
31+
test-le = $(call test-ge, $2, $1)
32+
test-lt = $(call test-gt, $2, $1)
1333

1434
###
1535
# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
@@ -40,6 +60,21 @@ escsq = $(subst $(squote),'\$(squote)',$1)
4060
# Quote a string to pass it to C files. foo => '"foo"'
4161
stringify = $(squote)$(quote)$1$(quote)$(squote)
4262

63+
###
64+
# The path to Kbuild or Makefile. Kbuild has precedence over Makefile.
65+
kbuild-dir = $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
66+
kbuild-file = $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
67+
68+
###
69+
# Read a file, replacing newlines with spaces
70+
#
71+
# Make 4.2 or later can read a file by using its builtin function.
72+
ifneq ($(filter-out 3.% 4.0 4.1, $(MAKE_VERSION)),)
73+
read-file = $(subst $(newline),$(space),$(file < $1))
74+
else
75+
read-file = $(shell cat $1 2>/dev/null)
76+
endif
77+
4378
###
4479
# Easy method for doing a status message
4580
kecho := :
@@ -150,9 +185,6 @@ endif
150185
make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))))
151186

152187
# Find any prerequisites that are newer than target or that do not exist.
153-
# (This is not true for now; $? should contain any non-existent prerequisites,
154-
# but it does not work as expected when .SECONDARY is present. This seems a bug
155-
# of GNU Make.)
156188
# PHONY targets skipped in both cases.
157189
newer-prereqs = $(filter-out $(PHONY),$?)
158190

@@ -228,4 +260,14 @@ endif
228260
.DELETE_ON_ERROR:
229261

230262
# do not delete intermediate files automatically
263+
#
264+
# .NOTINTERMEDIATE is more correct, but only available on newer Make versions.
265+
# Make 4.4 introduced .NOTINTERMEDIATE, and it appears in .FEATURES, but the
266+
# global .NOTINTERMEDIATE does not work. We can use it on Make > 4.4.
267+
# Use .SECONDARY for older Make versions, but "newer-prereq" cannot detect
268+
# deleted files.
269+
ifneq ($(and $(filter notintermediate, $(.FEATURES)),$(filter-out 4.4,$(MAKE_VERSION))),)
270+
.NOTINTERMEDIATE:
271+
else
231272
.SECONDARY:
273+
endif

scripts/Makefile.asm-generic

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ PHONY := all
1010
all:
1111

1212
src := $(subst /generated,,$(obj))
13-
-include $(src)/Kbuild
13+
14+
include $(srctree)/scripts/Kbuild.include
15+
-include $(kbuild-file)
1416

1517
# $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case.
1618
ifneq ($(SRCARCH),um)
1719
include $(srctree)/$(generic)/Kbuild
1820
endif
1921

20-
include $(srctree)/scripts/Kbuild.include
21-
2222
redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y))
2323
redundant += $(foreach f, $(generic-y), $(if $(wildcard $(srctree)/$(src)/$(f)),$(f)))
2424
redundant := $(sort $(redundant))

0 commit comments

Comments
 (0)