Re: [PATCH] kbuild: rust: pass AutoFDO flags to Clang with inline helpers
From: Miguel Ojeda
Date: Wed Nov 11 2026 - 13:49:09 EST
On Sat, Oct 31, 2026 at 4:08 AM Jenhao Chen <jenhaochen@xxxxxxxxxx> wrote:
>
> Factor out _autofdo_c_flags in scripts/Makefile.lib (preserving per-file
> and per-directory AUTOFDO_PROFILE opt-outs) and pass it to the
> post-llvm-link $(CC) invocation in scripts/Makefile.build and
> rust/Makefile.
This sounds reasonable, but my LLM spotted that Clang will run
`AddDiscriminatorsPass` again, i.e. on the optimized bitcode that
`rustc` produced. So the profile ends up indexed by Clang's renumbered
discriminators, and then the build that uses the profile will not find
a match for some code (depending on inlining decisions), i.e. that
part of the profile is silently dropped.
It proposes `-mllvm -no-discriminators` in
`CC_FLAGS_RUST_INLINE_HELPERS` so that Clang doesn't add them, i.e.
using the `rustc` ones.
Rong, Han: is that expected?
Cheers,
Miguel