]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: kbuild: support global per-version flags
authorMiguel Ojeda <ojeda@kernel.org>
Sun, 5 Apr 2026 23:53:08 +0000 (01:53 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 7 Apr 2026 08:00:25 +0000 (10:00 +0200)
commitb2aa1535ecdd10514daabe5e8eb7cea49aa5b5ec
tree6d55045e85ed6f401996c89a94105c2438ed574c
parent9e5946de3a3876113098dc272873802baff022cc
rust: kbuild: support global per-version flags

Sometimes it is useful to gate global Rust flags per compiler version.
For instance, we may want to disable a lint that has false positives in
a single version [1].

We already had helpers like `rustc-min-version` for that, which we use
elsewhere, but we cannot currently use them for `rust_common_flags`,
which contains the global flags for all Rust code (kernel and host),
because `rustc-min-version` depends on `CONFIG_RUSTC_VERSION`, which
does not exist when `rust_common_flags` is defined.

Thus, to support that, introduce `rust_common_flags_per_version`,
defined after the `include/config/auto.conf` inclusion (where
`CONFIG_RUSTC_VERSION` becomes available), and append it to
`rust_common_flags`, `KBUILD_HOSTRUSTFLAGS` and `KBUILD_RUSTFLAGS`.

In addition, move the expansion of `HOSTRUSTFLAGS` to the same place,
so that users can also override per-version flags [2].

Link: https://lore.kernel.org/rust-for-linux/CANiq72mWdFU11GcCZRchzhy0Gi1QZShvZtyRkHV2O+WA2uTdVQ@mail.gmail.com/
Link: https://lore.kernel.org/rust-for-linux/CANiq72mTaA2tjhkLKf0-2hrrrt9rxWPgy6SfNSbponbGOegQvA@mail.gmail.com/
Link: https://patch.msgid.link/20260307170929.153892-1-ojeda@kernel.org
Link: https://patch.msgid.link/20260405235309.418950-33-ojeda@kernel.org
Reviewed-by: Tamir Duberstein <tamird@kernel.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Makefile