Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit d98dba8

Browse files
committed
kbuild: add 'private' to target-specific variables
Currently, Kbuild produces inconsistent results in some cases. You can do an interesting experiment using the --shuffle option, which is supported by GNU Make 4.4 or later. Set CONFIG_KVM_INTEL=y and CONFIG_KVM_AMD=m (or vice versa), and repeat incremental builds w/wo --shuffle=reverse. $ make [ snip ] CC arch/x86/kvm/kvm-asm-offsets.s $ make --shuffle=reverse [ snip ] CC [M] arch/x86/kvm/kvm-asm-offsets.s $ make [ snip ] CC arch/x86/kvm/kvm-asm-offsets.s arch/x86/kvm/kvm-asm-offsets.s is rebuilt every time w/wo the [M] marker. arch/x86/kvm/kvm-asm-offsets.s is built as built-in when it is built as a prerequisite of arch/x86/kvm/kvm-intel.o, which is built-in. arch/x86/kvm/kvm-asm-offsets.s is built as modular when it is built as a prerequisite of arch/x86/kvm/kvm-amd.o, which is a module. Another odd example is single target builds. When CONFIG_LKDTM=m, drivers/misc/lkdtm/rodata.o can be built as built-in or modular, depending on how it is built. $ make drivers/misc/lkdtm/lkdtm.o [ snip ] CC [M] drivers/misc/lkdtm/rodata.o $ make drivers/misc/lkdtm/rodata.o [ snip ] CC drivers/misc/lkdtm/rodata.o drivers/misc/lkdtm/rodata.o is built as modular when it is built as a prerequisite of another, but built as built-in when it is a final target. The same thing happens to drivers/memory/emif-asm-offsets.s when CONFIG_TI_EMIF_SRAM=m. $ make drivers/memory/ti-emif-sram.o [ snip ] CC [M] drivers/memory/emif-asm-offsets.s $ make drivers/memory/emif-asm-offsets.s [ snip ] CC drivers/memory/emif-asm-offsets.s This is because the part-of-module=y flag defined for the modules is inherited by its prerequisites. Target-specific variables are likely intended only for local use. This commit adds 'private' to them. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <n.schier@avm.de>
1 parent 770202a commit d98dba8

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,8 +1254,8 @@ define filechk_version.h
12541254
echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
12551255
endef
12561256

1257-
$(version_h): PATCHLEVEL := $(or $(PATCHLEVEL), 0)
1258-
$(version_h): SUBLEVEL := $(or $(SUBLEVEL), 0)
1257+
$(version_h): private PATCHLEVEL := $(or $(PATCHLEVEL), 0)
1258+
$(version_h): private SUBLEVEL := $(or $(SUBLEVEL), 0)
12591259
$(version_h): FORCE
12601260
$(call filechk,version.h)
12611261

@@ -1503,7 +1503,7 @@ MRPROPER_FILES += include/config include/generated \
15031503

15041504
# clean - Delete most, but leave enough to build external modules
15051505
#
1506-
clean: rm-files := $(CLEAN_FILES)
1506+
clean: private rm-files := $(CLEAN_FILES)
15071507

15081508
PHONY += archclean vmlinuxclean
15091509

@@ -1515,7 +1515,7 @@ clean: archclean vmlinuxclean resolve_btfids_clean
15151515

15161516
# mrproper - Delete all generated files, including .config
15171517
#
1518-
mrproper: rm-files := $(MRPROPER_FILES)
1518+
mrproper: private rm-files := $(MRPROPER_FILES)
15191519
mrproper-dirs := $(addprefix _mrproper_,scripts)
15201520

15211521
PHONY += $(mrproper-dirs) mrproper
@@ -1792,7 +1792,7 @@ compile_commands.json: $(extmod_prefix)compile_commands.json
17921792
PHONY += compile_commands.json
17931793

17941794
clean-dirs := $(KBUILD_EXTMOD)
1795-
clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
1795+
clean: private rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
17961796
$(KBUILD_EXTMOD)/compile_commands.json
17971797

17981798
PHONY += prepare

scripts/Makefile.build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
216216

217217
is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),y)
218218

219-
$(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
219+
$(obj)/%.o: private objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
220220

221221
ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
222222
cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning $(kbuild-file): $*.o is added to multiple modules: $(modname-multi)))
@@ -437,8 +437,8 @@ define rule_ld_multi_m
437437
$(call cmd,gen_objtooldep)
438438
endef
439439

440-
$(multi-obj-m): objtool-enabled := $(delay-objtool)
441-
$(multi-obj-m): part-of-module := y
440+
$(multi-obj-m): private objtool-enabled := $(delay-objtool)
441+
$(multi-obj-m): private part-of-module := y
442442
$(multi-obj-m): %.o: %.mod FORCE
443443
$(call if_changed_rule,ld_multi_m)
444444
$(call multi_depend, $(multi-obj-m), .o, -objs -y -m)

0 commit comments

Comments
 (0)