BACKPORT: FROMGIT: 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> [ Applied same resolution as Linus to arch/powerpc/Makefile, resolved $(objtree) additions where $(mixed-build-prefix) was present in favor of $(mixed-build-prefix) - Matthew Maurer ] (cherry picked from commit 214c0eea43b2ea66bcd6467ea57e47ce8874191b https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild) Change-Id: I384feae14230165e4077df18b165f6df13f6cc79 Bug: 347787665 Signed-off-by: Matthew Maurer <mmaurer@google.com>
This commit is contained in:
committed by
Giuliano Procida
parent
e379551e61
commit
b0c7496af3
@@ -372,7 +372,7 @@ else # !mixed-build
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
|
||||
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
|
||||
KERNELRELEASE = $(call read-file, include/config/kernel.release)
|
||||
KERNELRELEASE = $(call read-file, $(objtree)/include/config/kernel.release)
|
||||
KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
|
||||
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
|
||||
|
||||
@@ -740,7 +740,7 @@ endif
|
||||
export KBUILD_MODULES KBUILD_BUILTIN
|
||||
|
||||
ifdef need-config
|
||||
include include/config/auto.conf
|
||||
include $(objtree)/include/config/auto.conf
|
||||
endif
|
||||
|
||||
ifeq ($(KBUILD_EXTMOD),)
|
||||
@@ -805,13 +805,13 @@ else # !may-sync-config
|
||||
# and include/config/auto.conf but do not care if they are up-to-date.
|
||||
# Use auto.conf to show the error message
|
||||
|
||||
checked-configs := include/generated/autoconf.h include/generated/rustc_cfg include/config/auto.conf
|
||||
checked-configs := $(addprefix $(objtree)/, include/generated/autoconf.h include/generated/rustc_cfg include/config/auto.conf)
|
||||
missing-configs := $(filter-out $(wildcard $(checked-configs)), $(checked-configs))
|
||||
|
||||
ifdef missing-configs
|
||||
PHONY += include/config/auto.conf
|
||||
PHONY += $(objtree)/include/config/auto.conf
|
||||
|
||||
include/config/auto.conf:
|
||||
$(objtree)/include/config/auto.conf:
|
||||
@echo >&2 '***'
|
||||
@echo >&2 '*** ERROR: Kernel configuration is invalid. The following files are missing:'
|
||||
@printf >&2 '*** - %s\n' $(missing-configs)
|
||||
|
||||
+2
-2
@@ -264,13 +264,13 @@ stack_protector_prepare: prepare0
|
||||
-mstack-protector-guard=tls \
|
||||
-mstack-protector-guard-offset=$(shell \
|
||||
awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}'\
|
||||
include/generated/asm-offsets.h))
|
||||
$(objtree)/include/generated/asm-offsets.h))
|
||||
else
|
||||
stack_protector_prepare: prepare0
|
||||
$(eval SSP_PLUGIN_CFLAGS := \
|
||||
-fplugin-arg-arm_ssp_per_task_plugin-offset=$(shell \
|
||||
awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}'\
|
||||
include/generated/asm-offsets.h))
|
||||
$(objtree)/include/generated/asm-offsets.h))
|
||||
$(eval KBUILD_CFLAGS += $(SSP_PLUGIN_CFLAGS))
|
||||
$(eval GCC_PLUGINS_CFLAGS += $(SSP_PLUGIN_CFLAGS))
|
||||
endif
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ stack_protector_prepare: prepare0
|
||||
-mstack-protector-guard-reg=sp_el0 \
|
||||
-mstack-protector-guard-offset=$(shell \
|
||||
awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \
|
||||
include/generated/asm-offsets.h))
|
||||
$(objtree)/include/generated/asm-offsets.h))
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARM64_BTI_KERNEL),y)
|
||||
|
||||
@@ -396,10 +396,10 @@ PHONY += stack_protector_prepare
|
||||
stack_protector_prepare: prepare0
|
||||
ifdef CONFIG_PPC64
|
||||
$(eval KBUILD_CFLAGS += -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 \
|
||||
-mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
|
||||
-mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' $(objtree)/include/generated/asm-offsets.h))
|
||||
else
|
||||
$(eval KBUILD_CFLAGS += -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 \
|
||||
-mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
|
||||
-mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' $(objtree)/include/generated/asm-offsets.h))
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ stack_protector_prepare: prepare0
|
||||
-mstack-protector-guard-reg=tp \
|
||||
-mstack-protector-guard-offset=$(shell \
|
||||
awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \
|
||||
include/generated/asm-offsets.h))
|
||||
$(objtree)/include/generated/asm-offsets.h))
|
||||
endif
|
||||
|
||||
# arch specific predefines for sparse
|
||||
|
||||
@@ -205,7 +205,7 @@ if_changed_dep = $(if $(if-changed-cond),$(cmd_and_fixdep),@:)
|
||||
|
||||
cmd_and_fixdep = \
|
||||
$(cmd); \
|
||||
scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\
|
||||
$(objtree)/scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\
|
||||
rm -f $(depfile)
|
||||
|
||||
# Usage: $(call if_changed_rule,foo)
|
||||
|
||||
@@ -34,7 +34,7 @@ subdir-asflags-y :=
|
||||
subdir-ccflags-y :=
|
||||
|
||||
# Read auto.conf if it exists, otherwise ignore
|
||||
-include include/config/auto.conf
|
||||
-include $(objtree)/include/config/auto.conf
|
||||
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
include $(srctree)/scripts/Makefile.compiler
|
||||
@@ -107,7 +107,7 @@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $<
|
||||
$(obj)/%.i: $(obj)/%.c FORCE
|
||||
$(call if_changed_dep,cpp_i_c)
|
||||
|
||||
genksyms = scripts/genksyms/genksyms \
|
||||
genksyms = $(objtree)/scripts/genksyms/genksyms \
|
||||
$(if $(1), -T $(2)) \
|
||||
$(if $(KBUILD_PRESERVE), -p) \
|
||||
-r $(or $(wildcard $(2:.symtypes=.symref)), /dev/null)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
PHONY := __modfinal
|
||||
__modfinal:
|
||||
|
||||
include include/config/auto.conf
|
||||
include $(objtree)/include/config/auto.conf
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
|
||||
# for c_flags
|
||||
@@ -43,7 +43,7 @@ quiet_cmd_ld_ko_o = LD [M] $@
|
||||
cmd_ld_ko_o = \
|
||||
$(LD) -r $(KBUILD_LDFLAGS) \
|
||||
$(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
|
||||
-T scripts/module.lds -o $@ $(filter %.o, $^); \
|
||||
-T $(objtree)/scripts/module.lds -o $@ $(filter %.o, $^); \
|
||||
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
|
||||
|
||||
quiet_cmd_btf_ko = BTF [M] $@
|
||||
@@ -64,7 +64,7 @@ if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check), \
|
||||
printf '%s\n' 'savedcmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
|
||||
|
||||
# Re-generate module BTFs if either module's .ko or vmlinux changed
|
||||
%.ko: %.o %.mod.o $(extmod_prefix).module-common.o scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),$(mixed-build-prefix)vmlinux) FORCE
|
||||
%.ko: %.o %.mod.o $(extmod_prefix).module-common.o $(objtree)/scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),$(mixed-build-prefix)vmlinux) FORCE
|
||||
+$(call if_changed_except,ld_ko_o,$(mixed-build-prefix)vmlinux)
|
||||
ifdef CONFIG_DEBUG_INFO_BTF_MODULES
|
||||
+$(if $(newer-prereqs),$(call cmd,btf_ko))
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
PHONY := __modinst
|
||||
__modinst:
|
||||
|
||||
include include/config/auto.conf
|
||||
include $(objtree)/include/config/auto.conf
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
|
||||
install-y :=
|
||||
|
||||
@@ -35,12 +35,12 @@
|
||||
PHONY := __modpost
|
||||
__modpost:
|
||||
|
||||
include include/config/auto.conf
|
||||
include $(objtree)/include/config/auto.conf
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
|
||||
mixed-build-prefix = $(if $(KBUILD_MIXED_TREE),$(KBUILD_MIXED_TREE)/)
|
||||
|
||||
MODPOST = scripts/mod/modpost
|
||||
MODPOST = $(objtree)/scripts/mod/modpost
|
||||
|
||||
modpost-args = \
|
||||
$(if $(CONFIG_MODULES),-M) \
|
||||
@@ -185,11 +185,11 @@ include $(kbuild-file)
|
||||
|
||||
output-symdump := $(KBUILD_EXTMOD)/Module.symvers
|
||||
|
||||
ifeq ($(wildcard Module.symvers),)
|
||||
missing-input := Module.symvers
|
||||
ifeq ($(wildcard $(objtree)/Module.symvers),)
|
||||
missing-input := $(objtree)/Module.symvers
|
||||
else
|
||||
modpost-args += -i Module.symvers
|
||||
modpost-deps += Module.symvers
|
||||
modpost-args += -i $(objtree)/Module.symvers
|
||||
modpost-deps += $(objtree)/Module.symvers
|
||||
endif
|
||||
|
||||
modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS))
|
||||
|
||||
Reference in New Issue
Block a user