Re: [PATCH] rust: cfi: disable function merging if CFI is enabled

From: Alice Ryhl

Date: Wed Nov 18 2026 - 06:53:01 EST


On Wed, Nov 18, 2026 at 12:25 PM Gary Guo <gary@xxxxxxxxxxx> wrote:
>
> 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?

In principle merging would be ok if the gendwarfksyms CRCs are the
same. I think that if KCFI hashes match, then the gendwarfksyms CRCs
are quite likely to be the same too, but I don't think it's a hard
guarantee.

After all, for a pointer to struct argument, the KCFI hash depends
only on the struct name, whereas gendwarfksym CRC also looks at its
fields.


Alice