Re: [PATCH v3 01/11] rust: bindings: Support some inline static functions

From: Alistair Francis
Date: Mon Nov 11 2024 - 17:52:21 EST


On Mon, Nov 11, 2024 at 9:47 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
>
> "Alistair Francis" <alistair@xxxxxxxxxxxxx> writes:
>
> > The kernel includes a large number of static inline functions that are
> > defined in header files. One example is the crypto_shash_descsize()
> > function which is defined in hash.h as
> >
> > static inline unsigned int crypto_shash_descsize(struct crypto_shash *tfm)
> > {
> > return tfm->descsize;
> > }
> >
> > bindgen is currently unable to generate bindings to these functions as
> > they are not publically exposed (they are static after all).
>
> Very cool!
>
> What does this mean for our minimum bindgen version? Is the feature safe

There are no changes to the minimum bindgen version :)

The next release of bindgen will support it without the experimental
flag [1], but 0.65.1 and newer will all work.

> to use in our current required version of 0.65.1? Did the feature change
> in significant ways between 0.65.1 and whatever version it will be
> stable in?

There are no breaking changes in the changelog that I can find. There
are improvements to support more functions, but as we use an
allow-list that doesn't affect us.

Eventually when the minimum bindgen is updated we can remove the
experimental flag, but otherwise it should work with everything newer
than 0.65.

1: https://github.com/rust-lang/rust-bindgen/blob/main/CHANGELOG.md?plain=1#L219

>
>
> > diff --git a/rust/bindgen_static_functions b/rust/bindgen_static_functions
> > new file mode 100644
> > index 000000000000..1f24360daeb3
> > --- /dev/null
> > +++ b/rust/bindgen_static_functions
> > @@ -0,0 +1,6 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +# Don't generate structs
> > +--blocklist-type '.*'
> > +
> > +--allowlist-function blk_mq_rq_to_pdu
>
> Should this be moved to the "Remove blk helper" patch?

I need a function here, otherwise nothing is generated and it fails to
build. As this would be added in the next patch anyway I just added it
here to maintain bisectability.

Alistair

>
>
> Best regards,
> Andreas Hindborg
>
>