[PATCH] kbuild: unset sub_make_done before calling kselftest build system

From: Thomas Weißschuh

Date: Fri Jul 03 2026 - 02:13:18 EST


The kselftest build system may recourse back into kbuild when building
test modules. In that case kbuild needs to parse the new flags passed
from the command line, instead of using the ones inherited from the
kbuild invocation.

Force that command line reevaluation.

The same was done for scripts/install.sh in commit 14ccc638b02f9ec
("kbuild: cancel sub_make_done for the install target to fix DKMS")

Reported-by: Zelin Deng <zelin.deng@xxxxxxxxxxxxxxxxx>
Closes: https://lore.kernel.org/all/20260525083721.27857-1-zelin.deng@xxxxxxxxxxxxxxxxx/
Fixes: c9bb03ac2c66 ("kbuild: reduce output spam when building out of tree")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index b9c5792c79e0..f717a4dc96d6 100644
--- a/Makefile
+++ b/Makefile
@@ -1591,10 +1591,10 @@ tools/%: FORCE

PHONY += kselftest
kselftest: headers
- $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
+ $(Q)unset sub_make_done; $(MAKE) -C $(srctree)/tools/testing/selftests run_tests

kselftest-%: headers FORCE
- $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
+ $(Q)unset sub_make_done; $(MAKE) -C $(srctree)/tools/testing/selftests $*

PHONY += kselftest-merge
kselftest-merge:

---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260702-makefile-unset-submake-done-cbc0b9375617

Best regards,
--
Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>