Skip to content

Commit 1bf807b

Browse files
committed
kbuild: set y instead of 1 to KBUILD_{BUILTIN,MODULES}
KBUILD_BUILTIN is set to 1 unless you are building only modules. KBUILD_MODULES is set to 1 when you are building only modules (a typical use case is "make modules"). It is more useful to set them to 'y' instead, so we can do something like: always-$(KBUILD_BUILTIN) += vmlinux.lds This works equivalently to: extra-y += vmlinux.lds This allows us to deprecate extra-y. extra-y and always-y are quite similar, and we do not need both. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Reviewed-by: Nicolas Schier <[email protected]>
1 parent 481d5c3 commit 1bf807b

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Documentation/kbuild/makefiles.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ Example::
291291
# arch/x86/kernel/Makefile
292292
extra-y += vmlinux.lds
293293

294+
extra-y is now deprecated because this is equivalent to:
295+
296+
always-$(KBUILD_BUILTIN) += vmlinux.lds
297+
294298
$(extra-y) should only contain targets needed for vmlinux.
295299

296300
Kbuild skips extra-y when vmlinux is apparently not a final goal.

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ targets :=
749749
# Normally, just do built-in.
750750

751751
KBUILD_MODULES :=
752-
KBUILD_BUILTIN := 1
752+
KBUILD_BUILTIN := y
753753

754754
# If we have only "make modules", don't compile built-in objects.
755755
ifeq ($(MAKECMDGOALS),modules)
@@ -761,11 +761,11 @@ endif
761761
# Just "make" or "make all" shall build modules as well
762762

763763
ifneq ($(filter all modules nsdeps compile_commands.json clang-%,$(MAKECMDGOALS)),)
764-
KBUILD_MODULES := 1
764+
KBUILD_MODULES := y
765765
endif
766766

767767
ifeq ($(MAKECMDGOALS),)
768-
KBUILD_MODULES := 1
768+
KBUILD_MODULES := y
769769
endif
770770

771771
export KBUILD_MODULES KBUILD_BUILTIN
@@ -1193,7 +1193,7 @@ export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
11931193
ifdef CONFIG_TRIM_UNUSED_KSYMS
11941194
# For the kernel to actually contain only the needed exported symbols,
11951195
# we have to build modules as well to determine what those symbols are.
1196-
KBUILD_MODULES := 1
1196+
KBUILD_MODULES := y
11971197
endif
11981198

11991199
# '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
@@ -1533,7 +1533,7 @@ all: modules
15331533
# the built-in objects during the descend as well, in order to
15341534
# make sure the checksums are up to date before we record them.
15351535
ifdef CONFIG_MODVERSIONS
1536-
KBUILD_BUILTIN := 1
1536+
KBUILD_BUILTIN := y
15371537
endif
15381538

15391539
# Build modules
@@ -1542,7 +1542,7 @@ endif
15421542
# *.ko are usually independent of vmlinux, but CONFIG_DEBUG_INFO_BTF_MODULES
15431543
# is an exception.
15441544
ifdef CONFIG_DEBUG_INFO_BTF_MODULES
1545-
KBUILD_BUILTIN := 1
1545+
KBUILD_BUILTIN := y
15461546
modules: vmlinux
15471547
endif
15481548

@@ -1858,7 +1858,7 @@ filechk_kernel.release = echo $(KERNELRELEASE)
18581858

18591859
# We are always building only modules.
18601860
KBUILD_BUILTIN :=
1861-
KBUILD_MODULES := 1
1861+
KBUILD_MODULES := y
18621862

18631863
build-dir := .
18641864

@@ -1986,7 +1986,7 @@ endif
19861986

19871987
single-goals := $(addprefix $(build-dir)/, $(single-no-ko))
19881988

1989-
KBUILD_MODULES := 1
1989+
KBUILD_MODULES := y
19901990

19911991
endif
19921992

0 commit comments

Comments
 (0)