Fix kselftest build with sub-directory
Subsystems (10)
v2 cover Fix kselftest build with sub-directory
Earlier attempts to get "make O=build kselftest-all" to work were not successful as they made undesirable changes to some functions in the top-level Makefile. This series takes a different approach by removing the root cause of the problem within kselftest, which is when the sub-Makefile tries to install kernel headers "backwards" by calling make with the top-level Makefile. The actual issue comes from the fact that $(srctree) is ".." when building in a sub-directory with "O=build" which then obviously makes "-C $(top_srcdir)" point outside of the real source tree.
With this series, the generic kselftest targets work as expected from the top level with or without a build directory e.g.:
$ make kselftest-all
$ make O=build kselftest-all
Then in order to build using the sub-Makefile explicitly, the headers have to be installed first. This is arguably a valid requirement to have when building a tool from a sub-Makefile. For example, "make -C tools/testing/nvdimm/" fails in a similar way until <asm/rwonce.h> has been generated by a kernel build.
v2: replace headers_install with headers
Guillaume Tucker (4):
selftests: drop khdr make target
selftests: stop using KSFT_KHDR_INSTALL
selftests: drop KSFT_KHDR_INSTALL make target
Makefile: add headers to kselftest targets
Makefile | 4 +- tools/testing/selftests/Makefile | 28 +------------- tools/testing/selftests/arm64/mte/Makefile | 1 - tools/testing/selftests/arm64/signal/Makefile | 1 - .../selftests/arm64/signal/test_signals.h | 4 +- .../selftests/drivers/s390x/uvdevice/Makefile | 1 - .../selftests/futex/functional/Makefile | 1 - tools/testing/selftests/kvm/Makefile | 1 - tools/testing/selftests/landlock/Makefile | 1 - tools/testing/selftests/lib.mk | 38 ------------------- tools/testing/selftests/net/Makefile | 1 - tools/testing/selftests/net/mptcp/Makefile | 1 - tools/testing/selftests/tc-testing/Makefile | 1 - tools/testing/selftests/vm/Makefile | 1 - 14 files changed, 5 insertions(+), 79 deletions(-)
--
2.30.2
PATCH v2 1/4 selftests: drop khdr make target
Drop the "khdr" make target as it fails when the build directory is a sub-directory of the source tree. Rely on the "headers_install" target to have been run first instead.
For example, here's a typical error this patch is addressing:
$ make O=build -j32 kselftest-gen_tar
make[1]: Entering directory '/home/kernelci/linux/build'
make --no-builtin-rules INSTALL_HDR_PATH=/home/kernelci/linux/build/usr \
ARCH=x86 -C ../../.. headers_install
make[3]: Entering directory '/home/kernelci/linux'
Makefile:1022: ../scripts/Makefile.extrawarn: No such file or directoryThe source directory is determined in the top-level Makefile as ".." relatively to the "build" directory, but then the kselftest Makefile switches to "-C ../../.." so "../scripts" then points one level higher than the source tree e.g. "linux/../scripts" - which fails obviously. There is no other use-case in the kernel tree where a sub-directory Makefile tries to call a top-level make target, and it appears this isn't really a valid thing to do.
--- tools/testing/selftests/Makefile | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-)
tools/testing/selftests/Makefile +2 -25
@@ -151,30 +151,7 @@ export KHDR_INCLUDES # all isn't the first target in the file. .DEFAULT_GOAL := all -# Install headers here once for all tests. KSFT_KHDR_INSTALL_DONE -# is used to avoid running headers_install from lib.mk. -# Invoke headers install with --no-builtin-rules to avoid circular -# dependency in "make kselftest" case. In this case, second level -# make inherits builtin-rules which will use the rule generate -# Makefile.o and runs into -# "Circular Makefile.o <- prepare dependency dropped." -# and headers_install fails and test compile fails. -# -# O= KBUILD_OUTPUT cases don't run into this error, since main Makefile -# invokes them as sub-makes and --no-builtin-rules is not necessary, -# but doesn't cause any failures. Keep it simple and use the same -# flags in both cases. -# Local build cases: "make kselftest", "make -C" - headers are installed -# in the default INSTALL_HDR_PATH usr/include. -khdr: -ifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) - $(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install -else - $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$(abs_objtree)/usr \ - ARCH=$(ARCH) -C $(top_srcdir) headers_install -endif - -all: khdr +all: @ret=1; \ for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \
@@ -274,4 +251,4 @@ clean: $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ done; -.PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar +.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar
Signature · 1 line
2.30.2
PATCH v2 2/4 selftests: stop using KSFT_KHDR_INSTALL
In reply to Guillaume TuckerStop using the KSFT_KHDR_INSTALL flag as installing the kernel headers from the kselftest Makefile is causing some issues. Instead, rely on the headers to be installed directly by the top-level Makefile "headers_install" make target prior to building kselftest.
--- tools/testing/selftests/arm64/mte/Makefile | 1 - tools/testing/selftests/arm64/signal/Makefile | 1 - tools/testing/selftests/arm64/signal/test_signals.h | 4 +--- tools/testing/selftests/drivers/s390x/uvdevice/Makefile | 1 - tools/testing/selftests/futex/functional/Makefile | 1 - tools/testing/selftests/kvm/Makefile | 1 - tools/testing/selftests/landlock/Makefile | 1 - tools/testing/selftests/net/Makefile | 1 - tools/testing/selftests/net/mptcp/Makefile | 1 - tools/testing/selftests/tc-testing/Makefile | 1 - tools/testing/selftests/vm/Makefile | 1 - 11 files changed, 1 insertion(+), 13 deletions(-)
tools/testing/selftests/arm64/mte/Makefile +0 -1
@@ -22,7 +22,6 @@ ifeq ($(mte_cc_support),1) TEST_GEN_PROGS := $(PROGS) # Get Kernel headers installed and use them. -KSFT_KHDR_INSTALL := 1 else $(warning compiler "$(CC)" does not support the ARMv8.5 MTE extension.) $(warning test program "mte" will not be created.)
tools/testing/selftests/arm64/signal/Makefile +0 -1
@@ -11,7 +11,6 @@ PROGS := $(patsubst %.c,%,$(SRCS)) TEST_GEN_PROGS := $(notdir $(PROGS)) # Get Kernel headers installed and use them. -KSFT_KHDR_INSTALL := 1 # Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list # to account for any OUTPUT target-dirs optionally provided by
tools/testing/selftests/arm64/signal/test_signals.h +1 -3
@@ -9,9 +9,7 @@#include <ucontext.h> /* -* Using ARCH specific and sanitized Kernel headers installed by KSFT -* framework since we asked for it by setting flag KSFT_KHDR_INSTALL -* in our Makefile. +* Using ARCH specific and sanitized Kernel headers from the tree. */ #include <asm/ptrace.h> #include <asm/hwcap.h>
tools/testing/selftests/drivers/s390x/uvdevice/Makefile +0 -1
@@ -11,7 +11,6 @@ else TEST_GEN_PROGS := test_uvdevice top_srcdir ?= ../../../../../.. -KSFT_KHDR_INSTALL := 1 khdr_dir = $(top_srcdir)/usr/include LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
tools/testing/selftests/futex/functional/Makefile +0 -1
@@ -22,7 +22,6 @@ TEST_GEN_FILES := \ TEST_PROGS := run.sh top_srcdir = ../../../../.. -KSFT_KHDR_INSTALL := 1 DEFAULT_INSTALL_HDR_PATH := 1 include ../../lib.mk
tools/testing/selftests/kvm/Makefile +0 -1
@@ -4,7 +4,6 @@ include ../../../build/Build.include all: top_srcdir = ../../../.. -KSFT_KHDR_INSTALL := 1 # For cross-builds to work, UNAME_M has to map to ARCH and arch specific # directories and targets in this Makefile. "uname -m" doesn't map to
tools/testing/selftests/landlock/Makefile +0 -1
@@ -8,7 +8,6 @@ TEST_GEN_PROGS := $(src_test:.c=) TEST_GEN_PROGS_EXTENDED := true -KSFT_KHDR_INSTALL := 1 OVERRIDE_TARGETS := 1 include ../lib.mk
tools/testing/selftests/net/Makefile +0 -1
@@ -63,7 +63,6 @@ TEST_GEN_FILES += bind_bhash_test TEST_FILES := settings -KSFT_KHDR_INSTALL := 1 include ../lib.mk include bpf/Makefile
tools/testing/selftests/net/mptcp/Makefile +0 -1
@@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 top_srcdir = ../../../../.. -KSFT_KHDR_INSTALL := 1 CFLAGS = -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
tools/testing/selftests/tc-testing/Makefile +0 -1
@@ -5,7 +5,6 @@ top_srcdir = $(abspath ../../../..) APIDIR := $(top_scrdir)/include/uapi TEST_GEN_FILES = action.o -KSFT_KHDR_INSTALL := 1 include ../lib.mk PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1)
tools/testing/selftests/vm/Makefile +0 -1
@@ -94,7 +94,6 @@ TEST_PROGS := run_vmtests.sh TEST_FILES := test_vmalloc.sh TEST_FILES += test_hmm.sh -KSFT_KHDR_INSTALL := 1 include ../lib.mk $(OUTPUT)/madv_populate: vm_util.c
Signature · 1 line
2.30.2
PATCH v2 3/4 selftests: drop KSFT_KHDR_INSTALL make target
In reply to Guillaume TuckerDrop the KSFT_KHDR_INSTALL make target now that all use-cases have been removed from the other kselftest Makefiles.
--- tools/testing/selftests/Makefile | 1 - tools/testing/selftests/lib.mk | 38 -------------------------------- 2 files changed, 39 deletions(-)
tools/testing/selftests/Makefile +0 -1
@@ -143,7 +143,6 @@ endif # Prepare for headers install include $(top_srcdir)/scripts/subarch.include ARCH ?= $(SUBARCH) -export KSFT_KHDR_INSTALL_DONE := 1 export BUILD export KHDR_INCLUDES
tools/testing/selftests/lib.mk +0 -38
@@ -30,45 +30,7 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) -ifdef KSFT_KHDR_INSTALL -top_srcdir ?= ../../../.. -include $(top_srcdir)/scripts/subarch.include -ARCH ?= $(SUBARCH) - -# set default goal to all, so make without a target runs all, even when -# all isn't the first target in the file. -.DEFAULT_GOAL := all - -# Invoke headers install with --no-builtin-rules to avoid circular -# dependency in "make kselftest" case. In this case, second level -# make inherits builtin-rules which will use the rule generate -# Makefile.o and runs into -# "Circular Makefile.o <- prepare dependency dropped." -# and headers_install fails and test compile fails. -# O= KBUILD_OUTPUT cases don't run into this error, since main Makefile -# invokes them as sub-makes and --no-builtin-rules is not necessary, -# but doesn't cause any failures. Keep it simple and use the same -# flags in both cases. -# Note that the support to install headers from lib.mk is necessary -# when test Makefile is run directly with "make -C". -# When local build is done, headers are installed in the default -# INSTALL_HDR_PATH usr/include. -.PHONY: khdr -.NOTPARALLEL: -khdr: -ifndef KSFT_KHDR_INSTALL_DONE -ifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) - $(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install -else - $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$OUTPUT/usr \ - ARCH=$(ARCH) -C $(top_srcdir) headers_install -endif -endif - -all: khdr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) -else all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) -endif define RUN_TESTS BASE_DIR="$(selfdir)"; \
Signature · 1 line
2.30.2
Re: [PATCH v2 3/4] selftests: drop KSFT_KHDR_INSTALL make target
Quoted 62 lines · Guillaume Tucker
Drop the
KSFT_KHDR_INSTALLmake target now that all use-cases have been removed from the other kselftest Makefiles.Signed-off-by Guillaume Tucker <[email protected]>--- tools/testing/selftests/Makefile | 1 - tools/testing/selftests/lib.mk | 38 -------------------------------- 2 files changed, 39 deletions(-)tools/testing/selftests/Makefile +0
-1@@ -143,7 +143,6 @@ endif # Prepare for headers install include $(top_srcdir)/scripts/subarch.include ARCH ?= $(SUBARCH) -export KSFT_KHDR_INSTALL_DONE := 1 export BUILD export KHDR_INCLUDEStools/testing/selftests/lib.mk +0
-32@@ -30,45 +30,7 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) -ifdef KSFT_KHDR_INSTALL -top_srcdir ?= ../../../.. -include $(top_srcdir)/scripts/subarch.include -ARCH ?= $(SUBARCH) - -# set default goal to all, so make without a target runs all, even when -# all isn't the first target in the file. -.DEFAULT_GOAL := all - -# Invoke headers install with --no-builtin-rules to avoid circular -# dependency in "make kselftest" case. In this case, second level -# make inherits builtin-rules which will use the rule generate -# Makefile.o and runs into -# "Circular Makefile.o <- prepare dependency dropped." -# and headers_install fails and test compile fails. -# O= KBUILD_OUTPUT cases don't run into this error, since main Makefile -# invokes them as sub-makes and --no-builtin-rules is not necessary, -# but doesn't cause any failures. Keep it simple and use the same -# flags in both cases. -# Note that the support to install headers from lib.mk is necessary -# when test Makefile is run directly with "make -C". -# When local build is done, headers are installed in the default -# INSTALL_HDR_PATH usr/include. -.PHONY: khdr -.NOTPARALLEL: -khdr: -ifndef KSFT_KHDR_INSTALL_DONE -ifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) - $(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install -else - $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$OUTPUT/usr \ - ARCH=$(ARCH) -C $(top_srcdir) headers_install
tools/testing/selftests/lib.mk TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) · line 36
Quoted 10 lines
tools/testing/selftests/lib.mk +0
-6-endif -endif - -all: khdr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) -else all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) -endif define RUN_TESTS BASE_DIR="$(selfdir)"; \
Should this be removed as well, since 'khdr' gets droped from file the lib.mk ?
(quoted diff) +0 -0
b/tools/testing/selftests/landlock/Makefile
index 1313e44e8fb9..99f88c52d61a 100644
tools/testing/selftests/landlock/Makefile +0 -3
@@ -13,9 +13,6 @@ include ../lib.mk khdr_dir = $(top_srcdir)/usr/include -$(khdr_dir)/linux/landlock.h: khdr - @: - $(OUTPUT)/true: true.c $(LINK.c) $< $(LDLIBS) -o $@ -static
Cheers,
Anders
Re: [PATCH v2 3/4] selftests: drop KSFT_KHDR_INSTALL make target
Quoted 83 lines · Anders Roxell
Quoted 62 lines · Guillaume Tucker
Drop the
KSFT_KHDR_INSTALLmake target now that all use-cases have been removed from the other kselftest Makefiles.Signed-off-by Guillaume Tucker <[email protected]>--- tools/testing/selftests/Makefile | 1 - tools/testing/selftests/lib.mk | 38 -------------------------------- 2 files changed, 39 deletions(-)tools/testing/selftests/Makefile +0
-1@@ -143,7 +143,6 @@ endif # Prepare for headers install include $(top_srcdir)/scripts/subarch.include ARCH ?= $(SUBARCH) -export KSFT_KHDR_INSTALL_DONE := 1 export BUILD export KHDR_INCLUDEStools/testing/selftests/lib.mk +0
-32@@ -30,45 +30,7 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) -ifdef KSFT_KHDR_INSTALL -top_srcdir ?= ../../../.. -include $(top_srcdir)/scripts/subarch.include -ARCH ?= $(SUBARCH) - -# set default goal to all, so make without a target runs all, even when -# all isn't the first target in the file. -.DEFAULT_GOAL := all - -# Invoke headers install with --no-builtin-rules to avoid circular -# dependency in "make kselftest" case. In this case, second level -# make inherits builtin-rules which will use the rule generate -# Makefile.o and runs into -# "Circular Makefile.o <- prepare dependency dropped." -# and headers_install fails and test compile fails. -# O= KBUILD_OUTPUT cases don't run into this error, since main Makefile -# invokes them as sub-makes and --no-builtin-rules is not necessary, -# but doesn't cause any failures. Keep it simple and use the same -# flags in both cases. -# Note that the support to install headers from lib.mk is necessary -# when test Makefile is run directly with "make -C". -# When local build is done, headers are installed in the default -# INSTALL_HDR_PATH usr/include. -.PHONY: khdr -.NOTPARALLEL: -khdr: -ifndef KSFT_KHDR_INSTALL_DONE -ifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) - $(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install -else - $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$OUTPUT/usr \ - ARCH=$(ARCH) -C $(top_srcdir) headers_installtools/testing/selftests/lib.mk TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) · line 36
Quoted 10 lines
tools/testing/selftests/lib.mk +0
-6-endif -endif - -all: khdr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) -else all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) -endif define RUN_TESTS BASE_DIR="$(selfdir)"; \Should this be removed as well, since 'khdr' gets droped from file the lib.mk ?
tools/testing/selftests/landlock/Makefile +0
-0
tools/testing/selftests/landlock/Makefile include ../lib.mk · line 17
Quoted 8 lines
tools/testing/selftests/landlock/Makefile +0
-3@@ -13,9 +13,6 @@ include ../lib.mk khdr_dir = $(top_srcdir)/usr/include -$(khdr_dir)/linux/landlock.h: khdr - @: - $(OUTPUT)/true: true.c $(LINK.c) $< $(LDLIBS) -o $@ -static
Good point, however I think I'll drop it in PATCH 1/4 "selftests:
drop khdr make target" as it's already dropped there. Ideally, the khdr dependency mentioned in this PATCH 3/4 should probably also be removed in PATCH 1/4. I'll send a v3 with this.
Thanks,
Guillaume
PATCH v2 4/4 Makefile: add headers to kselftest targets
In reply to Guillaume TuckerAdd headers as a dependency to kselftest targets so that they can be run directly from the top of the tree. The kselftest Makefile used to try to call headers_install "backwards" but failed due to the relative path not being consistent.
Now we can either run this directly:
$ make O=build kselftest-all
or this:
$ make O=build headers $ make O=build -C tools/testing/selftests all
The same commands work as well when building directly in the source tree (no O=) or any arbitrary path (relative or absolute).
---
Notes:
v2: replace headers_install with headers
Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -1347,10 +1347,10 @@ tools/%: FORCE # Kernel selftest PHONY += kselftest -kselftest: +kselftest: headers $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests -kselftest-%: FORCE +kselftest-%: headers FORCE $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $* PHONY += kselftest-merge
Signature · 1 line
2.30.2
Re: [PATCH v2 4/4] Makefile: add headers to kselftest targets
Quoted 11 lines · On Tue, 12 Jul 2022 09:29 +0100 Guillaume Tucker wrote:
Add headers as a dependency to kselftest targets so that they can be run directly from the top of the tree. The kselftest
Makefileused to try to callheaders_install"backwards" but failed due to the relative path not being consistent.Now we can either run this directly:
$ make O=build kselftest-allor this:
Quoted 8 lines
$ make O=build headers $ make O=build -C tools/testing/selftests allThe same commands work as well when building directly in the source tree (no O=) or any arbitrary path (relative or absolute).
Signed-off-by Guillaume Tucker <[email protected]>---
You might want to add the 'Reported-by: as you did in
https://lore.kernel.org/linux-kbuild/a7af58feaa6ae6d3b0c8c55972a470cec62341e5.1657693952.git.guillaume.tucker@collabora.com/
?
Quoted 26 lines
Notes:
v2: replaceheaders_installwith headersMakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Makefile +2
-2@@ -1347,10 +1347,10 @@ tools/%: FORCE # Kernel selftest PHONY += kselftest -kselftest: +kselftest: headers $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests -kselftest-%: FORCE +kselftest-%: headers FORCE $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $* PHONY += kselftest-mergeSignature · 1 line
2.30.2
Signature · 3 lines
epost|xmpp: [email protected] irc://oftc.net/nsc ↳ gpg: 18ed 52db e34f 860e e9fb c82b 7d97 0932 55a0 ce7f -- frykten for herren er opphav til kunnskap --
Re: [PATCH v2 4/4] Makefile: add headers to kselftest targets
Quoted 15 lines · Nicolas Schier
Quoted 14 lines · On Tue, 12 Jul 2022 09:29 +0100 Guillaume Tucker wrote:
Add headers as a dependency to kselftest targets so that they can be run directly from the top of the tree. The kselftest
Makefileused to try to callheaders_install"backwards" but failed due to the relative path not being consistent.Now we can either run this directly:
$ make O=build kselftest-allor this:
$ make O=build headers $ make O=build -C tools/testing/selftests all
Quoted 7 lines
Quoted 5 lines
The same commands work as well when building directly in the source tree (no O=) or any arbitrary path (relative or absolute).
Signed-off-by Guillaume Tucker <[email protected]>---
You might want to add the 'Reported-by: as you did in
https://lore.kernel.org/linux-kbuild/a7af58feaa6ae6d3b0c8c55972a470cec62341e5.1657693952.git.guillaume.tucker@collabora.com/
Except I don't know who reported the issue, I think it was just very well known. KernelCI builds have been working around it for a couple of years.
The Reported-by in the other patch was about using "headers" rather than "headers_install", as a follow-up improvement on top of this patch.
Quoted 1 line
Tested-by Nicolas Schier <[email protected]>
Thank you!
Guillaume
Shuah Khan
maintainerQuoted 17 lines · Guillaume Tucker
Earlier attempts to get "make O=build kselftest-all" to work were not successful as they made undesirable changes to some functions in the top-level
Makefile. This series takes a different approach by removing the root cause of the problem within kselftest, which is when the sub-Makefile tries to install kernel headers "backwards" by calling make with the top-levelMakefile. The actual issue comes from the fact that $(srctree) is ".." when building in a sub-directory with "O=build" which then obviously makes "-C $(top_srcdir)" point outside of the real source tree.With this series, the generic kselftest targets work as expected from the top level with or without a build directory e.g.:
$ make kselftest-all$ make O=build kselftest-all
Quoted 8 lines
Then in order to build using the sub-Makefile explicitly, the headers have to be installed first. This is arguably a valid requirement to have when building a tool from a sub-Makefile. For example, "make -C
tools/testing/nvdimm/" fails in a similar way until <asm/rwonce.h> has been generated by a kernel build.v2: replace
headers_installwith headers
I already applied the series. Please send me patches I can apply on top of the ones in linux-kselftest next branch.
thanks,
-- Shuah