* [PATCH] kbuild: rust: add AutoFDO support @ 2026-03-19 11:22 Alice Ryhl 2026-03-19 11:31 ` Gary Guo 0 siblings, 1 reply; 13+ messages in thread From: Alice Ryhl @ 2026-03-19 11:22 UTC (permalink / raw) To: Rong Xu, Han Shen, Nathan Chancellor, Nicolas Schier, Miguel Ojeda Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux, Alice Ryhl This patch enables AutoFDO build support for Rust code within the Linux kernel. This allows Rust code to be profiled and optimized based on the profile. This was verified by inspecting the object files and confirming that they look correct. It was also verified in conjuction with my helpers inlining series, and it also appears to have worked correctly when combined with that series once one missing thing [1] was fixed in the helpers inlining series. Link: https://lore.kernel.org/all/aasPsbMEsX6iGUl8@google.com/ [1] Signed-off-by: Alice Ryhl <aliceryhl@google.com> --- scripts/Makefile.autofdo | 6 +++++- scripts/Makefile.lib | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo index 1caf2457e585..3f08acab4549 100644 --- a/scripts/Makefile.autofdo +++ b/scripts/Makefile.autofdo @@ -3,14 +3,18 @@ # Enable available and selected Clang AutoFDO features. CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true +RUSTFLAGS_AUTOFDO_CLANG := -Zdebug-info-for-profiling -Cllvm-args=-enable-fs-discriminator=true -Cllvm-args=-improved-fs-discriminator=true ifndef CONFIG_DEBUG_INFO CFLAGS_AUTOFDO_CLANG += -gmlt + RUSTFLAGS_AUTOFDO_CLANG += -Cdebuginfo=line-tables-only 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 += -Cllvm-args=-split-machine-functions endif ifdef CONFIG_LTO_CLANG_THIN @@ -21,4 +25,4 @@ ifdef CONFIG_LTO_CLANG_THIN KBUILD_LDFLAGS += -plugin-opt=-split-machine-functions endif -export CFLAGS_AUTOFDO_CLANG +export CFLAGS_AUTOFDO_CLANG RUSTFLAGS_AUTOFDO_CLANG diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0718e39cedda..eaddf6637669 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -123,6 +123,9 @@ ifeq ($(CONFIG_AUTOFDO_CLANG),y) _c_flags += $(if $(patsubst n%,, \ $(AUTOFDO_PROFILE_$(target-stem).o)$(AUTOFDO_PROFILE)$(is-kernel-object)), \ $(CFLAGS_AUTOFDO_CLANG)) +_rust_flags += $(if $(patsubst n%,, \ + $(AUTOFDO_PROFILE_$(target-stem).o)$(AUTOFDO_PROFILE)$(is-kernel-object)), \ + $(RUSTFLAGS_AUTOFDO_CLANG)) endif # --- base-commit: 1f318b96cc84d7c2ab792fcc0bfd42a7ca890681 change-id: 20260309-autofdo-8d01e7977fed Best regards, -- Alice Ryhl <aliceryhl@google.com> ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-19 11:22 [PATCH] kbuild: rust: add AutoFDO support Alice Ryhl @ 2026-03-19 11:31 ` Gary Guo 2026-03-19 11:44 ` Alice Ryhl 0 siblings, 1 reply; 13+ messages in thread From: Gary Guo @ 2026-03-19 11:31 UTC (permalink / raw) To: Alice Ryhl, Rong Xu, Han Shen, Nathan Chancellor, Nicolas Schier, Miguel Ojeda Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux On Thu Mar 19, 2026 at 11:22 AM GMT, Alice Ryhl wrote: > This patch enables AutoFDO build support for Rust code within the Linux > kernel. This allows Rust code to be profiled and optimized based on the > profile. > > This was verified by inspecting the object files and confirming that > they look correct. It was also verified in conjuction with my helpers > inlining series, and it also appears to have worked correctly when > combined with that series once one missing thing [1] was fixed in the > helpers inlining series. > > Link: https://lore.kernel.org/all/aasPsbMEsX6iGUl8@google.com/ [1] > Signed-off-by: Alice Ryhl <aliceryhl@google.com> > --- > scripts/Makefile.autofdo | 6 +++++- > scripts/Makefile.lib | 3 +++ > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo > index 1caf2457e585..3f08acab4549 100644 > --- a/scripts/Makefile.autofdo > +++ b/scripts/Makefile.autofdo > @@ -3,14 +3,18 @@ > # Enable available and selected Clang AutoFDO features. > > CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true > +RUSTFLAGS_AUTOFDO_CLANG := -Zdebug-info-for-profiling -Cllvm-args=-enable-fs-discriminator=true -Cllvm-args=-improved-fs-discriminator=true I get that it's currently named as AUTOFDO_CLANG, but this really ought to be AUTOFDO_LLVM... The flag translations look correct to me. Best, Gary > > ifndef CONFIG_DEBUG_INFO > CFLAGS_AUTOFDO_CLANG += -gmlt > + RUSTFLAGS_AUTOFDO_CLANG += -Cdebuginfo=line-tables-only > 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 += -Cllvm-args=-split-machine-functions > endif > > ifdef CONFIG_LTO_CLANG_THIN > @@ -21,4 +25,4 @@ ifdef CONFIG_LTO_CLANG_THIN > KBUILD_LDFLAGS += -plugin-opt=-split-machine-functions > endif > > -export CFLAGS_AUTOFDO_CLANG > +export CFLAGS_AUTOFDO_CLANG RUSTFLAGS_AUTOFDO_CLANG > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib > index 0718e39cedda..eaddf6637669 100644 > --- a/scripts/Makefile.lib > +++ b/scripts/Makefile.lib > @@ -123,6 +123,9 @@ ifeq ($(CONFIG_AUTOFDO_CLANG),y) > _c_flags += $(if $(patsubst n%,, \ > $(AUTOFDO_PROFILE_$(target-stem).o)$(AUTOFDO_PROFILE)$(is-kernel-object)), \ > $(CFLAGS_AUTOFDO_CLANG)) > +_rust_flags += $(if $(patsubst n%,, \ > + $(AUTOFDO_PROFILE_$(target-stem).o)$(AUTOFDO_PROFILE)$(is-kernel-object)), \ > + $(RUSTFLAGS_AUTOFDO_CLANG)) > endif > > # > > --- > base-commit: 1f318b96cc84d7c2ab792fcc0bfd42a7ca890681 > change-id: 20260309-autofdo-8d01e7977fed > > Best regards, ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-19 11:31 ` Gary Guo @ 2026-03-19 11:44 ` Alice Ryhl 2026-03-19 11:47 ` Gary Guo 0 siblings, 1 reply; 13+ messages in thread From: Alice Ryhl @ 2026-03-19 11:44 UTC (permalink / raw) To: Gary Guo Cc: Rong Xu, Han Shen, Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux On Thu, Mar 19, 2026 at 12:31 PM Gary Guo <gary@garyguo.net> wrote: > > On Thu Mar 19, 2026 at 11:22 AM GMT, Alice Ryhl wrote: > > This patch enables AutoFDO build support for Rust code within the Linux > > kernel. This allows Rust code to be profiled and optimized based on the > > profile. > > > > This was verified by inspecting the object files and confirming that > > they look correct. It was also verified in conjuction with my helpers > > inlining series, and it also appears to have worked correctly when > > combined with that series once one missing thing [1] was fixed in the > > helpers inlining series. > > > > Link: https://lore.kernel.org/all/aasPsbMEsX6iGUl8@google.com/ [1] > > Signed-off-by: Alice Ryhl <aliceryhl@google.com> > > --- > > scripts/Makefile.autofdo | 6 +++++- > > scripts/Makefile.lib | 3 +++ > > 2 files changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo > > index 1caf2457e585..3f08acab4549 100644 > > --- a/scripts/Makefile.autofdo > > +++ b/scripts/Makefile.autofdo > > @@ -3,14 +3,18 @@ > > # Enable available and selected Clang AutoFDO features. > > > > CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true > > +RUSTFLAGS_AUTOFDO_CLANG := -Zdebug-info-for-profiling -Cllvm-args=-enable-fs-discriminator=true -Cllvm-args=-improved-fs-discriminator=true > > I get that it's currently named as AUTOFDO_CLANG, but this really ought to be > AUTOFDO_LLVM... > > The flag translations look correct to me. Do you think it's worth having Rust not match the CFLAGS here? Alice ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-19 11:44 ` Alice Ryhl @ 2026-03-19 11:47 ` Gary Guo 2026-03-19 16:33 ` Alice Ryhl 0 siblings, 1 reply; 13+ messages in thread From: Gary Guo @ 2026-03-19 11:47 UTC (permalink / raw) To: Alice Ryhl, Gary Guo Cc: Rong Xu, Han Shen, Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux On Thu Mar 19, 2026 at 11:44 AM GMT, Alice Ryhl wrote: > On Thu, Mar 19, 2026 at 12:31 PM Gary Guo <gary@garyguo.net> wrote: >> >> On Thu Mar 19, 2026 at 11:22 AM GMT, Alice Ryhl wrote: >> > This patch enables AutoFDO build support for Rust code within the Linux >> > kernel. This allows Rust code to be profiled and optimized based on the >> > profile. >> > >> > This was verified by inspecting the object files and confirming that >> > they look correct. It was also verified in conjuction with my helpers >> > inlining series, and it also appears to have worked correctly when >> > combined with that series once one missing thing [1] was fixed in the >> > helpers inlining series. >> > >> > Link: https://lore.kernel.org/all/aasPsbMEsX6iGUl8@google.com/ [1] >> > Signed-off-by: Alice Ryhl <aliceryhl@google.com> >> > --- >> > scripts/Makefile.autofdo | 6 +++++- >> > scripts/Makefile.lib | 3 +++ >> > 2 files changed, 8 insertions(+), 1 deletion(-) >> > >> > diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo >> > index 1caf2457e585..3f08acab4549 100644 >> > --- a/scripts/Makefile.autofdo >> > +++ b/scripts/Makefile.autofdo >> > @@ -3,14 +3,18 @@ >> > # Enable available and selected Clang AutoFDO features. >> > >> > CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true >> > +RUSTFLAGS_AUTOFDO_CLANG := -Zdebug-info-for-profiling -Cllvm-args=-enable-fs-discriminator=true -Cllvm-args=-improved-fs-discriminator=true >> >> I get that it's currently named as AUTOFDO_CLANG, but this really ought to be >> AUTOFDO_LLVM... >> >> The flag translations look correct to me. > > Do you think it's worth having Rust not match the CFLAGS here? > I think the C flags should probably be renamed AUTOFDO_LLVM too. After call, all the perf tools involved here are called llvm-foobar as well. Best, Gary ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-19 11:47 ` Gary Guo @ 2026-03-19 16:33 ` Alice Ryhl 2026-03-19 19:09 ` Gary Guo 0 siblings, 1 reply; 13+ messages in thread From: Alice Ryhl @ 2026-03-19 16:33 UTC (permalink / raw) To: Gary Guo Cc: Rong Xu, Han Shen, Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux On Thu, Mar 19, 2026 at 12:47 PM Gary Guo <gary@garyguo.net> wrote: > > On Thu Mar 19, 2026 at 11:44 AM GMT, Alice Ryhl wrote: > > On Thu, Mar 19, 2026 at 12:31 PM Gary Guo <gary@garyguo.net> wrote: > >> > >> On Thu Mar 19, 2026 at 11:22 AM GMT, Alice Ryhl wrote: > >> > This patch enables AutoFDO build support for Rust code within the Linux > >> > kernel. This allows Rust code to be profiled and optimized based on the > >> > profile. > >> > > >> > This was verified by inspecting the object files and confirming that > >> > they look correct. It was also verified in conjuction with my helpers > >> > inlining series, and it also appears to have worked correctly when > >> > combined with that series once one missing thing [1] was fixed in the > >> > helpers inlining series. > >> > > >> > Link: https://lore.kernel.org/all/aasPsbMEsX6iGUl8@google.com/ [1] > >> > Signed-off-by: Alice Ryhl <aliceryhl@google.com> > >> > --- > >> > scripts/Makefile.autofdo | 6 +++++- > >> > scripts/Makefile.lib | 3 +++ > >> > 2 files changed, 8 insertions(+), 1 deletion(-) > >> > > >> > diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo > >> > index 1caf2457e585..3f08acab4549 100644 > >> > --- a/scripts/Makefile.autofdo > >> > +++ b/scripts/Makefile.autofdo > >> > @@ -3,14 +3,18 @@ > >> > # Enable available and selected Clang AutoFDO features. > >> > > >> > CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true > >> > +RUSTFLAGS_AUTOFDO_CLANG := -Zdebug-info-for-profiling -Cllvm-args=-enable-fs-discriminator=true -Cllvm-args=-improved-fs-discriminator=true > >> > >> I get that it's currently named as AUTOFDO_CLANG, but this really ought to be > >> AUTOFDO_LLVM... > >> > >> The flag translations look correct to me. > > > > Do you think it's worth having Rust not match the CFLAGS here? > > > > I think the C flags should probably be renamed AUTOFDO_LLVM too. After call, all > the perf tools involved here are called llvm-foobar as well. But isn't it just called this because the config option is CONFIG_AUTOFDO_CLANG? So it's the CFLAGS or RUSTFLAGS related to that particular config option. It may make sense to rename CONFIG_AUTOFDO_CLANG to CONFIG_AUTOFDO, but that's out-of-scope for this change, in my opinion. Alice ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-19 16:33 ` Alice Ryhl @ 2026-03-19 19:09 ` Gary Guo 2026-03-19 20:37 ` Miguel Ojeda 2026-03-19 23:54 ` Nathan Chancellor 0 siblings, 2 replies; 13+ messages in thread From: Gary Guo @ 2026-03-19 19:09 UTC (permalink / raw) To: Alice Ryhl, Gary Guo Cc: Rong Xu, Han Shen, Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux On Thu Mar 19, 2026 at 4:33 PM GMT, Alice Ryhl wrote: > On Thu, Mar 19, 2026 at 12:47 PM Gary Guo <gary@garyguo.net> wrote: >> >> On Thu Mar 19, 2026 at 11:44 AM GMT, Alice Ryhl wrote: >> > On Thu, Mar 19, 2026 at 12:31 PM Gary Guo <gary@garyguo.net> wrote: >> >> >> >> On Thu Mar 19, 2026 at 11:22 AM GMT, Alice Ryhl wrote: >> >> > This patch enables AutoFDO build support for Rust code within the Linux >> >> > kernel. This allows Rust code to be profiled and optimized based on the >> >> > profile. >> >> > >> >> > This was verified by inspecting the object files and confirming that >> >> > they look correct. It was also verified in conjuction with my helpers >> >> > inlining series, and it also appears to have worked correctly when >> >> > combined with that series once one missing thing [1] was fixed in the >> >> > helpers inlining series. >> >> > >> >> > Link: https://lore.kernel.org/all/aasPsbMEsX6iGUl8@google.com/ [1] >> >> > Signed-off-by: Alice Ryhl <aliceryhl@google.com> >> >> > --- >> >> > scripts/Makefile.autofdo | 6 +++++- >> >> > scripts/Makefile.lib | 3 +++ >> >> > 2 files changed, 8 insertions(+), 1 deletion(-) >> >> > >> >> > diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo >> >> > index 1caf2457e585..3f08acab4549 100644 >> >> > --- a/scripts/Makefile.autofdo >> >> > +++ b/scripts/Makefile.autofdo >> >> > @@ -3,14 +3,18 @@ >> >> > # Enable available and selected Clang AutoFDO features. >> >> > >> >> > CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true >> >> > +RUSTFLAGS_AUTOFDO_CLANG := -Zdebug-info-for-profiling -Cllvm-args=-enable-fs-discriminator=true -Cllvm-args=-improved-fs-discriminator=true >> >> >> >> I get that it's currently named as AUTOFDO_CLANG, but this really ought to be >> >> AUTOFDO_LLVM... >> >> >> >> The flag translations look correct to me. >> > >> > Do you think it's worth having Rust not match the CFLAGS here? >> > >> >> I think the C flags should probably be renamed AUTOFDO_LLVM too. After call, all >> the perf tools involved here are called llvm-foobar as well. > > But isn't it just called this because the config option is > CONFIG_AUTOFDO_CLANG? So it's the CFLAGS or RUSTFLAGS related to that > particular config option. It may make sense to rename > CONFIG_AUTOFDO_CLANG to CONFIG_AUTOFDO, but that's out-of-scope for > this change, in my opinion. I get that it's an existing config name, but previously it is a correct description, while after this change it is no longer accurate. I don't know if there's an established practice on renaming CONFIG options when this sort thing happens though. Perhaps one way is to have add CONFIG_AUTOFDO_CLANG that selects CONFIG_AUTOFDO. Best, Gary ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-19 19:09 ` Gary Guo @ 2026-03-19 20:37 ` Miguel Ojeda 2026-03-19 23:54 ` Nathan Chancellor 1 sibling, 0 replies; 13+ messages in thread From: Miguel Ojeda @ 2026-03-19 20:37 UTC (permalink / raw) To: Gary Guo Cc: Alice Ryhl, Rong Xu, Han Shen, Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux On Thu, Mar 19, 2026 at 8:09 PM Gary Guo <gary@garyguo.net> wrote: > > I don't know if there's an established practice on renaming CONFIG options when > this sort thing happens though. Generally, we try to keep users' configs working. In the past, it was quite painful / pitfall-y to do so, so to make it easier, the `transitional` keyword was added recently -- a couple references: Documentation/kbuild/kconfig-language.rst f9afce4f32e9 ("kconfig: Add transitional symbol attribute for migration support") I hope that helps! Cheers, Miguel ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-19 19:09 ` Gary Guo 2026-03-19 20:37 ` Miguel Ojeda @ 2026-03-19 23:54 ` Nathan Chancellor 2026-03-20 6:47 ` Alice Ryhl 2026-03-20 21:48 ` Gary Guo 1 sibling, 2 replies; 13+ messages in thread From: Nathan Chancellor @ 2026-03-19 23:54 UTC (permalink / raw) To: Gary Guo Cc: Alice Ryhl, Rong Xu, Han Shen, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux On Thu, Mar 19, 2026 at 07:09:22PM +0000, Gary Guo wrote: > On Thu Mar 19, 2026 at 4:33 PM GMT, Alice Ryhl wrote: > > On Thu, Mar 19, 2026 at 12:47 PM Gary Guo <gary@garyguo.net> wrote: > >> On Thu Mar 19, 2026 at 11:44 AM GMT, Alice Ryhl wrote: > >> > Do you think it's worth having Rust not match the CFLAGS here? > >> > > >> > >> I think the C flags should probably be renamed AUTOFDO_LLVM too. After call, all > >> the perf tools involved here are called llvm-foobar as well. > > > > But isn't it just called this because the config option is > > CONFIG_AUTOFDO_CLANG? So it's the CFLAGS or RUSTFLAGS related to that > > particular config option. It may make sense to rename > > CONFIG_AUTOFDO_CLANG to CONFIG_AUTOFDO, but that's out-of-scope for > > this change, in my opinion. > > I get that it's an existing config name, but previously it is a correct > description, while after this change it is no longer accurate. > > I don't know if there's an established practice on renaming CONFIG options when > this sort thing happens though. Perhaps one way is to have add > CONFIG_AUTOFDO_CLANG that selects CONFIG_AUTOFDO. As Miguel mentioned, there is the transitional keyword for Kconfig to handle renames now but I would really like there to be a compelling reason for the rename other than LLVM is a little more accurate than CLANG. The kernel has never really done a great job of referring to Clang when it means the C compiler vs. the whole LLVM toolchain (like LTO_CLANG and all its derivatives should be LTO_LLVM since it requires ld.lld, llvm-nm, and llvm-ar in addition to clang). Additionally, aside from the configuration, there is the user facing Make variable CLANG_AUTOFDO_PROFILE that would presumably need to be changed for consistency. If we want to change the internal Kbuild variable names, I don't care as much about that. Cheers, Nathan ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-19 23:54 ` Nathan Chancellor @ 2026-03-20 6:47 ` Alice Ryhl 2026-03-20 21:18 ` Nathan Chancellor 2026-03-20 21:48 ` Gary Guo 1 sibling, 1 reply; 13+ messages in thread From: Alice Ryhl @ 2026-03-20 6:47 UTC (permalink / raw) To: Nathan Chancellor Cc: Gary Guo, Rong Xu, Han Shen, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux On Thu, Mar 19, 2026 at 04:54:43PM -0700, Nathan Chancellor wrote: > On Thu, Mar 19, 2026 at 07:09:22PM +0000, Gary Guo wrote: > > On Thu Mar 19, 2026 at 4:33 PM GMT, Alice Ryhl wrote: > > > On Thu, Mar 19, 2026 at 12:47 PM Gary Guo <gary@garyguo.net> wrote: > > >> On Thu Mar 19, 2026 at 11:44 AM GMT, Alice Ryhl wrote: > > >> > Do you think it's worth having Rust not match the CFLAGS here? > > >> > > > >> > > >> I think the C flags should probably be renamed AUTOFDO_LLVM too. After call, all > > >> the perf tools involved here are called llvm-foobar as well. > > > > > > But isn't it just called this because the config option is > > > CONFIG_AUTOFDO_CLANG? So it's the CFLAGS or RUSTFLAGS related to that > > > particular config option. It may make sense to rename > > > CONFIG_AUTOFDO_CLANG to CONFIG_AUTOFDO, but that's out-of-scope for > > > this change, in my opinion. > > > > I get that it's an existing config name, but previously it is a correct > > description, while after this change it is no longer accurate. > > > > I don't know if there's an established practice on renaming CONFIG options when > > this sort thing happens though. Perhaps one way is to have add > > CONFIG_AUTOFDO_CLANG that selects CONFIG_AUTOFDO. > > As Miguel mentioned, there is the transitional keyword for Kconfig to > handle renames now but I would really like there to be a compelling > reason for the rename other than LLVM is a little more accurate than > CLANG. The kernel has never really done a great job of referring to > Clang when it means the C compiler vs. the whole LLVM toolchain (like > LTO_CLANG and all its derivatives should be LTO_LLVM since it requires > ld.lld, llvm-nm, and llvm-ar in addition to clang). Additionally, aside > from the configuration, there is the user facing Make variable > CLANG_AUTOFDO_PROFILE that would presumably need to be changed for > consistency. > > If we want to change the internal Kbuild variable names, I don't care as > much about that. How about we just call them: * CFLAGS_AUTOFDO_CLANG * RUSTFLAGS_AUTOFDO then? For cflags, clarify that they are clang flags. For rustc, there is no such distinction to make (yet). Another option: * CFLAGS_AUTOFDO_CLANG * RUSTFLAGS_AUTOFDO_RUSTC Alice ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-20 6:47 ` Alice Ryhl @ 2026-03-20 21:18 ` Nathan Chancellor 0 siblings, 0 replies; 13+ messages in thread From: Nathan Chancellor @ 2026-03-20 21:18 UTC (permalink / raw) To: Alice Ryhl Cc: Gary Guo, Rong Xu, Han Shen, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux On Fri, Mar 20, 2026 at 06:47:05AM +0000, Alice Ryhl wrote: > How about we just call them: > > * CFLAGS_AUTOFDO_CLANG > * RUSTFLAGS_AUTOFDO > > then? For cflags, clarify that they are clang flags. For rustc, there is > no such distinction to make (yet). Yes, that seems reasonable to me (although CFLAGS_AUTOFDO_CLANG is already the name so I assume you mean just keeping it as it is). > Another option: > * CFLAGS_AUTOFDO_CLANG > * RUSTFLAGS_AUTOFDO_RUSTC I don't see much of a reason to make this distinction until the rest of the kernel's Rust code can be built with a different Rust compiler. Cheers, Nathan ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-19 23:54 ` Nathan Chancellor 2026-03-20 6:47 ` Alice Ryhl @ 2026-03-20 21:48 ` Gary Guo [not found] ` <CAF1bQ=T8-tWaB5Sf2eqWSodMgp=Pf9Guut-JavV62dczHpGNBg@mail.gmail.com> 2026-03-25 17:10 ` Rong Xu 1 sibling, 2 replies; 13+ messages in thread From: Gary Guo @ 2026-03-20 21:48 UTC (permalink / raw) To: Nathan Chancellor, Gary Guo Cc: Alice Ryhl, Rong Xu, Han Shen, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux On Thu Mar 19, 2026 at 11:54 PM GMT, Nathan Chancellor wrote: > On Thu, Mar 19, 2026 at 07:09:22PM +0000, Gary Guo wrote: >> On Thu Mar 19, 2026 at 4:33 PM GMT, Alice Ryhl wrote: >> > On Thu, Mar 19, 2026 at 12:47 PM Gary Guo <gary@garyguo.net> wrote: >> >> On Thu Mar 19, 2026 at 11:44 AM GMT, Alice Ryhl wrote: >> >> > Do you think it's worth having Rust not match the CFLAGS here? >> >> > >> >> >> >> I think the C flags should probably be renamed AUTOFDO_LLVM too. After call, all >> >> the perf tools involved here are called llvm-foobar as well. >> > >> > But isn't it just called this because the config option is >> > CONFIG_AUTOFDO_CLANG? So it's the CFLAGS or RUSTFLAGS related to that >> > particular config option. It may make sense to rename >> > CONFIG_AUTOFDO_CLANG to CONFIG_AUTOFDO, but that's out-of-scope for >> > this change, in my opinion. >> >> I get that it's an existing config name, but previously it is a correct >> description, while after this change it is no longer accurate. >> >> I don't know if there's an established practice on renaming CONFIG options when >> this sort thing happens though. Perhaps one way is to have add >> CONFIG_AUTOFDO_CLANG that selects CONFIG_AUTOFDO. > > As Miguel mentioned, there is the transitional keyword for Kconfig to > handle renames now but I would really like there to be a compelling > reason for the rename other than LLVM is a little more accurate than > CLANG. The kernel has never really done a great job of referring to > Clang when it means the C compiler vs. the whole LLVM toolchain (like > LTO_CLANG and all its derivatives should be LTO_LLVM since it requires > ld.lld, llvm-nm, and llvm-ar in addition to clang). Additionally, aside > from the configuration, there is the user facing Make variable > CLANG_AUTOFDO_PROFILE that would presumably need to be changed for > consistency. If you think the config name should be kept as CONFIG_AUTOFDO_CLANG, then I think there is no real benefit in changing the variable name. Reviewed-by: Gary Guo <gary@garyguo.net> Best, Gary ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <CAF1bQ=T8-tWaB5Sf2eqWSodMgp=Pf9Guut-JavV62dczHpGNBg@mail.gmail.com>]
* Re: [PATCH] kbuild: rust: add AutoFDO support [not found] ` <CAF1bQ=T8-tWaB5Sf2eqWSodMgp=Pf9Guut-JavV62dczHpGNBg@mail.gmail.com> @ 2026-03-25 17:08 ` Rong Xu 0 siblings, 0 replies; 13+ messages in thread From: Rong Xu @ 2026-03-25 17:08 UTC (permalink / raw) To: Gary Guo Cc: Nathan Chancellor, Alice Ryhl, Han Shen, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux (Resend in plain-text mode) I have reviewed this patch and it looks good to me. I suggest updating autofdo.rst to explicitly mention support for Rust. Regarding the naming convention, I understand Gary's point that Clang and Rust should both be viewed as LLVM frontends. I am open to renaming *FLAGS_AUTOFDO_CLANG to *FLAGS_AUTOFDO_LLVM. However, I would prefer not to use *FLAGS_AUTOFDO, as GCC also supports AutoFDO, but it hasn't been integrated into kernel builds yet. These naming updates can be handled in a separate patch. On Wed, Mar 25, 2026 at 5:01 PM Rong Xu <xur@google.com> wrote: > > I have reviewed this patch and it looks good to me. I suggest updating autofdo.rst to explicitly mention support for Rust. > > Regarding the naming convention, I understand Gary's point that Clang and Rust should both be viewed as LLVM frontends. I am open to renaming *FLAGS_AUTOFDO_CLANG to *FLAGS_AUTOFDO_LLVM. However, I would prefer not to use *FLAGS_AUTOFDO, as GCC also supports AutoFDO, but it hasn't been integrated into kernel builds yet. > > These naming updates can be handled in a separate patch. > > Reviewed-by: Rong Xu <xur@google.com> > > > On Fri, Mar 20, 2026 at 9:48 PM Gary Guo <gary@garyguo.net> wrote: >> >> On Thu Mar 19, 2026 at 11:54 PM GMT, Nathan Chancellor wrote: >> > On Thu, Mar 19, 2026 at 07:09:22PM +0000, Gary Guo wrote: >> >> On Thu Mar 19, 2026 at 4:33 PM GMT, Alice Ryhl wrote: >> >> > On Thu, Mar 19, 2026 at 12:47 PM Gary Guo <gary@garyguo.net> wrote: >> >> >> On Thu Mar 19, 2026 at 11:44 AM GMT, Alice Ryhl wrote: >> >> >> > Do you think it's worth having Rust not match the CFLAGS here? >> >> >> > >> >> >> >> >> >> I think the C flags should probably be renamed AUTOFDO_LLVM too. After call, all >> >> >> the perf tools involved here are called llvm-foobar as well. >> >> > >> >> > But isn't it just called this because the config option is >> >> > CONFIG_AUTOFDO_CLANG? So it's the CFLAGS or RUSTFLAGS related to that >> >> > particular config option. It may make sense to rename >> >> > CONFIG_AUTOFDO_CLANG to CONFIG_AUTOFDO, but that's out-of-scope for >> >> > this change, in my opinion. >> >> >> >> I get that it's an existing config name, but previously it is a correct >> >> description, while after this change it is no longer accurate. >> >> >> >> I don't know if there's an established practice on renaming CONFIG options when >> >> this sort thing happens though. Perhaps one way is to have add >> >> CONFIG_AUTOFDO_CLANG that selects CONFIG_AUTOFDO. >> > >> > As Miguel mentioned, there is the transitional keyword for Kconfig to >> > handle renames now but I would really like there to be a compelling >> > reason for the rename other than LLVM is a little more accurate than >> > CLANG. The kernel has never really done a great job of referring to >> > Clang when it means the C compiler vs. the whole LLVM toolchain (like >> > LTO_CLANG and all its derivatives should be LTO_LLVM since it requires >> > ld.lld, llvm-nm, and llvm-ar in addition to clang). Additionally, aside >> > from the configuration, there is the user facing Make variable >> > CLANG_AUTOFDO_PROFILE that would presumably need to be changed for >> > consistency. >> >> If you think the config name should be kept as CONFIG_AUTOFDO_CLANG, then I >> think there is no real benefit in changing the variable name. >> >> Reviewed-by: Gary Guo <gary@garyguo.net> >> >> Best, >> Gary ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] kbuild: rust: add AutoFDO support 2026-03-20 21:48 ` Gary Guo [not found] ` <CAF1bQ=T8-tWaB5Sf2eqWSodMgp=Pf9Guut-JavV62dczHpGNBg@mail.gmail.com> @ 2026-03-25 17:10 ` Rong Xu 1 sibling, 0 replies; 13+ messages in thread From: Rong Xu @ 2026-03-25 17:10 UTC (permalink / raw) To: Gary Guo Cc: Nathan Chancellor, Alice Ryhl, Han Shen, Nicolas Schier, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Matthew Maurer, linux-kbuild, linux-kernel, rust-for-linux I have reviewed this patch and it looks good to me. I suggest updating autofdo.rst to explicitly mention support for Rust. Regarding the naming convention, I understand Gary's point that Clang and Rust should both be viewed as LLVM frontends. I am open to renaming *FLAGS_AUTOFDO_CLANG to *FLAGS_AUTOFDO_LLVM. However, I would prefer not to use *FLAGS_AUTOFDO, as GCC also supports AutoFDO, but it hasn't been integrated into kernel builds yet. These naming updates can be handled in a separate patch. Reviewed-by: Rong Xu <xur@google.com> -Rong On Fri, Mar 20, 2026 at 9:48 PM Gary Guo <gary@garyguo.net> wrote: > > On Thu Mar 19, 2026 at 11:54 PM GMT, Nathan Chancellor wrote: > > On Thu, Mar 19, 2026 at 07:09:22PM +0000, Gary Guo wrote: > >> On Thu Mar 19, 2026 at 4:33 PM GMT, Alice Ryhl wrote: > >> > On Thu, Mar 19, 2026 at 12:47 PM Gary Guo <gary@garyguo.net> wrote: > >> >> On Thu Mar 19, 2026 at 11:44 AM GMT, Alice Ryhl wrote: > >> >> > Do you think it's worth having Rust not match the CFLAGS here? > >> >> > > >> >> > >> >> I think the C flags should probably be renamed AUTOFDO_LLVM too. After call, all > >> >> the perf tools involved here are called llvm-foobar as well. > >> > > >> > But isn't it just called this because the config option is > >> > CONFIG_AUTOFDO_CLANG? So it's the CFLAGS or RUSTFLAGS related to that > >> > particular config option. It may make sense to rename > >> > CONFIG_AUTOFDO_CLANG to CONFIG_AUTOFDO, but that's out-of-scope for > >> > this change, in my opinion. > >> > >> I get that it's an existing config name, but previously it is a correct > >> description, while after this change it is no longer accurate. > >> > >> I don't know if there's an established practice on renaming CONFIG options when > >> this sort thing happens though. Perhaps one way is to have add > >> CONFIG_AUTOFDO_CLANG that selects CONFIG_AUTOFDO. > > > > As Miguel mentioned, there is the transitional keyword for Kconfig to > > handle renames now but I would really like there to be a compelling > > reason for the rename other than LLVM is a little more accurate than > > CLANG. The kernel has never really done a great job of referring to > > Clang when it means the C compiler vs. the whole LLVM toolchain (like > > LTO_CLANG and all its derivatives should be LTO_LLVM since it requires > > ld.lld, llvm-nm, and llvm-ar in addition to clang). Additionally, aside > > from the configuration, there is the user facing Make variable > > CLANG_AUTOFDO_PROFILE that would presumably need to be changed for > > consistency. > > If you think the config name should be kept as CONFIG_AUTOFDO_CLANG, then I > think there is no real benefit in changing the variable name. > > Reviewed-by: Gary Guo <gary@garyguo.net> > > Best, > Gary ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-03-25 17:10 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 11:22 [PATCH] kbuild: rust: add AutoFDO support Alice Ryhl
2026-03-19 11:31 ` Gary Guo
2026-03-19 11:44 ` Alice Ryhl
2026-03-19 11:47 ` Gary Guo
2026-03-19 16:33 ` Alice Ryhl
2026-03-19 19:09 ` Gary Guo
2026-03-19 20:37 ` Miguel Ojeda
2026-03-19 23:54 ` Nathan Chancellor
2026-03-20 6:47 ` Alice Ryhl
2026-03-20 21:18 ` Nathan Chancellor
2026-03-20 21:48 ` Gary Guo
[not found] ` <CAF1bQ=T8-tWaB5Sf2eqWSodMgp=Pf9Guut-JavV62dczHpGNBg@mail.gmail.com>
2026-03-25 17:08 ` Rong Xu
2026-03-25 17:10 ` Rong Xu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox