Re: [RFC PATCH v2 5/7] tools: build kernel selftests in tools_build

From: Sasha Levin

Date: Sun Oct 18 2026 - 10:40:30 EST


On Sat, Oct 17, 2026 at 02:32:12PM +0000, sashiko-bot@xxxxxxxxxx wrote:
>> +config TOOLS_BUILD_SELFTESTS_KEXEC
>> + bool "kexec"
>> + depends on X86_64
>
>[Severity: Medium]
>Does this unnecessarily restrict the kexec selftest to X86_64?
>
>Looking at tools/testing/selftests/kexec/Makefile, it explicitly supports both
>x86 (32-bit and 64-bit) and ppc64le:
[...]
>Configuring the tools build on ppc64le or 32-bit x86 will not expose this
>option, silently excluding the test from being built and installed on these
>platforms.

TOOLS_BUILD is only available on x86_64 and arm64 for now
(TOOLS_BUILD_ABI), so no entry can be selected on ppc64le or 32-bit x86.
The kexec Makefile has no tests for arm64, which leaves x86_64.

>> +$(selftest-shared): FORCE
>> + $(Q)mkdir -p $(@D); \
>> + newest=$$(find $(CURDIR)/usr/include $(toolsdir)/include $(toolsdir)/arch $(toolsdir)/testing/selftests \
>> + -type f \( -name '*.h' -o -name '*.mk' -o -name Makefile \) -printf '%T@\n' | \
>> + sort -n | tail -n 1); \
>> + touch -d "@$${newest:-0}" $@
>
>[Severity: Medium]
>Will this miss rebuild dependencies on shared build scripts?
[...]
>Modifying core shared files like tools/scripts/Makefile.include,
>tools/scripts/Makefile.arch, or scripts/subarch.include will not trigger a
>rebuild of selftests that include them, which can lead to stale builds.

Right. Of the selftests built here, kexec and vDSO include
tools/scripts/Makefile.arch and rseq includes scripts/subarch.include,
and neither file is checked. I'll add both in the next version.

>[Severity: High]
>Can this trigger a fatal Make syntax error if no selftests are selected?
[...]
>Since this rule uses two colons, it is a static pattern rule. While GNU Make
>ignores empty targets for single-colon rules, an empty target list in a
>double-colon static pattern rule evaluates to : selftest-%: ... and
>triggers a fatal missing target pattern. Stop. build error.

This is not a double-colon rule, and make ignores a static pattern rule
whose target list is empty. With CONFIG_TOOLS_BUILD=y and no tool or
selftest selected, Makefile.kbuild runs with make 4.4.1 and reports
nothing to be done for __tools_build, with and without -n.

--
Thanks,
Sasha