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

Petr Mladek <[email protected]> Fri, 3 Jul 2026 10:26:07 +0200
Newsgroups org.kernel.vger.live-patching,dev.linux.lists.sashiko-reviews,org.kernel.vger.linux-kbuild,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest
Message-ID <[email protected]>
On Fri 2026-07-03 06:14:48, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Incomplete fix and inconsistent state: The patch correctly unsets `sub_make_done` for the `kselftest` targets to allow Kbuild command-line reevaluation when building external kernel modules. However, it fails to apply the same logic to the `tools/` and `tools/%` targets, introducing a discrepancy between build entry points.
> --
> 
> commit 06c418388d65deb3d8494a6e8e7071c0e709186b
> Author: Thomas Weißschuh <[email protected]>
> 
> kbuild: unset sub_make_done before calling kselftest build system
> 
> This commit unsets sub_make_done before invoking the kselftest build system to
> ensure Kbuild reevaluates command-line flags when building test modules. It
> mirrors a previous fix done for scripts/install.sh.
> 
> > diff --git a/Makefile b/Makefile
> > index b9c5792c79e01..f717a4dc96d6a 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
> 
> [Severity: Medium]
> Will make tools/selftests still fail after this change?
> 
> The tools/ and tools/% targets in Makefile delegate to the tools build
> system, which can also trigger external kernel module builds (like bpf_testmod).
> 
> Because sub_make_done is not unset for these targets, invoking commands like
> make tools/selftests or make tools/all will skip Kbuild's M= argument parsing.
> 
> Should sub_make_done also be unset in the tools/ and tools/% targets to maintain
> consistency across the build entry points?

This might make sense. I see that the tools: and tools/%: targets are
defined right above the kselftest*: ones. And they are even advertised
in "make help" or "make tools/help".

Well it probably should be done in a separate patch. It would be better
for bisecting potential regressions. Thomas, Zelin, what do you think, please?

Best Regards,
Petr