public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Miguel Ojeda <ojeda@kernel.org>
To: miguel.ojeda.sandonis@gmail.com
Cc: a.hindborg@kernel.org, aliceryhl@google.com,
	bjorn3_gh@protonmail.com, boqun@kernel.org, dakr@kernel.org,
	gary@garyguo.net, jhubbard@nvidia.com,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	lossin@kernel.org, ojeda@kernel.org, rafael@kernel.org,
	rust-for-linux@vger.kernel.org, tmgross@umich.edu,
	viresh.kumar@linaro.org
Subject: [RFC PATCH] rust: kbuild: support global per-version flags
Date: Sat,  7 Mar 2026 18:09:29 +0100	[thread overview]
Message-ID: <20260307170929.153892-1-ojeda@kernel.org> (raw)
In-Reply-To: <CANiq72mWdFU11GcCZRchzhy0Gi1QZShvZtyRkHV2O+WA2uTdVQ@mail.gmail.com>

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`.

An alternative is moving all those three down, but that would mean
separating them from the other `KBUILD_*` variables.

Link: https://lore.kernel.org/rust-for-linux/CANiq72mWdFU11GcCZRchzhy0Gi1QZShvZtyRkHV2O+WA2uTdVQ@mail.gmail.com/ [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
> Doing it globally for certain versions (i.e. `rust_common_flags`, not
> just `KBUILD_RUSTFLAGS`) requires a bit of reorganization,

If we wanted to go for a per-version global one, we we would need
something like this patch -- sending it here so that it gets archived
in case we need it.

 Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Makefile b/Makefile
index 2446085983f7..a49cddb0599b 100644
--- a/Makefile
+++ b/Makefile
@@ -833,6 +833,14 @@ endif # CONFIG_TRACEPOINTS

 export WARN_ON_UNUSED_TRACEPOINTS

+# Per-version Rust flags. These are like `rust_common_flags`, but may
+# depend on the Rust compiler version (e.g. using `rustc-min-version`).
+rust_common_flags_per_version :=
+
+rust_common_flags += $(rust_common_flags_per_version)
+KBUILD_HOSTRUSTFLAGS += $(rust_common_flags_per_version)
+KBUILD_RUSTFLAGS += $(rust_common_flags_per_version)
+
 include $(srctree)/arch/$(SRCARCH)/Makefile

 ifdef need-config

base-commit: 11439c4635edd669ae435eec308f4ab8a0804808
--
2.53.0

  reply	other threads:[~2026-03-07 17:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04 19:53 [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest John Hubbard
2026-03-04 20:06 ` Gary Guo
2026-03-04 20:07   ` John Hubbard
2026-03-04 20:28     ` Gary Guo
2026-03-04 20:32       ` John Hubbard
2026-03-04 20:39       ` Gary Guo
2026-03-04 21:13         ` John Hubbard
2026-03-05 12:31           ` Gary Guo
2026-03-06 12:36             ` Miguel Ojeda
2026-03-07 17:09               ` Miguel Ojeda [this message]
2026-03-15 21:21                 ` [RFC PATCH] rust: kbuild: support global per-version flags Miguel Ojeda
2026-03-15 21:22                   ` Miguel Ojeda
2026-03-16  0:04                   ` Mark Brown
2026-03-16  4:49                     ` Miguel Ojeda
2026-03-16 12:50                       ` Mark Brown
2026-03-16 12:31                         ` Danilo Krummrich
2026-03-16 13:42                         ` Miguel Ojeda
2026-03-04 20:30 ` [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest Gary Guo
2026-03-04 20:34   ` John Hubbard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260307170929.153892-1-ojeda@kernel.org \
    --to=ojeda@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox