Re: [PATCH] rust: Disallow BTF generation with Rust + LTO

From: Alice Ryhl
Date: Thu Jan 09 2025 - 09:16:01 EST


On Thu, Jan 9, 2025 at 3:10 PM Neal Gompa <neal@xxxxxxxxx> wrote:
>
> On Thu, Jan 9, 2025 at 8:17 AM Miguel Ojeda
> <miguel.ojeda.sandonis@xxxxxxxxx> wrote:
> >
> > On Thu, Jan 9, 2025 at 12:35 AM Matthew Maurer <mmaurer@xxxxxxxxxx> wrote:
> > >
> > > The kernel cannot currently self-parse BTF containing Rust debug
> > > information. pahole uses the language of the CU to determine whether to
> > > filter out debug information when generating the BTF. When LTO is
> > > enabled, Rust code can cross CU boundaries, resulting in Rust debug
> > > information in CUs labeled as C. This results in a system which cannot
> > > parse its own BTF.
> >
> > Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> >
> > as well as BPF/BTF, plus others that may be using or were involved
> > with the right-hand side of the condition.
> >
>
> Do we have cases where something is a mix of C and Rust? I thought all
> our Linux Rust code was self-contained?

If LTO is used, then any time that Rust calls C or C calls Rust,
optimizations could move Rust code into a C object file and cause this
boot failure. For example, vsprintf calls the Rust function
rust_fmt_argument when using the %pA format specifier.

Alice