rb-sys icon indicating copy to clipboard operation
rb-sys copied to clipboard

Bindgen layout tests broken with bindgen v0.70

Open NoisyCoil opened this issue 1 year ago • 1 comments

Hello. After updating bindgen to v0.70 in Debian, bindgen layout tests for rb-sys started failing. More precisely, they started to fail compiling at all. The compile errors I see are of the kind

 96s error[E0412]: cannot find type `RString` in this scope
 96s  --> /tmp/tmp.8KgGSkJnaY/target/x86_64-unknown-linux-gnu/debug/build/rb-sys-2ab3a78fa105e128/out/bindings-0.9.102-x86_64-linux-gnu-3.1.2.rs:1:103592
 96s   |
 96s 1 | ... _ : () = { ["Size of RString"] [:: std :: mem :: size_of :: < RString > () - 40usize] ; ["Alignment of RString"] [:: std :: mem :: al...
220s   |                                                ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
 97s error[E0412]: cannot find type `rb_sys__Opaque__RArray` in this scope
 97s  --> /tmp/tmp.8KgGSkJnaY/target/x86_64-unknown-linux-gnu/debug/build/rb-sys-2ab3a78fa105e128/out/bindings-0.9.102-x86_64-linux-gnu-3.1.2.rs:1:237821
 97s   |
 97s 1 | ...e__RArray"] [:: std :: mem :: align_of :: < rb_sys__Opaque__RArray > () - 8usize] ; } ; # [doc = "\n---\n\nGenerated by [rb-sys](https...
 97s   |                                                ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
220s 
220s error[E0412]: cannot find type `RArray` in this scope
220s  --> /tmp/tmp.SXMzVBjVR1/target/x86_64-unknown-linux-gnu/debug/build/rb-sys-6425e5deae7afbe9/out/bindings-0.9.102-x86_64-linux-gnu-3.1.2.rs:1:104102
220s   |
220s 1 | ...{ ["Size of RArray"] [:: std :: mem :: size_of :: < RArray > () - 40usize] ; ["Alignment of RArray"] [:: std :: mem :: align_of :: < R...
220s   |                                                        ^^^^^^ not found in this scope
220s error[E0412]: cannot find type `rb_sys__Opaque__RString` in this scope
220s  --> /tmp/tmp.SXMzVBjVR1/target/x86_64-unknown-linux-gnu/debug/build/rb-sys-6425e5deae7afbe9/out/bindings-0.9.102-x86_64-linux-gnu-3.1.2.rs:1:221019
220s   |
220s 1 | ..._RString"] [:: std :: mem :: align_of :: < rb_sys__Opaque__RString > () - 8usize] ; } ; # [allow (clippy :: unnecessary_operation , cl...
220s   |                                               ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

see e.g. https://ci.debian.net/data/autopkgtest/testing/amd64/r/rust-rb-sys/54516503/log.gz for a full log.

I believe the reason for these is starting from v0.70 layout tests were replaced with build-time compilation tests. rb-sys-build, however, still expects actual tests so it does not modify the generated bindings file properly for opaque types (there are no bindgen_test_* functions in the file generated by v0.70).

Edit: Maybe I should have been more clear in specifying that, since the error is a compile error, it's the whole feature that's broken (as in cargo build --feature bindgen-layout-tests), not just the tests (as in cargo test --feature bindgen-layout-tests). In Debian, that showed up as a test failure, but in general the feature fails to build too for the aforementioned reasons.

NoisyCoil avatar Nov 23 '24 08:11 NoisyCoil

I took a stab at this here: https://github.com/oxidize-rb/rb-sys/pull/482

jbourassa avatar Jan 14 '25 00:01 jbourassa