-
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
android JNINativeMethod wrong size #942
Comments
Looks a lot like you're generating methods for a 64-bit target and compiling with a 32-bit target. |
Have you tried passing the target down to libclang using |
I tried this: //build.rs
let target = env::var("TARGET").unwrap();
let generated_bindings = bindings
.clang_arg(format!("-target {}", target))
.generate()
.map_err(|_| "Failed to generate bindings".to_string())?; got this:
|
I was able to fix issue with .clang_arg(format!("--target={}", target)) but for some reason with pub type __va_list = __builtin_va_list;
pub struct __va_list {
pub __ap: *mut ::std::os::raw::c_void,
} and resulted code not compiled, as you see I do not use Android #include <sys/cdefs.h>
#include <stdarg.h> at start of So here is two issues:
|
The difference between //no --target=
pub type __builtin_va_list = [__va_list_tag; 1usize];
#[repr(C)]
#[derive(Debug, Copy)]
pub struct __va_list_tag {
pub gp_offset: ::std::os::raw::c_uint,
pub fp_offset: ::std::os::raw::c_uint,
pub overflow_arg_area: *mut ::std::os::raw::c_void,
pub reg_save_area: *mut ::std::os::raw::c_void,
}
//with --target=
pub type __builtin_va_list = __va_list;
#[repr(C)]
#[derive(Debug, Copy)]
pub struct __va_list {
pub __ap: *mut ::std::os::raw::c_void,
} |
Here difference difference of --- __bindgen.i 2017-09-03 14:14:27.780836405 +0300
+++ __bindgen-bad.i 2017-09-03 14:14:08.600835491 +0300
@@ -1,7 +1,7 @@
# 1 "__bindgen.c"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
-# 322 "<built-in>" 3
+# 320 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "./bitmap.h" 1
@@ -484,7 +484,7 @@
/* Define this type if we are doing the whole job,
or if we want this type in particular. */
# 147 "/home/evgeniy/toolchains/android-16-arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x/include/stddef.h"
-typedef long int ptrdiff_t;
+typedef int ptrdiff_t;
# 157 "/home/evgeniy/toolchains/android-16-arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x/include/stddef.h"
/* If this symbol has done its job, get rid of it. */
@@ -496,7 +496,7 @@
/* Define this type if we are doing the whole job,
or if we want this type in particular. */
# 212 "/home/evgeniy/toolchains/android-16-arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x/include/stddef.h"
-typedef long unsigned int size_t;
+typedef unsigned int size_t;
# 238 "/home/evgeniy/toolchains/android-16-arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x/include/stddef.h"
/* Wide character type.
Locale-writers should change this as necessary to
@@ -521,7 +521,7 @@
since it no longer defines _BSD_RUNE_T_ yet still desires to export
rune_t in some cases... */
# 324 "/home/evgeniy/toolchains/android-16-arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x/include/stddef.h"
-typedef int wchar_t;
+typedef unsigned int wchar_t;
# 358 "/home/evgeniy/toolchains/android-16-arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x/include/stddef.h"
/* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
are already defined. */
@@ -784,8 +784,11 @@
*/
-typedef long intptr_t;
-typedef unsigned long uintptr_t;
+
+
+
+typedef int intptr_t;
+typedef unsigned int uintptr_t;
# 216 "/home/evgeniy/toolchains/android-16-arm-linux-androideabi-4.9/bin/../sysroot/usr/include/stdint.h"
/*
* intmax_t & uintmax_t |
Reduced tes case:
//from include/machine/_types.h from sys/_types.h from stdint.h
typedef __builtin_va_list __va_list; $ bindgen --version
bindgen 0.30.0
$ bindgen --no-layout-tests bitmap.h
/* automatically generated by rust-bindgen */
pub type __va_list = __builtin_va_list;
pub type __builtin_va_list = [__va_list_tag; 1usize];
#[repr(C)]
#[derive(Debug, Copy)]
pub struct __va_list_tag {
pub gp_offset: ::std::os::raw::c_uint,
pub fp_offset: ::std::os::raw::c_uint,
pub overflow_arg_area: *mut ::std::os::raw::c_void,
pub reg_save_area: *mut ::std::os::raw::c_void,
}
impl Clone for __va_list_tag {
fn clone(&self) -> Self { *self }
}
$ bindgen --no-layout-tests bitmap.h -- --target=arm-linux-androideabi
/* automatically generated by rust-bindgen */
pub type __va_list = __builtin_va_list;
pub type __builtin_va_list = __va_list;
#[repr(C)]
#[derive(Debug, Copy)]
pub struct __va_list {
pub __ap: *mut ::std::os::raw::c_void,
}
impl Clone for __va_list {
fn clone(&self) -> Self { *self }
}
|
I suppose |
Just wanted to note, that I experienced same problem with the Emscripten (see #947 (comment)) This worked for me as well: // build.rs
let target = env::var("TARGET").unwrap();
let generated_bindings = bindings
.clang_arg(format!("--target={}", target))
.generate() |
Input C/C++ Header
Bindgen Invocation
Actual Results
Expected Results
I compile on linux/amd64 for arm-linux-androideabi.
If I run generated by bindgen unit tests I got:
Test that failed:
The text was updated successfully, but these errors were encountered: