Re: [PATCH] rust: Disallow BTF generation with Rust + LTO
From: Arnaldo Carvalho de Melo
Date: Thu Jan 09 2025 - 11:38:30 EST
On Thu, Jan 09, 2025 at 01:29:47PM -0300, Arnaldo Carvalho de Melo wrote:
> On Thu, Jan 09, 2025 at 10:49:49AM -0500, Tamir Duberstein wrote:
> > On Thu, Jan 9, 2025 at 10:47 AM Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:
> > > I was thinking about it after reading this thread yesterday, i.e. we
> > > could encode constructs from Rust that can be represented in BTF and
> > > skip the ones that can't, pruning types that depend on non BTF
> > > representable types, etc.
> > Yep, this is what bpf-linker does, along with some other things[0]. I
> > highly recommend reading the code I linked to avoid re-discovering
> > these things.
> Sure, thanks for pointing it out and suggest I read it while
> experimenting with having the same concept in pahole, I'll try a quick
> hack and then look at it to see how close I got to what you guys came up
> with :-)
BTW, its "funny" how the DWARF loader can get things from Rust, golang,
fortran and end up with things like:
Rust:
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=d744d859768d6951cacd146604891c108b39f6a1
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=c4eb1897d1f3841d291ee39dc969c4212750cf2c
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=2e8cd6a435d96335c4794794147019369b6a7b6a
FORTRAN:
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=f5847773d94d4875e04e47de9b677098f34c6510
Go:
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=31bc0d7410572f6e03e3ed9da7c8c6f0d8df23c8
Now its a matter of making the BTF encoder be more permissive and just
skip things it can't express in BTF.
:-)
- Arnaldo