Re: [PATCH BCACHEFS-TOOLS] use upstream bindgen; fix packed and aligned types

Thomas Bertschinger
2024-01-22T20:19:17Z

On Mon, Jan 22, 2024 at 02:22:47PM -0500, Kent Overstreet wrote:
>
> Doesn't build here...?
>
> Compiling bch_bindgen v0.1.0 (/home/kent/bcachefs-tools/bch_bindgen)
> error[E0587]: type has conflicting packed and align representation hints
> --> /home/kent/bcachefs-tools/target/release/build/bch_bindgen-6ee8b9c8755f1deb/out/bcachefs.rs:3:147196
> |
> 3 | ...r (align (8))] # [derive (Debug , Default , Copy , Clone)] pub struct bkey { pub u64s : __u8 , pub _bitfield_align_1 : [u8 ; 0] , pub ...
> | ^^^^^^^^^^^^^^^

It looks like this happens if you build bcachefs-tools in an environment
without the "rustfmt" tool. Turns out that tool is what inserts the line
breaks into the bindings string. If rustfmt isn't in the path, you get
a string with spaces instead of "\n".

I will work on a v2 that can be resilient to that environment
difference.

FWIW, it looks like the bindgen maintainer is open to a patch to handle
this in bindgen, so hopefully this is a short-lived hack...
https://github.com/rust-lang/rust-bindgen/issues/2725

- Thomas Bertschinger