Re: [PATCH 1/1] kbuild: record real-prereqs in .cmd files

From: Nathan Chancellor

Date: Tue Aug 18 2026 - 15:51:30 EST


> Record $(real-prereqs), the non-phony prerequisites of the target, in a
> new metadata field:
>
> make_prereqs_<target> := <prerequisites>
>
> Write the field from both cmd_and_savecmd and cmd_and_fixdep.
>
> Update scripts/make_fit.py to read only savedcmd_* instead of parsing the
> complete .cmd file.
>
> Ignore make_prereqs_* in KernelSbom.
>
> Link: https://lore.kernel.org/r/a01233b9-23a2-4666-91ed-f1cf030dcb9f@xxxxxxxxxxx
> Assisted-by: Cursor:GPT-5.6 Sol
> Co-developed-by: Maximilian Huber <maximilian.huber@xxxxxxxxxxx>
> Signed-off-by: Maximilian Huber <maximilian.huber@xxxxxxxxxxx>
> Signed-off-by: Luis Augenstein <luis.augenstein@xxxxxxxxxxx>
>
> diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> index 8c311b997e24..6daa244ba0ef 100644
> --- a/scripts/Kbuild.include
> +++ b/scripts/Kbuild.include
> @@ -181,6 +181,9 @@ endif
> # (needed for the shell)
> make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))))
>
> +# prerequisites to record in .cmd files, excluding those covered in deps_*
> +cmd-prereqs = $(call escsq,$(filter-out $(deps_$@), $(real-prereqs)))

Sashiko has a comment that this produces different results based on a
clean versus incremental build:

https://sashiko.dev/#/patchset/59032

I can reproduce this with:

$ make -skj"$(nproc)" ARCH=x86_64 mrproper defconfig lib/oid_registry.o

$ grep -n oid_registry_data lib/.oid_registry.o.cmd
3:make_prereqs_lib/oid_registry.o := lib/oid_registry.c lib/oid_registry_data.c
1111: lib/oid_registry_data.c \

$ touch lib/oid_registry.c

$ make -skj"$(nproc)" ARCH=x86_64 lib/oid_registry.o

$ grep -n oid_registry_data lib/.oid_registry.o.cmd
1111: lib/oid_registry_data.c \

As this is just metadata for external tools (i.e., it does not get
consumed by Kbuild again), we could just require them to filter
duplicates after the fact?

--
Cheers,
Nathan