The exported sub_make_done variable leaks into the environment of all
child processes. When make targets like tcheck spawn independent
make-invocations with O=, those child-makes inherit sub_make_done=1,
skip the KBUILD_OUTPUT setup and try to build in the source tree.
A global 'unexport sub_make_done' cannot be used because the build
system itself re-invokes the top-level Makefile for syncconfig (via
'$(MAKE) -f $(srctree)/Makefile syncconfig'). Without sub_make_done,
that child make re-enters the KBUILD_OUTPUT block and recomputes
abs_objtree. With a relative O= path this resolves to a nested
directory (e.g. build/build/) where .config does not exist.
Instead, use 'env -u sub_make_done' in the test-target recipes so only
the test scripts see a clean environment. This allows their child make
invocations to process O= correctly without affecting internal kbuild
recursion.
This is not strictly a bugfix, but compare with:
commit 27529f1cb02d ("kbuild: skip parsing pre sub-make code for recursion")
Signed-off-by: Simon Glass <[email protected]>
---
Changes in v2:
- Use recipe-level env -u to avoid breaking relative O= builds
Makefile | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 5df869213b6..65bac2e5b26 100644
--- a/Makefile
+++ b/Makefile
@@ -2737,21 +2737,19 @@ help:
@echo 'Execute "make" or "make all" to build all targets marked with
[*] '
@echo 'For further info see the ./README file'
-ifneq ($(filter tests pcheck qcheck tcheck,$(MAKECMDGOALS)),)
-export sub_make_done := 0
-endif
+run_tests = $(Q)env -u sub_make_done $(srctree)/test/run
tests check:
- $(srctree)/test/run
+ $(run_tests)
pcheck:
- $(srctree)/test/run parallel
+ $(run_tests) parallel
qcheck:
- $(srctree)/test/run quick
+ $(run_tests) quick
tcheck:
- $(srctree)/test/run tools
+ $(run_tests) tools
# Documentation targets
# ---------------------------------------------------------------------------
--
2.43.0
base-commit: 80d0a2f6016d32b4e732a4d6eae8341d68fafe5e
branch: fix-kbuild2