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 $(objtree)/ prefix to some in-kernel build artifacts

$(objtree) refers to the top of the output directory of kernel builds.

This commit adds the explicit $(objtree)/ prefix to build artifacts
needed for building external modules.

This change has no immediate impact, as the top-level Makefile
currently defines:

objtree := .

This commit prepares for supporting the building of external modules
in a different directory.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

+30 -30
+5 -5
Makefile
··· 354 354 include $(srctree)/scripts/Kbuild.include 355 355 356 356 # Read KERNELRELEASE from include/config/kernel.release (if it exists) 357 - KERNELRELEASE = $(call read-file, include/config/kernel.release) 357 + KERNELRELEASE = $(call read-file, $(objtree)/include/config/kernel.release) 358 358 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 359 359 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 360 360 ··· 720 720 export KBUILD_MODULES KBUILD_BUILTIN 721 721 722 722 ifdef need-config 723 - include include/config/auto.conf 723 + include $(objtree)/include/config/auto.conf 724 724 endif 725 725 726 726 ifeq ($(KBUILD_EXTMOD),) ··· 783 783 # and include/config/auto.conf but do not care if they are up-to-date. 784 784 # Use auto.conf to show the error message 785 785 786 - checked-configs := include/generated/autoconf.h include/generated/rustc_cfg include/config/auto.conf 786 + checked-configs := $(addprefix $(objtree)/, include/generated/autoconf.h include/generated/rustc_cfg include/config/auto.conf) 787 787 missing-configs := $(filter-out $(wildcard $(checked-configs)), $(checked-configs)) 788 788 789 789 ifdef missing-configs 790 - PHONY += include/config/auto.conf 790 + PHONY += $(objtree)/include/config/auto.conf 791 791 792 - include/config/auto.conf: 792 + $(objtree)/include/config/auto.conf: 793 793 @echo >&2 '***' 794 794 @echo >&2 '*** ERROR: Kernel configuration is invalid. The following files are missing:' 795 795 @printf >&2 '*** - %s\n' $(missing-configs)
+2 -2
arch/arm/Makefile
··· 264 264 -mstack-protector-guard=tls \ 265 265 -mstack-protector-guard-offset=$(shell \ 266 266 awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}'\ 267 - include/generated/asm-offsets.h)) 267 + $(objtree)/include/generated/asm-offsets.h)) 268 268 else 269 269 stack_protector_prepare: prepare0 270 270 $(eval SSP_PLUGIN_CFLAGS := \ 271 271 -fplugin-arg-arm_ssp_per_task_plugin-offset=$(shell \ 272 272 awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}'\ 273 - include/generated/asm-offsets.h)) 273 + $(objtree)/include/generated/asm-offsets.h)) 274 274 $(eval KBUILD_CFLAGS += $(SSP_PLUGIN_CFLAGS)) 275 275 $(eval GCC_PLUGINS_CFLAGS += $(SSP_PLUGIN_CFLAGS)) 276 276 endif
+1 -1
arch/arm64/Makefile
··· 71 71 -mstack-protector-guard-reg=sp_el0 \ 72 72 -mstack-protector-guard-offset=$(shell \ 73 73 awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \ 74 - include/generated/asm-offsets.h)) 74 + $(objtree)/include/generated/asm-offsets.h)) 75 75 endif 76 76 77 77 ifeq ($(CONFIG_ARM64_BTI_KERNEL),y)
+2 -2
arch/powerpc/Makefile
··· 402 402 PHONY += stack_protector_prepare 403 403 stack_protector_prepare: prepare0 404 404 ifdef CONFIG_PPC64 405 - $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h)) 405 + $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' $(objtree)/include/generated/asm-offsets.h)) 406 406 else 407 - $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h)) 407 + $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' $(objtree)/include/generated/asm-offsets.h)) 408 408 endif 409 409 endif 410 410
+1 -1
arch/riscv/Makefile
··· 129 129 -mstack-protector-guard-reg=tp \ 130 130 -mstack-protector-guard-offset=$(shell \ 131 131 awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \ 132 - include/generated/asm-offsets.h)) 132 + $(objtree)/include/generated/asm-offsets.h)) 133 133 endif 134 134 135 135 # arch specific predefines for sparse
+1 -1
scripts/Kbuild.include
··· 205 205 206 206 cmd_and_fixdep = \ 207 207 $(cmd); \ 208 - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ 208 + $(objtree)/scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ 209 209 rm -f $(depfile) 210 210 211 211 # Usage: $(call if_changed_rule,foo)
+2 -2
scripts/Makefile.build
··· 34 34 subdir-ccflags-y := 35 35 36 36 # Read auto.conf if it exists, otherwise ignore 37 - -include include/config/auto.conf 37 + -include $(objtree)/include/config/auto.conf 38 38 39 39 include $(srctree)/scripts/Kbuild.include 40 40 include $(srctree)/scripts/Makefile.compiler ··· 107 107 $(obj)/%.i: $(obj)/%.c FORCE 108 108 $(call if_changed_dep,cpp_i_c) 109 109 110 - genksyms = scripts/genksyms/genksyms \ 110 + genksyms = $(objtree)/scripts/genksyms/genksyms \ 111 111 $(if $(1), -T $(2)) \ 112 112 $(if $(KBUILD_PRESERVE), -p) \ 113 113 -r $(or $(wildcard $(2:.symtypes=.symref)), /dev/null)
+7 -7
scripts/Makefile.modfinal
··· 6 6 PHONY := __modfinal 7 7 __modfinal: 8 8 9 - include include/config/auto.conf 9 + include $(objtree)/include/config/auto.conf 10 10 include $(srctree)/scripts/Kbuild.include 11 11 12 12 # for c_flags ··· 37 37 cmd_ld_ko_o = \ 38 38 $(LD) -r $(KBUILD_LDFLAGS) \ 39 39 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ 40 - -T scripts/module.lds -o $@ $(filter %.o, $^) 40 + -T $(objtree)/scripts/module.lds -o $@ $(filter %.o, $^) 41 41 42 42 quiet_cmd_btf_ko = BTF [M] $@ 43 43 cmd_btf_ko = \ 44 - if [ ! -f vmlinux ]; then \ 44 + if [ ! -f $(objtree)/vmlinux ]; then \ 45 45 printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \ 46 46 else \ 47 - LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) $(MODULE_PAHOLE_FLAGS) --btf_base vmlinux $@; \ 48 - $(RESOLVE_BTFIDS) -b vmlinux $@; \ 47 + LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) $(MODULE_PAHOLE_FLAGS) --btf_base $(objtree)/vmlinux $@; \ 48 + $(RESOLVE_BTFIDS) -b $(objtree)/vmlinux $@; \ 49 49 fi; 50 50 51 51 # Same as newer-prereqs, but allows to exclude specified extra dependencies ··· 57 57 printf '%s\n' 'savedcmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) 58 58 59 59 # Re-generate module BTFs if either module's .ko or vmlinux changed 60 - %.ko: %.o %.mod.o $(extmod_prefix).module-common.o scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),vmlinux) FORCE 61 - +$(call if_changed_except,ld_ko_o,vmlinux) 60 + %.ko: %.o %.mod.o $(extmod_prefix).module-common.o $(objtree)/scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),$(objtree)/vmlinux) FORCE 61 + +$(call if_changed_except,ld_ko_o,$(objtree)/vmlinux) 62 62 ifdef CONFIG_DEBUG_INFO_BTF_MODULES 63 63 +$(if $(newer-prereqs),$(call cmd,btf_ko)) 64 64 endif
+1 -1
scripts/Makefile.modinst
··· 6 6 PHONY := __modinst 7 7 __modinst: 8 8 9 - include include/config/auto.conf 9 + include $(objtree)/include/config/auto.conf 10 10 include $(srctree)/scripts/Kbuild.include 11 11 12 12 install-y :=
+6 -6
scripts/Makefile.modpost
··· 35 35 PHONY := __modpost 36 36 __modpost: 37 37 38 - include include/config/auto.conf 38 + include $(objtree)/include/config/auto.conf 39 39 include $(srctree)/scripts/Kbuild.include 40 40 41 - MODPOST = scripts/mod/modpost 41 + MODPOST = $(objtree)/scripts/mod/modpost 42 42 43 43 modpost-args = \ 44 44 $(if $(CONFIG_MODULES),-M) \ ··· 119 119 120 120 output-symdump := $(KBUILD_EXTMOD)/Module.symvers 121 121 122 - ifeq ($(wildcard Module.symvers),) 123 - missing-input := Module.symvers 122 + ifeq ($(wildcard $(objtree)/Module.symvers),) 123 + missing-input := $(objtree)/Module.symvers 124 124 else 125 - modpost-args += -i Module.symvers 126 - modpost-deps += Module.symvers 125 + modpost-args += -i $(objtree)/Module.symvers 126 + modpost-deps += $(objtree)/Module.symvers 127 127 endif 128 128 129 129 modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS))
+2 -2
scripts/depmod.sh
··· 12 12 13 13 : ${DEPMOD:=depmod} 14 14 15 - if ! test -r System.map ; then 15 + if ! test -r "${objtree}/System.map" ; then 16 16 echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2 17 17 exit 0 18 18 fi ··· 25 25 exit 0 26 26 fi 27 27 28 - set -- -ae -F System.map 28 + set -- -ae -F "${objtree}/System.map" 29 29 if test -n "$INSTALL_MOD_PATH"; then 30 30 set -- "$@" -b "$INSTALL_MOD_PATH" 31 31 fi