Re: [PATCH] rust: cfi: disable function merging if CFI is enabled
From: Gary Guo
Date: Wed Nov 18 2026 - 06:25:58 EST
On Tue Nov 17, 2026 at 8:58 PM GMT, Alice Ryhl wrote:
> On Fri, Aug 21, 2026 at 11:20:18AM +0200, Miguel Ojeda wrote:
>> On Fri, Aug 21, 2026 at 1:43 AM Sami Tolvanen <samitolvanen@xxxxxxxxxx> wrote:
>> >
>> > The LLVM fix itself is trivial, and it looks like a pull request for
>> > it already exists. I assume we'll want to drop this flag for fixed
>> > LLVM versions when they're available.
>>
>> I will link it in the commit message when I pick it up soon -- already
>> did in https://github.com/Rust-for-Linux/linux/issues/1132.
>>
>> I also added the `-Z` flag to https://github.com/Rust-for-Linux/linux/issues/2.
>>
>> The `-Zmerge-functions` flag is internal but has been there since Rust
>> 1.34.0 in upstream commit:
>>
>> b91d211b4030 ("Add a target option "merge-functions" taking values
>> in ("disabled", "trampolines", or "aliases (the default)) to allow
>> targets to opt out of the MergeFunctions LLVM pass. Also add a
>> corresponding -Z option with the same name and values.")
>>
>> so that should be fine, but I will ping upstream Rust so that they are
>> aware we are using it.
>>
>> And, yeah, agreed, we probably should remove the flag conditionally
>> later on, to confirm the bug is gone etc.
>
> Function merging should also be disabled with gendwarfksyms. It causes
> faux::Registration::as_raw() and Page::as_ptr() to get merged, which
> incorrectly causes the former to get the CRC of the latter.
Do we not want merging at all, or only when the types are not going to match up?
If somehow the KCFI type metadata is always emitted, will two functions with the
same KCFI type metadata be mergeable for gendwarfksyms purpose?
Best,
Gary