Re: [PATCH] rust: bindings: derive Zeroable for bindgen's opaque array wrappers
From: Sasha Levin
Date: Sat Oct 31 2026 - 12:29:54 EST
On Sat, Oct 31, 2026 at 05:17:46PM +0100, Alice Ryhl wrote:
>Is it possible to instead fix this by adding the impl of Zeroable in
>rust/bindings/lib.rs, similar to this piece of code that we already
>have:
>
>unsafe impl<Storage> Zeroable for __BindgenBitfieldUnit<Storage> where
>Storage: Zeroable {}
I looked at doing it that way, but the wrapper types don't always exist,
so a fixed impl in lib.rs won't build everywhere:
- bindgen 0.71 and 0.72 (we still support 0.71.1) don't generate them
at all, the blob is a plain array there.
- 0.73 only emits the alignments a config actually needs. On x86_64,
allmodconfig gets __BindgenOpaqueArray, __BindgenOpaqueArray8,
__BindgenOpaqueArray64 and __BindgenOpaqueArray4096, but defconfig
with Rust enabled has no __BindgenOpaqueArray4096, so an impl for it
would break the build there.
__BindgenBitfieldUnit works because it's always generated. We could do it
in lib.rs with a Kconfig symbol for the bindgen version plus some way to
know which alignments a config ends up with, but tagging the wrappers
right after bindgen runs seemed simpler.
--
Thanks,
Sasha