Closed ignatenkobrain closed 9 months ago
It appears that these test failures happen because bindgen test cases are not generated at build-time, and hard-code struct sizes that are only valid on 64-bit architectures. Looking at the code, I think the failures are harmless.
Still, would it be possible to generate the bindings and tests with bindgen at build-time (i.e. in build.rs)? Looking at the generated code in src/lib.rs, I think there are no manual modifications of the source code that was generated by bindgen, so that should work, it would solve the problem of the broken bindgen tests, and you wouldn't need to actually commit the generated source code to git at all, but only the build script and a "wrapper" lib.rs file.
Just using bindgen directly is not a good solution as this introduces quite a lot of heavy dependencies. bindgen
links llvm internally, so that must be there at build time or build as part of the build process. We can talk about adding support for this behind a feature flag that is off by default, but I would postpone that at least till https://github.com/sgrif/pq-sys/issues/42 is solved.
Sure, it makes sense to make it optional behind a feature flag for such cases. I can submit a PR for that, once the prerequisites are done :)
I ran into the same issue on debian while unblocking diesel. I skipped the failing test for now with this patch:
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -37,6 +37,7 @@ pub struct __sbuf {
pub _size: ::std::os::raw::c_int,
}
#[test]
+#[cfg(not(target_pointer_width = "32"))]
fn bindgen_test_layout___sbuf() {
assert_eq!(::std::mem::size_of::<__sbuf>() , 16usize);
assert_eq!(::std::mem::align_of::<__sbuf>() , 8usize);
@@ -91,6 +92,7 @@ pub struct __sFILE {
pub _offset: fpos_t,
}
#[test]
+#[cfg(not(target_pointer_width = "32"))]
fn bindgen_test_layout___sFILE() {
assert_eq!(::std::mem::size_of::<__sFILE>() , 152usize);
assert_eq!(::std::mem::align_of::<__sFILE>() , 8usize);
@@ -235,6 +237,7 @@ pub struct pgNotify {
pub next: *mut pgNotify,
}
#[test]
+#[cfg(not(target_pointer_width = "32"))]
fn bindgen_test_layout_pgNotify() {
assert_eq!(::std::mem::size_of::<pgNotify>() , 32usize);
assert_eq!(::std::mem::align_of::<pgNotify>() , 8usize);
@@ -268,6 +271,7 @@ pub struct _PQprintOpt {
pub fieldName: *mut *mut ::std::os::raw::c_char,
}
#[test]
+#[cfg(not(target_pointer_width = "32"))]
fn bindgen_test_layout__PQprintOpt() {
assert_eq!(::std::mem::size_of::<_PQprintOpt>() , 40usize);
assert_eq!(::std::mem::align_of::<_PQprintOpt>() , 8usize);
@@ -288,6 +292,7 @@ pub struct _PQconninfoOption {
pub dispsize: ::std::os::raw::c_int,
}
#[test]
+#[cfg(not(target_pointer_width = "32"))]
fn bindgen_test_layout__PQconninfoOption() {
assert_eq!(::std::mem::size_of::<_PQconninfoOption>() , 56usize);
assert_eq!(::std::mem::align_of::<_PQconninfoOption>() , 8usize);
@@ -311,6 +316,7 @@ pub struct _bindgen_ty_8__bindgen_ty_1 {
pub bindgen_union_field: u64,
}
#[test]
+#[cfg(not(target_arch = "x86"))]
fn bindgen_test_layout__bindgen_ty_8__bindgen_ty_1() {
assert_eq!(::std::mem::size_of::<_bindgen_ty_8__bindgen_ty_1>() , 8usize);
assert_eq!(::std::mem::align_of::<_bindgen_ty_8__bindgen_ty_1>() ,
@@ -340,6 +346,7 @@ pub struct pgresAttDesc {
pub atttypmod: ::std::os::raw::c_int,
}
#[test]
+#[cfg(not(target_pointer_width = "32"))]
fn bindgen_test_layout_pgresAttDesc() {
assert_eq!(::std::mem::size_of::<pgresAttDesc>() , 32usize);
assert_eq!(::std::mem::align_of::<pgresAttDesc>() , 8usize);
@werdahias Again, I'm happy to accept a PR that fixes these tests.
Essentially fixed by https://github.com/sgrif/pq-sys/pull/47 which allows to build your own platform specific bindings. The bundled bindings are meant to support all targets that are tested on CI.