Re: rust compile failure in next-20260730

"Gary Guo" <[email protected]> Mon, 03 Aug 2026 16:32:02 +0100
Newsgroups org.kernel.vger.linux-next,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
On Mon Aug 3, 2026 at 4:10 PM BST, Vlastimil Babka (SUSE) wrote:
> On 8/3/26 16:23, Boqun Feng wrote:
>> On Mon, Aug 03, 2026 at 02:57:49PM +0100, Gary Guo wrote:
>>>=20
>>> We could also unconditionally use `kvfree_rcu_head` here, and
>>> add
>>>=20
>>>     #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
>>>     pub type kvfree_rcu_head =3D callback_head;
>>>=20
>>> to bindings.rs?
>>>=20
>>=20
>> This option is currently not maintainable unless it becomes a
>> maintainer-aware way to handle things like this.
>>=20
>>> (Or even better, changing `#define` to `typedef` so bindgen takes care =
of
>>> everything).
>>>=20
>>=20
>> Yes, this is better IMO, but it's up to slab maintainers. :-)
>
> Can you elaborate a bit please, how would that look like?

I was thinking of doing `typedef struct rcu_head kvfree_rcu_head;` but of c=
ourse
that didn't work because you can't use typedef to create `kvfree_rcu_head` =
:)

However, something like this could work?

    #ifdef CONFIG_KVFREE_RCU_BATCHED
    ...
    #else
    struct kvfree_rcu_head {
        struct rcu_head head;
    };
    #endif

and everywhere add a cast everywhere that expects kvfree_rcu_head =3D=3D rc=
u_head.

but this would indeed be more complex :(

It's a bit unfortunate that C doesn't have a better way of doing struct typ=
e
aliases without doing textual replacement with macro.=20

Another approach is to have:

    #ifdef __BINDGEN__
    typedef struct rcu_head kvfree_rcu_head;
    #endif
    #define kvfree_rcu_head rcu_head

so bindgen can still see the typedef while it doesn't have effect for C use=
rs.
But this doesn't look perfect either.

Best,
Gary