embassy-rs / nrf-softdevice

Apache License 2.0
254 stars 74 forks source link

Bindgen dependency requirement? #255

Open plaes opened 1 month ago

plaes commented 1 month ago

Attempt to run gen.sh straight from current HEAD fails with following error:

+ for s in mbr s112 s113 s122 s132 s140
+ ./nrf-softdevice-gen/target/release/nrf-softdevice-gen ./softdevice/mbr/headers ./nrf-softdevice-mbr/src/bindings.rs
thread 'main' panicked at /home/plaes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.55.1/src/ir/context.rs:838:9:
"sd_mbr_command_t_union_(unnamed_at__/tmp/nrf_mbr_h_219_3)" is not a valid Ident
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

First version of bindgen which works is 0.62, though generated bindings seem to have some minor incompatibilities regarding newly introduced _bitfield_align_1 field:

Current binding in git generated with 0.55.2:

#[doc = "@brief GATT Characteristic Properties."]
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct ble_gatt_char_props_t {
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
}

Generated with 0.62:

#[doc = "@brief GATT Characteristic Properties."]
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct ble_gatt_char_props_t {
    pub _bitfield_align_1: [u8; 0],
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
}

Upstream PR which adds the extra alignment field is https://github.com/rust-lang/rust-bindgen/pull/1950 and was introduced in bindgen 0.57.