]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
kbuild: strip sub_make_done from test-script environment
authorSimon Glass <sjg@chromium.org>
Wed, 4 Mar 2026 18:48:53 +0000 (11:48 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 16 Mar 2026 16:41:40 +0000 (10:41 -0600)
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 <sjg@chromium.org>
Makefile

index 627f1775fe1432d752e35b7d454341fd4a5f3b2a..8295cd4e5e83e311ec4cc55dda0d5a968af6e324 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2747,21 +2747,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
 # ---------------------------------------------------------------------------