Re: [RFC 1/2] rust: Introduce atomic API helpers

From: Mark Rutland
Date: Thu Jun 13 2024 - 06:36:40 EST


On Thu, Jun 13, 2024 at 11:17:47AM +0200, Peter Zijlstra wrote:
> On Thu, Jun 13, 2024 at 07:38:51AM +0200, Greg Kroah-Hartman wrote:
> > On Wed, Jun 12, 2024 at 03:30:24PM -0700, Boqun Feng wrote:
> > > +// Generated by scripts/atomic/gen-rust-atomic-helpers.sh
> > > +// DO NOT MODIFY THIS FILE DIRECTLY
> >
> > Why not just build this at build time and not check the file into the
> > tree if it is always automatically generated? That way it never gets
> > out of sync. We do this for other types of auto-generated files in the
> > kernel today already.
>
> Part of the problem is, is that a *TON* of files depend on the atomic.h
> headers. If we'd generate it on every build, you'd basically get to
> rebuild the whole kernel every single time.
>
> Also, these files don't change too often. And if you look, there's a
> hash in those files which is used to check if things somehow got stale.

That and:

1) The generation is currently slow (multiple seconds), which gets
people angry if they have to wait for it for a clean build. Improving
that would require changing the way we generate the headers (e.g.
rewrite that in something else to avoid the subshell fork problem).

Last I looked there wasn't an obvious better way to do this, because
nice options ended up pulling in more build-time dependencies.

2) Linus wanted git grep to work, which meant checking in the generated
files:

https://lore.kernel.org/all/CA+55aFxjU0op8QLLu0n-RjHBs7gQsLvD8jcyedgw6jeZFN7B+Q@xxxxxxxxxxxxxx/

Mark.