Skip to content

Commit 86008ba

Browse files
committed
Merge: Fix failure when building kernel modules using a separate output directory [rhel-9.8]
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7244 JIRA: https://issues.redhat.com/browse/RHEL-107194 This Merge Request intends to fix an error with the buildcheck test QE runs. It builds the kernel using a separate output directory for the build artifacts. The core of the problem is that some backports in RHEL 9 are already using a new way to reference the source directory used upstream, but those backports failed to bring the necessary kbuild changes to use it. The core of the Merge Request here is commit "kbuild: use $(src) instead of $(srctree)/$(src) for source directory", which is the main change required. All other changes are dependencies/pre-requisites or fixes to this change. With changes below, using the build with a separate output directory is then fixed. - Makefile: add $(srctree) to dependency of compile_commands.json target (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - kbuild: scripts/gdb: bring the "abspath" back (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - kbuild: Use $(obj)/%.cc to fix host C++ module builds (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - kbuild: scripts/gdb: Replace missed $(srctree)/$(src) w/ $(src) (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - kbuild: use $(src) instead of $(srctree)/$(src) for source directory (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - kbuild: use $(obj)/ instead of $(src)/ for common pattern rules (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - kbuild: do not add $(srctree) or $(objtree) to header search paths (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - arch: use $(obj)/ instead of $(src)/ for preprocessed linker scripts (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - arm64: vdso32: Remove unused vdso32-offsets.h (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - staging: vc04_services: interface: Drop include Makefile directive (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - staging: vc04_services: vchiq-mmal: Drop include Makefile directive (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - staging: vc04_services: bcm2835-camera: Drop include Makefile directive (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - staging: vc04_services: bcm2835-audio: Drop include Makefile directive (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - certs: check-in the default x509 config file (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - sparc: move the install rule to arch/sparc/Makefile (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - riscv: move the (z)install rules to arch/riscv/Makefile (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - powerpc: move the install rule to arch/powerpc/Makefile (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - powerpc: make the install target not depend on any build artifact (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - powerpc: remove unused zInstall target from arch/powerpc/boot/Makefile (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - nios2: move the install rule to arch/nios2/Makefile (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] - ARM: 9102/1: move theinstall rules to arch/arm/Makefile (Herton R. Krzesinski) [[RHEL-107194](https://issues.redhat.com/browse/RHEL-107194)] Signed-off-by: Herton R. Krzesinski <herton@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: Waiman Long <longman@redhat.com> Approved-by: Jan Stancek <jstancek@redhat.com> Approved-by: David Arcari <darcari@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: Vladis Dronov <vdronov@redhat.com> Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: José Expósito <jexposit@redhat.com> Approved-by: Eric Auger <eric.auger@redhat.com> Approved-by: John W. Linville <linville@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Patrick Talbert <ptalbert@redhat.com>
2 parents 46e73aa + 56ae359 commit 86008ba

File tree

131 files changed

+277
-326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+277
-326
lines changed

Documentation/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,22 @@ loop_cmd = $(echo-cmd) $(cmd_$(1)) || exit;
6868
# * dest folder relative to $(BUILDDIR) and
6969
# * cache folder relative to $(BUILDDIR)/.doctrees
7070
# $4 dest subfolder e.g. "man" for man pages at userspace-api/media/man
71-
# $5 reST source folder relative to $(srctree)/$(src),
71+
# $5 reST source folder relative to $(src),
7272
# e.g. "userspace-api/media" for the linux-tv book-set at ./Documentation/userspace-api/media
7373

7474
quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
7575
cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/userspace-api/media $2 && \
7676
PYTHONDONTWRITEBYTECODE=1 \
77-
BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
77+
BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(src)/$5/$(SPHINX_CONF)) \
7878
$(PYTHON3) $(srctree)/scripts/jobserver-exec \
7979
$(CONFIG_SHELL) $(srctree)/Documentation/sphinx/parallel-wrapper.sh \
8080
$(SPHINXBUILD) \
8181
-b $2 \
82-
-c $(abspath $(srctree)/$(src)) \
82+
-c $(abspath $(src)) \
8383
-d $(abspath $(BUILDDIR)/.doctrees/$3) \
8484
-D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \
8585
$(ALLSPHINXOPTS) \
86-
$(abspath $(srctree)/$(src)/$5) \
86+
$(abspath $(src)/$5) \
8787
$(abspath $(BUILDDIR)/$3/$4)
8888

8989
YNL_INDEX:=$(srctree)/Documentation/networking/netlink_spec/index.rst

Documentation/devicetree/bindings/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ $(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE
2222
# Use full schemas when checking %.example.dts
2323
DT_TMP_SCHEMA := $(obj)/processed-schema-examples.json
2424

25-
find_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \
25+
find_cmd = find $(src) \( -name '*.yaml' ! \
2626
-name 'processed-schema*' ! \
2727
-name '*.example.dt.yaml' \)
2828

2929
quiet_cmd_yamllint = LINT $(src)
3030
cmd_yamllint = ($(find_cmd) | \
31-
xargs $(DT_SCHEMA_LINT) -f parsable -c $(srctree)/$(src)/.yamllint) || true
31+
xargs $(DT_SCHEMA_LINT) -f parsable -c $(src)/.yamllint) || true
3232

3333
quiet_cmd_chk_bindings = CHKDT $@
3434
cmd_chk_bindings = ($(find_cmd) | \
35-
xargs -n200 -P$$(nproc) $(DT_DOC_CHECKER) -u $(srctree)/$(src)) || true
35+
xargs -n200 -P$$(nproc) $(DT_DOC_CHECKER) -u $(src)) || true
3636

3737
quiet_cmd_mk_schema = SCHEMA $@
3838
cmd_mk_schema = f=$$(mktemp) ; \

Documentation/kbuild/makefiles.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ more details, with real examples.
421421
Example::
422422

423423
#arch/cris/boot/compressed/Makefile
424-
ldflags-y += -T $(srctree)/$(src)/decompress_$(arch-y).lds
424+
ldflags-y += -T $(src)/decompress_$(arch-y).lds
425425

426426
subdir-ccflags-y, subdir-asflags-y
427427
The two flags listed above are similar to ccflags-y and asflags-y.
@@ -502,14 +502,14 @@ more details, with real examples.
502502
Two variables are used when defining custom rules:
503503

504504
$(src)
505-
$(src) is a relative path which points to the directory
506-
where the Makefile is located. Always use $(src) when
505+
$(src) is the directory where the Makefile is located. Always use $(src) when
507506
referring to files located in the src tree.
508507

509508
$(obj)
510-
$(obj) is a relative path which points to the directory
511-
where the target is saved. Always use $(obj) when
512-
referring to generated files.
509+
$(obj) is the directory where the target is saved. Always use $(obj) when
510+
referring to generated files. Use $(obj) for pattern rules that need to work
511+
for both generated files and real sources (VPATH will help to find the
512+
prerequisites not only in the object tree but also in the source tree).
513513

514514
Example::
515515

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,14 @@ srctree := $(abs_srctree)
264264
endif
265265

266266
objtree := .
267+
268+
VPATH :=
269+
270+
ifeq ($(KBUILD_EXTMOD),)
271+
ifdef building_out_of_srctree
267272
VPATH := $(srctree)
273+
endif
274+
endif
268275

269276
export building_out_of_srctree srctree objtree VPATH
270277

@@ -2001,7 +2008,7 @@ nsdeps: modules
20012008
quiet_cmd_gen_compile_commands = GEN $@
20022009
cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
20032010

2004-
$(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
2011+
$(extmod_prefix)compile_commands.json: $(srctree)/scripts/clang-tools/gen_compile_commands.py \
20052012
$(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \
20062013
$(if $(CONFIG_MODULES), $(MODORDER)) FORCE
20072014
$(call if_changed,gen_compile_commands)

arch/arc/boot/dts/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ obj-y += $(builtindtb-y).dtb.o
1010
dtb-y := $(builtindtb-y).dtb
1111

1212
# for CONFIG_OF_ALL_DTBS test
13-
dtstree := $(srctree)/$(src)
14-
dtb- := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts))
13+
dtb- := $(patsubst $(src)/%.dts,%.dtb, $(wildcard $(src)/*.dts))
1514

1615
# board-specific dtc flags
1716
DTC_FLAGS_hsdk += --pad 20

arch/arm/Kbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
obj-$(CONFIG_FPE_NWFPE) += nwfpe/
33
# Put arch/arm/fastfpe/ to use this.
4-
obj-$(CONFIG_FPE_FASTFPE) += $(patsubst $(srctree)/$(src)/%,%,$(wildcard $(srctree)/$(src)/fastfpe/))
4+
obj-$(CONFIG_FPE_FASTFPE) += $(patsubst $(src)/%,%,$(wildcard $(src)/fastfpe/))
55
obj-$(CONFIG_VFP) += vfp/
66
obj-$(CONFIG_XEN) += xen/
77
obj-$(CONFIG_VDSO) += vdso/

arch/arm/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ $(BOOT_TARGETS): vmlinux
308308
@$(kecho) ' Kernel: $(boot)/$@ is ready'
309309

310310
$(INSTALL_TARGETS):
311-
$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@
311+
$(CONFIG_SHELL) $(srctree)/$(boot)/install.sh "$(KERNELRELEASE)" \
312+
$(boot)/$(patsubst %install,%Image,$@) System.map "$(INSTALL_PATH)"
312313

313314
PHONY += vdso_install
314315
vdso_install:

arch/arm/boot/Makefile

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ targets := Image zImage xipImage bootpImage uImage
3131

3232
ifeq ($(CONFIG_XIP_KERNEL),y)
3333

34-
cmd_deflate_xip_data = $(CONFIG_SHELL) -c \
35-
'$(srctree)/$(src)/deflate_xip_data.sh $< $@'
34+
cmd_deflate_xip_data = $(CONFIG_SHELL) -c '$(src)/deflate_xip_data.sh $< $@'
3635

3736
ifeq ($(CONFIG_XIP_DEFLATED_DATA),y)
3837
quiet_cmd_mkxip = XIPZ $@
@@ -96,23 +95,11 @@ $(obj)/bootp/bootp: $(obj)/zImage initrd FORCE
9695
$(obj)/bootpImage: $(obj)/bootp/bootp FORCE
9796
$(call if_changed,objcopy)
9897

99-
PHONY += initrd install zinstall uinstall
98+
PHONY += initrd
10099
initrd:
101100
@test "$(INITRD_PHYS)" != "" || \
102101
(echo This machine does not support INITRD; exit -1)
103102
@test "$(INITRD)" != "" || \
104103
(echo You must specify INITRD; exit -1)
105104

106-
install:
107-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
108-
$(obj)/Image System.map "$(INSTALL_PATH)"
109-
110-
zinstall:
111-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
112-
$(obj)/zImage System.map "$(INSTALL_PATH)"
113-
114-
uinstall:
115-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
116-
$(obj)/uImage System.map "$(INSTALL_PATH)"
117-
118105
subdir- := bootp compressed dts

arch/arm/mach-davinci/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
#
66

7-
ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include
7+
ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(src)/include
88

99
# Common objects
1010
obj-y := serial.o usb.o common.o sram.o

arch/arm/mach-omap2/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Makefile for the linux kernel.
44
#
55

6-
ccflags-y := -I$(srctree)/$(src)/include \
6+
ccflags-y := -I$(src)/include \
77
-I$(srctree)/arch/arm/plat-omap/include
88

99
# Common support

0 commit comments

Comments
 (0)