On Thu, Dec 04, 2025 at 10:23:17AM +0000, Alice Ryhl wrote: > > The other day [*] I proposed extending Rust such that it would be able > > to consume a clang precompiled header directly, this would allow doing > > away with most of all this. No more helpers and no more bindgen. > > > > Would that not be a much saner approach to all this? > > > > [*] > > https://lkml.kernel.org/r/[email protected] > > I have actually discussed similar ideas in the past with Josh Triplett, > so you are not the only one who thinks it is a good idea. Unfortunately, > the road to get there is long.
Right. Earlier I also proposed using libclang to parse the C header and inject that. This might be a little simpler, in that.. > Another option to get rid of the helpers is that bindgen is working on a > --wrap-static-fns flag, which would generate the helpers for us. > However, that route would still require this patch for them to be > inlined. > > One detail that makes the precompiled clang header really tricky is > that IMO we should not require RUSTC_CLANG_LLVM_COMPATIBLE for the > build. With bindgen, you just need bindgen and clang to match LLVMs. > That's easy since bindgen loads a dylib from your clang install. But if > you build this logic into rustc, then you need to be really careful to > get rustc and clang from the same source, and that same source must use > the same LLVM to build both. ... if you build rustc against libclang they are necessarily from the same LLVM build. But that might be more tricky in that you might need ways to specify C specific build flags. Anyway, good to know people are in fact pondering this, because IMO the whole interoperability thing with C is quite terrible.
