Re: [PATCH 32/33] rust: kbuild: support global per-version flags

Gary Guo
2026-04-06T00:09:13Z

On Mon Apr 6, 2026 at 12:15 AM BST, Miguel Ojeda wrote:
> On Thu, Apr 2, 2026 at 12:28 AM Gary Guo <gary@garyguo.net> wrote:
>>
>> I think I would prefer moving these down.
>>
>> The current approach append the flags to all variables, which will cause the
>> following equivalence to stop holding after the flag update.
>>
>> KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
>> -Zallow-features= $(HOSTRUSTFLAGS)
>>
>> (Per version flags doesn't go before -O anymore, it comes after HOSTRUSTFLAGS).
>
> [ For context for others, Sashiko reported the same and we also talked
> about it in a Rust for Linux call. ]
>
> I have been thinking about this, and about potential other ways to
> achieve the same thing. I think the best at the moment is to move just
> the `$(HOSTRUSTFLAGS)` below, but not the rest.
>
> The reason is that it is closer to what we do with other user (kernel)
> flags (e.g. arch flags come after the general ones). But I am
> wondering if we should/could set all the user variables later in the
> `Makefile` in general `HOST*FLAGS` later in the `Makefile`.
>
> In fact, there is already a limitation with the host flags: `-Werror`,
> i.e. that one gets appended later, and so users cannot override it.

I cared a bit more about the code clarity (where appending to all variables
feel like a hack, while moving the code block is natural).

Best,
Gary

> [...]
>
> Anyway, for now I moved the expansion of `HOSTRUSTFLAGS` in v2. If
> Kbuild (Nathan, Nicolas) think it is a good idea to do one of the
> bigger changes (e.g. for more `HOST*` flags, appending it even later),
> then we can do it afterwards.
>
> Cheers,
> Miguel