Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH] kbuild: rust: support stabilized flag `-Cprofile-sample-use` for Rust >= 1.100
@ 2026-11-06  7:35 Miguel Ojeda
  2026-11-06 10:45 ` Alice Ryhl
  2026-11-07 13:21 ` Nicolas Schier
  0 siblings, 2 replies; 6+ messages in thread
From: Miguel Ojeda @ 2026-11-06  7:35 UTC (permalink / raw)
  To: Rong Xu, Han Shen, Nathan Chancellor, Nicolas Schier,
	Miguel Ojeda
  Cc: linux-kbuild, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, rust-for-linux, stable

Starting with Rust 1.100.0 (expected 2026-11-12), the
`-Zprofile-sample-use` flag has been stabilized as
`-Cprofile-sample-use` and the former is not available anymore [1].

Without this change, when building with `CLANG_AUTOFDO_PROFILE` set, one
gets in the latest betas and nightlies:

    error: unknown unstable option: `profile-sample-use`

Thus pass the right name.

Cc: stable@vger.kernel.org # Needed in 7.3.y.
Link: https://github.com/rust-lang/rust/pull/155942 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
I can take it via `rust-fixes` to get it in for the release, but please
let me know if you prefer to do something else. Thanks!

 scripts/Makefile.autofdo | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo
index 57a3aba6ffc2..32c18df237f1 100644
--- a/scripts/Makefile.autofdo
+++ b/scripts/Makefile.autofdo
@@ -13,7 +13,7 @@ endif
 ifdef CLANG_AUTOFDO_PROFILE
   CFLAGS_AUTOFDO_CLANG += -fprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -ffunction-sections
   CFLAGS_AUTOFDO_CLANG += -fsplit-machine-functions
-  RUSTFLAGS_AUTOFDO_CLANG += -Zprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -Zfunction-sections=y
+  RUSTFLAGS_AUTOFDO_CLANG += $(if $(call rustc-min-version,110000),-Cprofile-sample-use,-Zprofile-sample-use)=$(CLANG_AUTOFDO_PROFILE) -Zfunction-sections=y
   RUSTFLAGS_AUTOFDO_CLANG += -Cllvm-args=-split-machine-functions
 endif


base-commit: 57d916a3eb765ee0577d269bb2ac1bdf3a7a7f40
--
2.56.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: rust: support stabilized flag `-Cprofile-sample-use` for Rust >= 1.100
  2026-11-06  7:35 [PATCH] kbuild: rust: support stabilized flag `-Cprofile-sample-use` for Rust >= 1.100 Miguel Ojeda
@ 2026-11-06 10:45 ` Alice Ryhl
  2026-11-06 11:04   ` Miguel Ojeda
  2026-11-07 13:21 ` Nicolas Schier
  1 sibling, 1 reply; 6+ messages in thread
From: Alice Ryhl @ 2026-11-06 10:45 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Alice Ryhl, Rong Xu, Han Shen, Nathan Chancellor, Nicolas Schier,
	linux-kbuild, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich,
	Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan, rust-for-linux, stable

On Fri, Nov 06, 2026 at 08:35:28AM +0100, Miguel Ojeda wrote:
> Starting with Rust 1.100.0 (expected 2026-11-12), the
> `-Zprofile-sample-use` flag has been stabilized as
> `-Cprofile-sample-use` and the former is not available anymore [1].
> 
> Without this change, when building with `CLANG_AUTOFDO_PROFILE` set, one
> gets in the latest betas and nightlies:
> 
>     error: unknown unstable option: `profile-sample-use`
> 
> Thus pass the right name.
> 
> Cc: stable@vger.kernel.org # Needed in 7.3.y.
> Link: https://github.com/rust-lang/rust/pull/155942 [1]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> I can take it via `rust-fixes` to get it in for the release, but please
> let me know if you prefer to do something else. Thanks!
> 
>  scripts/Makefile.autofdo | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo
> index 57a3aba6ffc2..32c18df237f1 100644
> --- a/scripts/Makefile.autofdo
> +++ b/scripts/Makefile.autofdo
> @@ -13,7 +13,7 @@ endif
>  ifdef CLANG_AUTOFDO_PROFILE
>    CFLAGS_AUTOFDO_CLANG += -fprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -ffunction-sections
>    CFLAGS_AUTOFDO_CLANG += -fsplit-machine-functions
> -  RUSTFLAGS_AUTOFDO_CLANG += -Zprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -Zfunction-sections=y
> +  RUSTFLAGS_AUTOFDO_CLANG += $(if $(call rustc-min-version,110000),-Cprofile-sample-use,-Zprofile-sample-use)=$(CLANG_AUTOFDO_PROFILE) -Zfunction-sections=y
>    RUSTFLAGS_AUTOFDO_CLANG += -Cllvm-args=-split-machine-functions
>  endif

Could we check for `-Cprofile-sample-use` directly using `rustc-option`
instead of checking the rustc version (e.g. testing
`-Cprofile-sample-use=/dev/null` or using `$(call rustc-option,...)`)?
That way toolchains that cherry-pick the stabilization (or older 1.100
nightlies from before the flag was stabilized) are also handled
properly.

Either way:

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

Alice

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: rust: support stabilized flag `-Cprofile-sample-use` for Rust >= 1.100
  2026-11-06 10:45 ` Alice Ryhl
@ 2026-11-06 11:04   ` Miguel Ojeda
  2026-11-06 12:21     ` Gary Guo
  2026-11-06 20:53     ` Nathan Chancellor
  0 siblings, 2 replies; 6+ messages in thread
From: Miguel Ojeda @ 2026-11-06 11:04 UTC (permalink / raw)
  To: Alice Ryhl
  Cc: Miguel Ojeda, Rong Xu, Han Shen, Nathan Chancellor,
	Nicolas Schier, linux-kbuild, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, rust-for-linux, stable

On Fri, Nov 6, 2026 at 11:45 AM Alice Ryhl <aliceryhl@google.com> wrote:
>
> Could we check for `-Cprofile-sample-use` directly using `rustc-option`
> instead of checking the rustc version (e.g. testing
> `-Cprofile-sample-use=/dev/null` or using `$(call rustc-option,...)`)?
> That way toolchains that cherry-pick the stabilization (or older 1.100
> nightlies from before the flag was stabilized) are also handled
> properly.

It is definitely an option, as usual, but this file uses the version
elsewhere, and we have preferred so far the version one where
possible, because it is way simpler and spawns fewer processes
(especially so in newer Make), which Kbuild has usually appreciated.

Regarding old nightlies, those are not supported by upstream nor by
us, and we intentionally never attempted to make flags work for
particular binaries out there. I think the fact that we support even
nightlies from Rust is already quite a success :)

Same for custom `rustc` forks, if you mean "cherry-picking the
stabilization". We can't really test those, and if someone really
needs that properly working and can make a case, then we would need to
take a look at all the version tests we do (and not just for Rust).
Perhaps some folks only customize 1 or 2 flags and thus only care
about those working, but we wouldn't know which ones.

Thanks for the review!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: rust: support stabilized flag `-Cprofile-sample-use` for Rust >= 1.100
  2026-11-06 11:04   ` Miguel Ojeda
@ 2026-11-06 12:21     ` Gary Guo
  2026-11-06 20:53     ` Nathan Chancellor
  1 sibling, 0 replies; 6+ messages in thread
From: Gary Guo @ 2026-11-06 12:21 UTC (permalink / raw)
  To: Miguel Ojeda, Alice Ryhl
  Cc: Miguel Ojeda, Rong Xu, Han Shen, Nathan Chancellor,
	Nicolas Schier, linux-kbuild, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, rust-for-linux, stable

On Fri Nov 6, 2026 at 7:04 PM CST, Miguel Ojeda wrote:
> On Fri, Nov 6, 2026 at 11:45 AM Alice Ryhl <aliceryhl@google.com> wrote:
>>
>> Could we check for `-Cprofile-sample-use` directly using `rustc-option`
>> instead of checking the rustc version (e.g. testing
>> `-Cprofile-sample-use=/dev/null` or using `$(call rustc-option,...)`)?
>> That way toolchains that cherry-pick the stabilization (or older 1.100
>> nightlies from before the flag was stabilized) are also handled
>> properly.
>
> It is definitely an option, as usual, but this file uses the version
> elsewhere, and we have preferred so far the version one where
> possible, because it is way simpler and spawns fewer processes
> (especially so in newer Make), which Kbuild has usually appreciated.
>
> Regarding old nightlies, those are not supported by upstream nor by
> us, and we intentionally never attempted to make flags work for
> particular binaries out there. I think the fact that we support even
> nightlies from Rust is already quite a success :)
>
> Same for custom `rustc` forks, if you mean "cherry-picking the
> stabilization". We can't really test those, and if someone really
> needs that properly working and can make a case, then we would need to
> take a look at all the version tests we do (and not just for Rust).
> Perhaps some folks only customize 1 or 2 flags and thus only care
> about those working, but we wouldn't know which ones.

I suppose another option is to check version and fallback to probe when version
is not new enough. This way it handles both the case described here (and also
have the benefit of being self-descriptive that can remind people of removal
when MSRV is ultimately bumped.

The "cherry-pick stabilization" can manifest in other forms in distro Rust
compiler too, so the issue is not entirely novel. IIRC Fedora enables shadow
stack in Rustc with patches despite it being unstable upstream.

Best,
Gary


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: rust: support stabilized flag `-Cprofile-sample-use` for Rust >= 1.100
  2026-11-06 11:04   ` Miguel Ojeda
  2026-11-06 12:21     ` Gary Guo
@ 2026-11-06 20:53     ` Nathan Chancellor
  1 sibling, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2026-11-06 20:53 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Alice Ryhl, Miguel Ojeda, Rong Xu, Han Shen, Nicolas Schier,
	linux-kbuild, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich,
	Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan, rust-for-linux, stable

On Fri, Nov 06, 2026 at 12:04:08PM +0100, Miguel Ojeda wrote:
> On Fri, Nov 6, 2026 at 11:45 AM Alice Ryhl <aliceryhl@google.com> wrote:
> >
> > Could we check for `-Cprofile-sample-use` directly using `rustc-option`
> > instead of checking the rustc version (e.g. testing
> > `-Cprofile-sample-use=/dev/null` or using `$(call rustc-option,...)`)?
> > That way toolchains that cherry-pick the stabilization (or older 1.100
> > nightlies from before the flag was stabilized) are also handled
> > properly.
> 
> It is definitely an option, as usual, but this file uses the version
> elsewhere, and we have preferred so far the version one where
> possible, because it is way simpler and spawns fewer processes
> (especially so in newer Make), which Kbuild has usually appreciated.

Yeah, there is always a fine line between deciding whether or not to do
a dynamic versus version check. Obviously the cost of querying the
compiler is not that high in the grand scheme of the total build time,
so I don't think we should be scared of doing dynamic tests, However, I
do think doing plain version checks is simpler to support, especially
since it makes cleaning up these changes as the minimum version is
bumped.

> Regarding old nightlies, those are not supported by upstream nor by
> us, and we intentionally never attempted to make flags work for
> particular binaries out there. I think the fact that we support even
> nightlies from Rust is already quite a success :)

Yeah, for clang, we have done our best to support prerelease versions
but once the toolchain stabilizes, we don't care about those old
versions. I generally try to do version checks against the stable
version (i.e., x.1.0, instead of x.0.0) to avoid breaking compiler
bisects but I guess Rust doesn't have such a scheme? That is the only
area where I feel friction with version checks.

> Same for custom `rustc` forks, if you mean "cherry-picking the
> stabilization". We can't really test those, and if someone really
> needs that properly working and can make a case, then we would need to
> take a look at all the version tests we do (and not just for Rust).
> Perhaps some folks only customize 1 or 2 flags and thus only care
> about those working, but we wouldn't know which ones.

To be honest, I would avoid supporting franken-toolchains if you have
the option not to. Presumably if a vendor has customized or vendored
their toolchain, they are likely working with a downstream kernel as
well, in which case they can just adjust the check in their tree as
needed. You could obviously deal with exceptions on a case-by-case basis
but reasoning about all the different options and their first supported
version is hard enough as it is.

-- 
Cheers,
Nathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: rust: support stabilized flag `-Cprofile-sample-use` for Rust >= 1.100
  2026-11-06  7:35 [PATCH] kbuild: rust: support stabilized flag `-Cprofile-sample-use` for Rust >= 1.100 Miguel Ojeda
  2026-11-06 10:45 ` Alice Ryhl
@ 2026-11-07 13:21 ` Nicolas Schier
  1 sibling, 0 replies; 6+ messages in thread
From: Nicolas Schier @ 2026-11-07 13:21 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Rong Xu, Han Shen, Nathan Chancellor, linux-kbuild, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan,
	rust-for-linux, stable

On Fri, Nov 06, 2026 at 08:35:28AM +0100, Miguel Ojeda wrote:
> Starting with Rust 1.100.0 (expected 2026-11-12), the
> `-Zprofile-sample-use` flag has been stabilized as
> `-Cprofile-sample-use` and the former is not available anymore [1].
> 
> Without this change, when building with `CLANG_AUTOFDO_PROFILE` set, one
> gets in the latest betas and nightlies:
> 
>     error: unknown unstable option: `profile-sample-use`
> 
> Thus pass the right name.
> 
> Cc: stable@vger.kernel.org # Needed in 7.3.y.
> Link: https://github.com/rust-lang/rust/pull/155942 [1]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> I can take it via `rust-fixes` to get it in for the release, but please
> let me know if you prefer to do something else. Thanks!

'rust-fixes' sounds good, thanks!

Acked-by: Nicolas Schier <nsc@kernel.org>


-- 
Nicolas

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-07 13:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06  7:35 [PATCH] kbuild: rust: support stabilized flag `-Cprofile-sample-use` for Rust >= 1.100 Miguel Ojeda
2026-11-06 10:45 ` Alice Ryhl
2026-11-06 11:04   ` Miguel Ojeda
2026-11-06 12:21     ` Gary Guo
2026-11-06 20:53     ` Nathan Chancellor
2026-11-07 13:21 ` Nicolas Schier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox