Re: [PATCH] rust: cfi: disable function merging if CFI is enabled
From: Miguel Ojeda
Date: Sun Aug 23 2026 - 21:15:36 EST
On Thu, Aug 20, 2026 at 3:57 PM Gary Guo <gary@xxxxxxxxxx> wrote:
>
> From: Gary Guo <gary@xxxxxxxxxxx>
>
> 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 <yi1.lai@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-lkp/202608201017.100a4511-lkp@xxxxxxxxx
> Link: https://github.com/llvm/llvm-project/issues/217629 [1]
> Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>
[ 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: stable@xxxxxxxxxxxxxxx
Fixes: ca627e636551 ("rust: cfi: add support for CFI_CLANG with Rust")
Cheers,
Miguel