rust-lang / rust-lang/rust-bindgen
Missing class methods bindings when target is i686-pc-windows-gnu
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
struct Vec2 {
float x, y;
void reset();
};
Bindgen Invocation
$ bindgen test.hpp -- -target i686-pc-windows-gnu
Actual Results
/* automatically generated by rust-bindgen */
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Vec2 {
pub x: f32,
pub y: f32,
}
#[test]
fn bindgen_test_layout_Vec2() {
assert_eq!(
::std::mem::size_of::<Vec2>(),
8usize,
concat!("Size of: ", stringify!(Vec2))
);
assert_eq!(
::std::mem::align_of::<Vec2>(),
4usize,
concat!("Alignment of ", stringify!(Vec2))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<Vec2>())).x as *const _ as usize },
0usize,
concat!("Offset of field: ", stringify!(Vec2), "::", stringify!(x))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<Vec2>())).y as *const _ as usize },
4usize,
concat!("Offset of field: ", stringify!(Vec2), "::", stringify!(y))
);
}
Expected Results
However when target is x86_64 it works as expected:
$ bindgen test.hpp -- -target x86_64-pc-windows-gnu
The result is:
/* automatically generated by rust-bindgen */
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Vec2 {
pub x: f32,
pub y: f32,
}
#[test]
fn bindgen_test_layout_Vec2() {
assert_eq!(
::std::mem::size_of::<Vec2>(),
8usize,
concat!("Size of: ", stringify!(Vec2))
);
assert_eq!(
::std::mem::align_of::<Vec2>(),
4usize,
concat!("Alignment of ", stringify!(Vec2))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<Vec2>())).x as *const _ as usize },
0usize,
concat!("Offset of field: ", stringify!(Vec2), "::", stringify!(x))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<Vec2>())).y as *const _ as usize },
4usize,
concat!("Offset of field: ", stringify!(Vec2), "::", stringify!(y))
);
}
extern "C" {
#[link_name = "\u{1}_ZN4Vec25resetEv"]
pub fn Vec2_reset(this: *mut Vec2);
}
impl Vec2 {
#[inline]
pub unsafe fn reset(&mut self) {
Vec2_reset(self)
}
}
I assume the both results should looks similar but this isn't so.
This issue looks like a #751, but adding -fvisibility=default doesn't help.
Also I tried to set appropriate sysroot to clang (using -isysroot) but It also doesn't help.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the discrepancy with the test.hpp header and the bindgen commands for i686-pc-windows-gnu and x86_64-pc-windows-gnu. Trace target-specific handling of C++ class methods and symbol generation; done means the i686 output includes the reset binding consistently with the x86_64 output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100