Skip to content

Commit 8afc66e

Browse files
committed
Merge tag 'kbuild-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada: - Remove potentially incomplete targets when Kbuid is interrupted by SIGINT etc in case GNU Make may miss to do that when stderr is piped to another program. - Rewrite the single target build so it works more correctly. - Fix rpm-pkg builds with V=1. - List top-level subdirectories in ./Kbuild. - Ignore auto-generated __kstrtab_* and __kstrtabns_* symbols in kallsyms. - Avoid two different modules in lib/zstd/ having shared code, which potentially causes building the common code as build-in and modular back-and-forth. - Unify two modpost invocations to optimize the build process. - Remove head-y syntax in favor of linker scripts for placing particular sections in the head of vmlinux. - Bump the minimal GNU Make version to 3.82. - Clean up misc Makefiles and scripts. * tag 'kbuild-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (41 commits) docs: bump minimal GNU Make version to 3.82 ia64: simplify esi object addition in Makefile Revert "kbuild: Check if linker supports the -X option" kbuild: rebuild .vmlinux.export.o when its prerequisite is updated kbuild: move modules.builtin(.modinfo) rules to Makefile.vmlinux_o zstd: Fixing mixed module-builtin objects kallsyms: ignore __kstrtab_* and __kstrtabns_* symbols kallsyms: take the input file instead of reading stdin kallsyms: drop duplicated ignore patterns from kallsyms.c kbuild: reuse mksysmap output for kallsyms mksysmap: update comment about __crc_* kbuild: remove head-y syntax kbuild: use obj-y instead extra-y for objects placed at the head kbuild: hide error checker logs for V=1 builds kbuild: re-run modpost when it is updated kbuild: unify two modpost invocations kbuild: move vmlinux.o rule to the top Makefile kbuild: move .vmlinux.objs rule to Makefile.modpost kbuild: list sub-directories in ./Kbuild Makefile.compiler: replace cc-ifversion with compiler-specific macros ...
2 parents 4de65c5 + 0715fdb commit 8afc66e

Some content is hidden

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

87 files changed

+729
-763
lines changed

Documentation/kbuild/makefiles.rst

+23-33
Original file line numberDiff line numberDiff line change
@@ -341,30 +341,14 @@ more details, with real examples.
341341

342342
Examples are:
343343

344-
1) head objects
345-
346-
Some objects must be placed at the head of vmlinux. They are
347-
directly linked to vmlinux without going through built-in.a
348-
A typical use-case is an object that contains the entry point.
349-
350-
arch/$(SRCARCH)/Makefile should specify such objects as head-y.
351-
352-
Discussion:
353-
Given that we can control the section order in the linker script,
354-
why do we need head-y?
355-
356-
2) vmlinux linker script
344+
1) vmlinux linker script
357345

358346
The linker script for vmlinux is located at
359347
arch/$(SRCARCH)/kernel/vmlinux.lds
360348

361349
Example::
362350

363351
# arch/x86/kernel/Makefile
364-
extra-y := head_$(BITS).o
365-
extra-y += head$(BITS).o
366-
extra-y += ebda.o
367-
extra-y += platform-quirks.o
368352
extra-y += vmlinux.lds
369353

370354
$(extra-y) should only contain targets needed for vmlinux.
@@ -683,22 +667,27 @@ more details, with real examples.
683667
In the above example, -Wno-unused-but-set-variable will be added to
684668
KBUILD_CFLAGS only if gcc really accepts it.
685669

686-
cc-ifversion
687-
cc-ifversion tests the version of $(CC) and equals the fourth parameter
688-
if version expression is true, or the fifth (if given) if the version
689-
expression is false.
670+
gcc-min-version
671+
gcc-min-version tests if the value of $(CONFIG_GCC_VERSION) is greater than
672+
or equal to the provided value and evaluates to y if so.
673+
674+
Example::
675+
676+
cflags-$(call gcc-min-version, 70100) := -foo
677+
678+
In this example, cflags-y will be assigned the value -foo if $(CC) is gcc and
679+
$(CONFIG_GCC_VERSION) is >= 7.1.
680+
681+
clang-min-version
682+
clang-min-version tests if the value of $(CONFIG_CLANG_VERSION) is greater
683+
than or equal to the provided value and evaluates to y if so.
690684

691685
Example::
692686

693-
#fs/reiserfs/Makefile
694-
ccflags-y := $(call cc-ifversion, -lt, 0402, -O1)
687+
cflags-$(call clang-min-version, 110000) := -foo
695688

696-
In this example, ccflags-y will be assigned the value -O1 if the
697-
$(CC) version is less than 4.2.
698-
cc-ifversion takes all the shell operators:
699-
-eq, -ne, -lt, -le, -gt, and -ge
700-
The third parameter may be a text as in this example, but it may also
701-
be an expanded variable or a macro.
689+
In this example, cflags-y will be assigned the value -foo if $(CC) is clang
690+
and $(CONFIG_CLANG_VERSION) is >= 11.0.0.
702691

703692
cc-cross-prefix
704693
cc-cross-prefix is used to check if there exists a $(CC) in path with
@@ -1099,8 +1088,7 @@ When kbuild executes, the following steps are followed (roughly):
10991088
- The values of the above variables are expanded in arch/$(SRCARCH)/Makefile.
11001089
5) All object files are then linked and the resulting file vmlinux is
11011090
located at the root of the obj tree.
1102-
The very first objects linked are listed in head-y, assigned by
1103-
arch/$(SRCARCH)/Makefile.
1091+
The very first objects linked are listed in scripts/head-object-list.txt.
11041092
6) Finally, the architecture-specific part does any required post processing
11051093
and builds the final bootimage.
11061094
- This includes building boot records
@@ -1272,6 +1260,9 @@ When kbuild executes, the following steps are followed (roughly):
12721260
All object files for vmlinux. They are linked to vmlinux in the same
12731261
order as listed in KBUILD_VMLINUX_OBJS.
12741262

1263+
The objects listed in scripts/head-object-list.txt are exceptions;
1264+
they are placed before the other objects.
1265+
12751266
KBUILD_VMLINUX_LIBS
12761267

12771268
All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and
@@ -1315,8 +1306,7 @@ When kbuild executes, the following steps are followed (roughly):
13151306
machinery is all architecture-independent.
13161307

13171308

1318-
head-y, core-y, libs-y, drivers-y
1319-
$(head-y) lists objects to be linked first in vmlinux.
1309+
core-y, libs-y, drivers-y
13201310

13211311
$(libs-y) lists directories where a lib.a archive can be located.
13221312

Documentation/process/changes.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ GNU C 5.1 gcc --version
3333
Clang/LLVM (optional) 11.0.0 clang --version
3434
Rust (optional) 1.62.0 rustc --version
3535
bindgen (optional) 0.56.0 bindgen --version
36-
GNU make 3.81 make --version
36+
GNU make 3.82 make --version
3737
bash 4.2 bash --version
3838
binutils 2.23 ld -v
3939
flex 2.5.35 flex --version
@@ -108,7 +108,7 @@ It depends on ``libclang``.
108108
Make
109109
----
110110

111-
You will need GNU make 3.81 or later to build the kernel.
111+
You will need GNU make 3.82 or later to build the kernel.
112112

113113
Bash
114114
----

Kbuild

+59-19
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
#
33
# Kbuild for top-level directory of the kernel
44

5-
#####
5+
# Prepare global headers and check sanity before descending into sub-directories
6+
# ---------------------------------------------------------------------------
7+
68
# Generate bounds.h
79

810
bounds-file := include/generated/bounds.h
911

10-
always-y := $(bounds-file)
1112
targets := kernel/bounds.s
1213

1314
$(bounds-file): kernel/bounds.s FORCE
1415
$(call filechk,offsets,__LINUX_BOUNDS_H__)
1516

16-
#####
1717
# Generate timeconst.h
1818

1919
timeconst-file := include/generated/timeconst.h
@@ -23,37 +23,77 @@ filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $<
2323
$(timeconst-file): kernel/time/timeconst.bc FORCE
2424
$(call filechk,gentimeconst)
2525

26-
#####
2726
# Generate asm-offsets.h
2827

2928
offsets-file := include/generated/asm-offsets.h
3029

31-
always-y += $(offsets-file)
3230
targets += arch/$(SRCARCH)/kernel/asm-offsets.s
3331

3432
arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file)
3533

3634
$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
3735
$(call filechk,offsets,__ASM_OFFSETS_H__)
3836

39-
#####
4037
# Check for missing system calls
4138

42-
always-y += missing-syscalls
43-
4439
quiet_cmd_syscalls = CALL $<
4540
cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
4641

47-
missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
42+
PHONY += missing-syscalls
43+
missing-syscalls: scripts/checksyscalls.sh $(offsets-file)
4844
$(call cmd,syscalls)
4945

50-
#####
51-
# Check atomic headers are up-to-date
52-
53-
always-y += old-atomics
54-
55-
quiet_cmd_atomics = CALL $<
56-
cmd_atomics = $(CONFIG_SHELL) $<
57-
58-
old-atomics: scripts/atomic/check-atomics.sh FORCE
59-
$(call cmd,atomics)
46+
# Check the manual modification of atomic headers
47+
48+
quiet_cmd_check_sha1 = CHKSHA1 $<
49+
cmd_check_sha1 = \
50+
if ! command -v sha1sum >/dev/null; then \
51+
echo "warning: cannot check the header due to sha1sum missing"; \
52+
exit 0; \
53+
fi; \
54+
if [ "$$(sed -n '$$s:// ::p' $<)" != \
55+
"$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \
56+
echo "error: $< has been modified." >&2; \
57+
exit 1; \
58+
fi; \
59+
touch $@
60+
61+
atomic-checks += $(addprefix $(obj)/.checked-, \
62+
atomic-arch-fallback.h \
63+
atomic-instrumented.h \
64+
atomic-long.h)
65+
66+
targets += $(atomic-checks)
67+
$(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE
68+
$(call if_changed,check_sha1)
69+
70+
# A phony target that depends on all the preparation targets
71+
72+
PHONY += prepare
73+
prepare: $(offsets-file) missing-syscalls $(atomic-checks)
74+
@:
75+
76+
# Ordinary directory descending
77+
# ---------------------------------------------------------------------------
78+
79+
obj-y += init/
80+
obj-y += usr/
81+
obj-y += arch/$(SRCARCH)/
82+
obj-y += $(ARCH_CORE)
83+
obj-y += kernel/
84+
obj-y += certs/
85+
obj-y += mm/
86+
obj-y += fs/
87+
obj-y += ipc/
88+
obj-y += security/
89+
obj-y += crypto/
90+
obj-$(CONFIG_BLOCK) += block/
91+
obj-$(CONFIG_IO_URING) += io_uring/
92+
obj-$(CONFIG_RUST) += rust/
93+
obj-y += $(ARCH_LIB)
94+
obj-y += drivers/
95+
obj-y += sound/
96+
obj-$(CONFIG_SAMPLES) += samples/
97+
obj-$(CONFIG_NET) += net/
98+
obj-y += virt/
99+
obj-y += $(ARCH_DRIVERS)

0 commit comments

Comments
 (0)