-
Notifications
You must be signed in to change notification settings - Fork 745
Missing memory alignment Rust generated code #1291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you tried with Good point about the test though, that's definitely an oversight on my side when implementing #1271. We currently skip the test here: Needs a feature check, should be trivial to fix. Want to submit a PR? |
Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the If you intend to work on this issue, then add |
Thanks for the fast awnser. This is the updated call to the bindgen: let bindings = bindgen::Builder::default()
.clang_args(["-x", "c++", "-std=c++11"].iter())
.enable_cxx_namespaces()
.blacklist_type("max_align_t")
.rust_target(bindgen::RustTarget::Stable_1_25)
.header("wrapper.h")
.generate()
.expect("Unable to generate bindings"); I have tried to see why the "align" attribute is not added to the generated code. But I did not found the reason yet. If I have time, I will investigate. |
That looks... Also like an oversight on my side. In particular, for alignments greater than a word we couldn't generate proper alignment until |
Plus fix the check that avoids us generating explicit alignment fields for structs aligned to more than pointer-size. Fixes rust-lang#1291
Hi guys,
I developing a Rust wrapper for the Embree library. This library heavily relies on processor vector operation (SSE, AVX) to provide high performance. For now, I use explicit FFI declaration to interface with Embree. However, I was planning to use rust-bindgen to generate this interface automatically.
However, when I use bindgen, the code does not align correctly compared to what it is specified in the C++ header. Moreover, the test code generated by bindgen does not include a test to check if the current rust code have the proper alignment.
Input C/C++ Header
Extracted code from Embree (v2)
Bindgen Invocation
Actual Results
The code generated by rust-bindgen
The test that I have inside my lib.rs:
this test failed and give me this output:
Expected Results
From bindgen call, I was expecting two things:
#[repr(C,align(16))]
(compared to#[repr(C)]
)assert_eq!(::std::mem::align_of::<RTCRay>(), 16usize);
inside the test suite.Does rust-bindgen have a way to generate this test and have explicit align automatically?
Thanks guys for your awsome tool. Hope that I can use it inside my project :)
Version
rustup 1.11.0, stable rust 1.25.0 (84203cac6 2018-03-25), version bindgen: "0.35.0"
My embree wrapper: https://github.com/beltegeuse/embree-rs (branch: bindgen)
The text was updated successfully, but these errors were encountered: