-
Notifications
You must be signed in to change notification settings - Fork 707
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
structure layout using __aligned__ attribute is incorrect #867
Comments
Thanks a lot for the report :) |
FYI this issue seems to have solved with newer clang/llvm version. I was trying to bindgen for some linux kernel header files like https://github.com/torvalds/linux/blob/master/include/uapi/linux/taskstats.h#L41 and hit the same issue, but on different machine with newer clang/llvm version the padding field is inserted in correct place and it worked well. The older clang and llvm version is indeed lower than the recommended version at: https://rust-lang.github.io/rust-bindgen/requirements.html#clang With old clang and llvm:
Generated: #[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct taskstats {
(snip)
pub ac_pad: [__u8; 3usize],
pub ac_uid: __u32,
(snip)
pub freepages_delay_total: __u64,
pub __bindgen_padding_0: u64,
} With new clang and llvm:
Generated: #[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct taskstats {
(snip)
pub ac_pad: [__u8; 3usize],
pub __bindgen_padding_0: u32,
pub ac_uid: __u32,
(snip)
pub freepages_delay_total: __u64,
} |
Thank you for your information.
I try to generate rust code from the header with bindgen 0.53.2.
It seems works well, but it can not be compiled.
|
This became an instance of #1538 if I understand. |
Input C/C++ Header
The original header is linux kernel source header; linux/target_core_user.h.
Bindgen Invocation
Actual Results
Expected Results
In C, the offset of cmd_tail is 64, so generated rust code should also have same offset.
To check offset, I wrote C code like as;
The outpu is;
The text was updated successfully, but these errors were encountered: