You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.
Building android apps from crates that have native dependencies currently not possible, due to the structure of the toolchains inside Android NDK that has the standard library includes in a separate folder from the toolchain sysroot. For example if i try to use backtrace-rs dependency in my project i get this during build:
error: failed to run custom build command for `backtrace-sys v0.1.24`
process didn't exit successfully: `/home/theartist/Workdir/Charge/target/debug/build/backtrace-sys-60c2d4f631e66e45/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("arm-linux-androideabi")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-unknown-linux-gnu")
CC_arm-linux-androideabi = Some("/opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc")
CFLAGS_arm-linux-androideabi = Some("--sysroot /opt/android-ndk/platforms/android-28/arch-arm")
DEBUG = Some("true")
running: "/opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "--sysroot" "/opt/android-ndk/platforms/android-28/arch-arm" "-g" "-fno-omit-frame-pointer" "-I" "src/libbacktrace" "-I" "/home/theartist/Workdir/Charge/target/arm-linux-androideabi/debug/build/backtrace-sys-f9d57695cf709455/out" "-fvisibility=hidden" "-DBACKTRACE_ELF_SIZE=32" "-DBACKTRACE_SUPPORTED=1" "-DBACKTRACE_USES_MALLOC=1" "-DBACKTRACE_SUPPORTS_THREADS=0" "-DBACKTRACE_SUPPORTS_DATA=0" "-D_GNU_SOURCE=1" "-D_LARGE_FILES=1" "-Dbacktrace_full=__rbt_backtrace_full" "-Dbacktrace_dwarf_add=__rbt_backtrace_dwarf_add" "-Dbacktrace_initialize=__rbt_backtrace_initialize" "-Dbacktrace_pcinfo=__rbt_backtrace_pcinfo" "-Dbacktrace_syminfo=__rbt_backtrace_syminfo" "-Dbacktrace_get_view=__rbt_backtrace_get_view" "-Dbacktrace_release_view=__rbt_backtrace_release_view" "-Dbacktrace_alloc=__rbt_backtrace_alloc" "-Dbacktrace_free=__rbt_backtrace_free" "-Dbacktrace_vector_finish=__rbt_backtrace_vector_finish" "-Dbacktrace_vector_grow=__rbt_backtrace_vector_grow" "-Dbacktrace_vector_release=__rbt_backtrace_vector_release" "-Dbacktrace_close=__rbt_backtrace_close" "-Dbacktrace_open=__rbt_backtrace_open" "-Dbacktrace_print=__rbt_backtrace_print" "-Dbacktrace_simple=__rbt_backtrace_simple" "-Dbacktrace_qsort=__rbt_backtrace_qsort" "-Dbacktrace_create_state=__rbt_backtrace_create_state" "-Dbacktrace_uncompress_zdebug=__rbt_backtrace_uncompress_zdebug" "-o" "/home/theartist/Workdir/Charge/target/arm-linux-androideabi/debug/build/backtrace-sys-f9d57695cf709455/out/src/libbacktrace/alloc.o" "-c" "src/libbacktrace/alloc.c"
cargo:warning=src/libbacktrace/alloc.c:35:19: fatal error: errno.h: No such file or directory
cargo:warning= #include <errno.h>
cargo:warning= ^
cargo:warning=compilation terminated.
exit code: 1
--- stderr
thread 'main' panicked at '
Internal error occurred: Command "/opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "--sysroot" "/opt/android-ndk/platforms/android-28/arch-arm" "-g" "-fno-omit-frame-pointer" "-I" "src/libbacktrace" "-I" "/home/theartist/Workdir/Charge/target/arm-linux-androideabi/debug/build/backtrace-sys-f9d57695cf709455/out" "-fvisibility=hidden" "-DBACKTRACE_ELF_SIZE=32" "-DBACKTRACE_SUPPORTED=1" "-DBACKTRACE_USES_MALLOC=1" "-DBACKTRACE_SUPPORTS_THREADS=0" "-DBACKTRACE_SUPPORTS_DATA=0" "-D_GNU_SOURCE=1" "-D_LARGE_FILES=1" "-Dbacktrace_full=__rbt_backtrace_full" "-Dbacktrace_dwarf_add=__rbt_backtrace_dwarf_add" "-Dbacktrace_initialize=__rbt_backtrace_initialize" "-Dbacktrace_pcinfo=__rbt_backtrace_pcinfo" "-Dbacktrace_syminfo=__rbt_backtrace_syminfo" "-Dbacktrace_get_view=__rbt_backtrace_get_view" "-Dbacktrace_release_view=__rbt_backtrace_release_view" "-Dbacktrace_alloc=__rbt_backtrace_alloc" "-Dbacktrace_free=__rbt_backtrace_free" "-Dbacktrace_vector_finish=__rbt_backtrace_vector_finish" "-Dbacktrace_vector_grow=__rbt_backtrace_vector_grow" "-Dbacktrace_vector_release=__rbt_backtrace_vector_release" "-Dbacktrace_close=__rbt_backtrace_close" "-Dbacktrace_open=__rbt_backtrace_open" "-Dbacktrace_print=__rbt_backtrace_print" "-Dbacktrace_simple=__rbt_backtrace_simple" "-Dbacktrace_qsort=__rbt_backtrace_qsort" "-Dbacktrace_create_state=__rbt_backtrace_create_state" "-Dbacktrace_uncompress_zdebug=__rbt_backtrace_uncompress_zdebug" "-o" "/home/theartist/Workdir/Charge/target/arm-linux-androideabi/debug/build/backtrace-sys-f9d57695cf709455/out/src/libbacktrace/alloc.o" "-c" "src/libbacktrace/alloc.c" with args "arm-linux-androideabi-gcc" did not execute successfully (status code exit code: 1).
', /home/theartist/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/cc-1.0.25/src/lib.rs:2260:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Build failed, waiting for other jobs to finish...
error: build failed
After lots of inspection, i found out that the exported variables here: https://github.com/tomaka/android-rs-glue/blob/master/cargo-apk/src/ops/build.rs#L197 are picked up and used by the cc crate that is used to build the native components of backtrace-rs (backtrace-sys).
NDK though, has the standard include headers in different directory than the platform specific one that is passed as a parameter to --sysroot.
Proposed solution is to add to the set env vars the -isysroot flag that points to the $NDK_HOME/sysroot dir that contains the unified headers path, along with a -isystem flag that points to the architecture specific includes (needed by the unified headers) that reside here: $NDK_HOME/sysroot/usr/include/<target_arch>
Building android apps from crates that have native dependencies currently not possible, due to the structure of the toolchains inside Android NDK that has the standard library includes in a separate folder from the toolchain sysroot. For example if i try to use backtrace-rs dependency in my project i get this during build:
After lots of inspection, i found out that the exported variables here:
https://github.com/tomaka/android-rs-glue/blob/master/cargo-apk/src/ops/build.rs#L197 are picked up and used by the
cc
crate that is used to build the native components of backtrace-rs (backtrace-sys).NDK though, has the standard include headers in different directory than the platform specific one that is passed as a parameter to --sysroot.
Proposed solution is to add to the set env vars the
-isysroot
flag that points to the$NDK_HOME/sysroot
dir that contains the unified headers path, along with a-isystem
flag that points to the architecture specific includes (needed by the unified headers) that reside here:$NDK_HOME/sysroot/usr/include/<target_arch>
I'm prepping a PR for this.
EDIT:
Added #186
The text was updated successfully, but these errors were encountered: