Re: [PATCH v2 0/3] Inline helpers into Rust without full LTO
Miguel Ojeda <[email protected]>
| Newsgroups | gmane.linux.kernel.rust,gmane.linux.ports.arm.kernel,gmane.linux.kbuild.devel,gmane.linux.kernel,gmane.linux.kernel.mm,gmane.linux.uml.devel |
|---|---|
| Message-ID | <CANiq72kD6HVrDTjQrTXDujyjA4Z5ELM6Nh8kFfVfNXrvpfU1wA@mail.gmail.com> |
On Mon, Mar 23, 2026 at 2:28 PM Andrew Lunn <[email protected]> wrote: > > So it sounds like my understanding is out of date. When the first > Ethernet PHY driver was being merged, Rust could not access inline C > functions. The binding had to replicate the functionality. But you are > saying that Rust can now make use of inline C code, but not actually > inline it? It results in a function call? > > What this feature does it actually allows inline C functions to be > inline? So it is just an optimisation? We have always been using the helpers to access the inline functions, please see the top comment in `rust/helpers/helpers.c`: Non-trivial C macros cannot be used in Rust. Similarly, inlined C functions cannot be called either. This file explicitly creates functions ("helpers") that wrap those so that they can be called from Rust. It doesn't duplicate the functionality, it simply forwards the call, i.e. it is not as bad as a full copy-paste of the implementation. This patch series aims to improve performance (cheaply in terms of built time) because for Rust calling those helpers are not inline anymore otherwise. You may be referring, instead, to avoiding to have to write manually the helper (the forwarder) -- for that, please see "Support static inline functions in headers (by generating a wrapper)" at: https://github.com/Rust-for-Linux/linux/issues/353 (In fact, I had your previous mention of `skbuff.h` from Lore there :) Assuming `--wrap-static-fns` works well etc., then it would be nice to use it, yeah. But that is different from this patch series (and this patch series would apply as well even if we use the automated wrappers etc.). I hope that clarifies. Cheers, Miguel