Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+8 -8
+5 -5
Makefile
··· 1254 1254 echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL) 1255 1255 endef 1256 1256 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) 1259 1259 $(version_h): FORCE 1260 1260 $(call filechk,version.h) 1261 1261 ··· 1503 1503 1504 1504 # clean - Delete most, but leave enough to build external modules 1505 1505 # 1506 - clean: rm-files := $(CLEAN_FILES) 1506 + clean: private rm-files := $(CLEAN_FILES) 1507 1507 1508 1508 PHONY += archclean vmlinuxclean 1509 1509 ··· 1515 1515 1516 1516 # mrproper - Delete all generated files, including .config 1517 1517 # 1518 - mrproper: rm-files := $(MRPROPER_FILES) 1518 + mrproper: private rm-files := $(MRPROPER_FILES) 1519 1519 mrproper-dirs := $(addprefix _mrproper_,scripts) 1520 1520 1521 1521 PHONY += $(mrproper-dirs) mrproper ··· 1792 1792 PHONY += compile_commands.json 1793 1793 1794 1794 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 \ 1796 1796 $(KBUILD_EXTMOD)/compile_commands.json 1797 1797 1798 1798 PHONY += prepare
+3 -3
scripts/Makefile.build
··· 216 216 217 217 is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),y) 218 218 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)) 220 220 221 221 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) 222 222 cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning $(kbuild-file): $*.o is added to multiple modules: $(modname-multi))) ··· 437 437 $(call cmd,gen_objtooldep) 438 438 endef 439 439 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 442 442 $(multi-obj-m): %.o: %.mod FORCE 443 443 $(call if_changed_rule,ld_multi_m) 444 444 $(call multi_depend, $(multi-obj-m), .o, -objs -y -m)