Re: [PATCH] kbuild: rust: add AutoFDO support

From: Alice Ryhl

Date: Thu Mar 19 2026 - 07:46:28 EST


On Thu, Mar 19, 2026 at 12:31 PM Gary Guo <gary@xxxxxxxxxxx> 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@xxxxxxxxxx/ [1]
> > Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> > ---
> > 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