Re: [PATCH 11/23] kbuild: implement and use depcheck to check dependency timestamps

From: Lorenzo Stoakes (ARM)

Date: Mon Sep 14 2026 - 04:37:56 EST


On Wed, Sep 09, 2026 at 08:26:42AM -0700, Linus Torvalds wrote:
> On Tue, 8 Sept 2026 at 13:57, Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx> wrote:
> >
> > Each object's .cmd file lists its header dependencies, which often
> > consists of over a thousand dependencies.
> >
> > When little has changed in the tree, this is what make spends most of its
> > time doing, spending over a second, single-threaded when parsing larger
> > directory trees.
>
> Side note: from some kernel build profiles I did long ago, I have this
> memory of it being made much worse by the fact that we use
>
> "$(wildcard xyzzy)"
>
> for all our config header files in those .cmd.o files. That then
> causes extra work for 'make' for all of this.
>
> And we do that 'wildcard' thing not because we want to actually match
> a pattern, but because that was the only way to have 'make' not
> complain about missing config headers.
>
> I'm not even sure the original reason for it is relevant any more -
> this is all a very dim memory from years and years ago when I actually
> tried to look at profiles of 'make' itself (normally when I do kernel
> build profiles I only look at the what the kernel part of the build
> is, not user mode).
>
> I just tried removing the 'wildcard' generation from
> scripts/basic/fixdep.c and the kernel build didn't care about it at
> all. The whole 'wildcard' trick goes all the way back to the original
> commit that added that whole 'fixdep.c' phase.
>
> Maybe the whole thing is entirely stale now and should be removed. I
> probably just didn't trigger the situation where those extra
> 'wildcard' things matter. That whole thing is from a quarter century
> ago, and nobody has dared look at that code since..

Yeah, unfortunately it seems that it's still required - without it make
seems to treat a missing target with an empty rule as if it were updated,
so without the wildcard every object that references an unset option
results in a rebuild.

>
> Or maybe 'make' is better at those wildcards these days - or other
> things have shifted.
>
> From those dim memories, make spent a lot of time doing filesystem
> lookups (directory reading and 'stat()' calls - the wildcard thing
> triggered more getdents calls), but even more time just in string
> handling.

The depcheck commit ("kbuild: implement and use depcheck to check
dependency timestamps") actually fixes the overhead issue :) it stops make
seeing those dependency lists at all for stuff that's up to date so the
parse cost just goes away.

After that commit make only sees actually stale stuff.

The obvious question here is 'does depcheck make the wildcard stuff
unnecessary then?' - and sadly no, because there's still places where make
includes .cmd files directly without using depcheck.

But TL;DR is the overhead is gone.

>
> Linus

--
Cheers, Lorenzo