Re: [PATCH] rust: cfi: disable function merging if CFI is enabled
Miguel Ojeda <[email protected]>
| Newsgroups | org.kernel.vger.rust-for-linux,dev.linux.lists.llvm,org.kernel.vger.linux-kbuild,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CANiq72=SL4A-UQbOxngRy8-6Q-qHKyGbqOTvqo=uJNyhr5nTzw@mail.gmail.com> |
On Thu, Aug 20, 2026 at 3:57 PM Gary Guo <[email protected]> wrote: > > From: Gary Guo <[email protected]> > > In Rust doc tests, there is a dummy `__module_firmware_test_init` function > generated by the example in `module_firmware!`'s documentation, which just > returns zero. Many other documentation generates function that produces > zero. LKP test robot reports a `Flags::zeroed` instance; my local > reproduction has a `Bounded::new::<0>`. > > LLVM's MergeFunctionsPass incorrectly merge functions with the same KCFI > type, causing `__module_firmware_test_init` being merged into one of the > zero-returning function. As module init is invoked via indirect function > call, KCFI is checked and this produces a KCFI failure. > > I've reported this bug to upstream LLVM [1]; in the mean time, disable > function merging if CFI is enabled. No separate treatment is needed for > CONFIG_RUST_INLINE_HELPERS, as Clang does not enable function merging by > default. > > Reported-by: kernel test robot <[email protected]> > Closes: https://lore.kernel.org/oe-lkp/[email protected] > Link: https://github.com/llvm/llvm-project/issues/217629 [1] > Signed-off-by: Gary Guo <[email protected]> [ LLVM already has a pending PR: https://github.com/llvm/llvm-project/pull/217665 which solves the issue. In addition, I asked upstream Rust if the unstable `-Zmerge-functions=disabled` flag will remain around: https://rust-lang.zulipchat.com/#narrow/channel/425075-rust-for-linux/topic/.60-Zmerge-functions.3Ddisabled.60/ and it does indeed look like that will be the case. - Miguel ] [ Fixed typos as discussed. Reworded slightly for other typos. - Miguel ] Link: https://github.com/llvm/llvm-project/issues/217629 [2] Cc: [email protected] Fixes: ca627e636551 ("rust: cfi: add support for CFI_CLANG with Rust") Cheers, Miguel