Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Compilation for Android x86 fails #345

Closed
vmx opened this issue Mar 29, 2017 · 5 comments
Closed

Compilation for Android x86 fails #345

vmx opened this issue Mar 29, 2017 · 5 comments

Comments

@vmx
Copy link

vmx commented Mar 29, 2017

I tried to compile rust-mozjs for Android x86. It fails with the error below. I suspect that there's a mismatch between the platform headers and the actual platform. On Android x86 c_char is i8 on ARM it's u8.

I have no clue, why it would expect an ARM-stlye u8 although I compile for x86. I'm happy to work on a fix if anyone tells me where to look.

$ PATH=$PATH:/home/vmx/src/rust/android/android-24-toolchain-x86/bin ANDROID_NDK=/home/vmx/src/rust/android/android-ndk-r12b cargo build --target i686-linux-android --verbose
       Fresh log v0.3.7
       Fresh num-traits v0.1.37
       Fresh lazy_static v0.2.5
       Fresh gcc v0.3.45
       Fresh libc v0.2.21
       Fresh pkg-config v0.3.9
       Fresh cmake v0.1.22
       Fresh heapsize v0.3.9
       Fresh libz-sys v1.0.13
       Fresh mozjs_sys v0.0.0 (https:/servo/mozjs#98c3df63)
   Compiling js v0.1.4 (file:///tmp/rust-mozjs)
     Running `rustc --crate-name js src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=bf95172d2256808a -C extra-filename=-bf95172d2256808a --out-dir /tmp/rust-mozjs/target/i686-linux-android/debug/deps --target i686-linux-android -C ar=/home/vmx/src/rust/android/android-24-toolchain-x86/bin/i686-linux-android-ar -C linker=/home/vmx/src/rust/android/android-24-toolchain-x86/bin/i686-linux-android-gcc -L dependency=/tmp/rust-mozjs/target/i686-linux-android/debug/deps -L dependency=/tmp/rust-mozjs/target/debug/deps --extern lazy_static=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/liblazy_static-6512ce482ce46607.rlib --extern num_traits=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/libnum_traits-69f4129d46397118.rlib --extern mozjs_sys=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/libmozjs_sys-97826a5d9cd703db.rlib --extern log=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/liblog-d4c0e5c2504fbbea.rlib --extern heapsize=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/libheapsize-a0ca106bb4f4bbb6.rlib --extern libc=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/liblibc-5dc7b85e748840b4.rlib -L native=/tmp/rust-mozjs/target/i686-linux-android/debug/build/js-62abd7c6dbea0549/out/lib -l static=jsglue -L native=/tmp/rust-mozjs/target/i686-linux-android/debug/build/mozjs_sys-2cecbe7697181d13/out/js/src`
error[E0308]: mismatched types
  --> src/error.rs:24:11
   |
24 |     name: b"RUSTMSG_TYPE_ERROR\0" as *const _ as *const libc::c_char,
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u8, found i8
   |
   = help: here are some functions which might fulfill your needs:
           - .offset(...)
           - .wrapping_offset(...)

error[E0308]: mismatched types
  --> src/error.rs:25:13
   |
25 |     format: &ERROR_FORMAT_STRING_STRING as *const libc::c_char,
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u8, found i8
   |
   = help: here are some functions which might fulfill your needs:
           - .offset(...)
           - .wrapping_offset(...)

error[E0308]: mismatched types
  --> src/error.rs:32:11
   |
32 |     name: b"RUSTMSG_RANGE_ERROR\0" as *const _ as *const libc::c_char,
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u8, found i8
   |
   = help: here are some functions which might fulfill your needs:
           - .offset(...)
           - .wrapping_offset(...)

error[E0308]: mismatched types
  --> src/error.rs:33:13
   |
33 |     format: &ERROR_FORMAT_STRING_STRING as *const libc::c_char,
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u8, found i8
   |
   = help: here are some functions which might fulfill your needs:
           - .offset(...)
           - .wrapping_offset(...)

error: aborting due to 4 previous errors

error: Could not compile `js`.

Caused by:
  process didn't exit successfully: `rustc --crate-name js src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=bf95172d2256808a -C extra-filename=-bf95172d2256808a --out-dir /tmp/rust-mozjs/target/i686-linux-android/debug/deps --target i686-linux-android -C ar=/home/vmx/src/rust/android/android-24-toolchain-x86/bin/i686-linux-android-ar -C linker=/home/vmx/src/rust/android/android-24-toolchain-x86/bin/i686-linux-android-gcc -L dependency=/tmp/rust-mozjs/target/i686-linux-android/debug/deps -L dependency=/tmp/rust-mozjs/target/debug/deps --extern lazy_static=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/liblazy_static-6512ce482ce46607.rlib --extern num_traits=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/libnum_traits-69f4129d46397118.rlib --extern mozjs_sys=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/libmozjs_sys-97826a5d9cd703db.rlib --extern log=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/liblog-d4c0e5c2504fbbea.rlib --extern heapsize=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/libheapsize-a0ca106bb4f4bbb6.rlib --extern libc=/tmp/rust-mozjs/target/i686-linux-android/debug/deps/liblibc-5dc7b85e748840b4.rlib -L native=/tmp/rust-mozjs/target/i686-linux-android/debug/build/js-62abd7c6dbea0549/out/lib -l static=jsglue -L native=/tmp/rust-mozjs/target/i686-linux-android/debug/build/mozjs_sys-2cecbe7697181d13/out/js/src` (exit code: 101)
@jdm
Copy link
Member

jdm commented Mar 29, 2017

The issue is that the generated bindings use std::os::raw::c_char, and our code uses libc::c_char. In the past these types have been identical, and now they are not for some reason. rust-lang/rust#40317 just merged four days ago, so rust-mozjs requires a more recent nightly version in order to avoid this problem. For Servo, this can be addressed by updating the contents of the rust-commit-hash file to make the build system use the given compiler version.

@vmx
Copy link
Author

vmx commented Mar 29, 2017

I've updated rust via rustup, my system is now on

nightly-x86_64-unknown-linux-gnu updated - rustc 1.17.0-nightly (ccce2c6eb 2017-03-27)

Which is after the commit rust-lang/rust@24be899 mentioned above. The error is still the same.

@jdm
Copy link
Member

jdm commented Mar 30, 2017

Unless you are building rust-mozjs standalone, your local compiler (as updated by rustup) has no effect on the Servo build system. Are you building Servo (via ./mach build), or rust-mozjs (via cargo build)?

@vmx
Copy link
Author

vmx commented Mar 30, 2017

I'm building rust-mozjs standalone (it's all I care about atm). See the exact command I'm building with on the original bug description.

@vmx
Copy link
Author

vmx commented Mar 30, 2017

It builds now. My nightly build wasn't recent enough as as fix got merged with rust-lang/rust#40867 just two days ago. Another rustup update got me to version rustc 1.17.0-nightly (e1cec5d4b 2017-03-29) which is recent enough. Thanks @jdm for finding that out.

@vmx vmx closed this as completed Mar 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants