iroh resp. rocksdb does not compile on android
trying to build https://github.com/deltachat/deltachat-core-rust/pull/3489 on android leads to different errors:
for "arm64-v8a" and "x86_64" (though printed as a "warning", compiling is aborted with an error):
cargo:warning=rocksdb/env/io_posix.cc:1001:41: error: use of undeclared identifier 'POSIX_MADV_NORMAL'
cargo:warning= Madvise(mmapped_region_, length_, POSIX_MADV_NORMAL);
cargo:warning= ^
cargo:warning=rocksdb/env/io_posix.cc:1004:41: error: use of undeclared identifier 'POSIX_MADV_RANDOM'
cargo:warning= Madvise(mmapped_region_, length_, POSIX_MADV_RANDOM);
cargo:warning= ^
cargo:warning=rocksdb/env/io_posix.cc:1007:41: error: use of undeclared identifier 'POSIX_MADV_SEQUENTIAL'
cargo:warning= Madvise(mmapped_region_, length_, POSIX_MADV_SEQUENTIAL);
cargo:warning= ^
cargo:warning=rocksdb/env/io_posix.cc:1010:41: error: use of undeclared identifier 'POSIX_MADV_WILLNEED'
cargo:warning= Madvise(mmapped_region_, length_, POSIX_MADV_WILLNEED);
cargo:warning= ^
cargo:warning=rocksdb/env/io_posix.cc:1013:41: error: use of undeclared identifier 'POSIX_MADV_DONTNEED'
cargo:warning= Madvise(mmapped_region_, length_, POSIX_MADV_DONTNEED);
cargo:warning= ^
cargo:warning=5 errors generated.
exit status: 0
exit status: 1
for "armv7-linux-androideabi (arm)" and "i686-linux-android (x86)"
cargo:warning=In file included from rocksdb/cache/cache_key.cc:13:
cargo:warning=In file included from rocksdb/util/hash.h:26:
cargo:warning=rocksdb/util/fastrange.h:62:5: error: unknown type name '__uint128_t'
cargo:warning= __uint128_t wide = __uint128_t{range} * hash;
cargo:warning= ^
cargo:warning=rocksdb/util/fastrange.h:62:24: error: use of undeclared identifier '__uint128_t'
cargo:warning= __uint128_t wide = __uint128_t{range} * hash;
cargo:warning= ^
cargo:warning=rocksdb/util/fastrange.h:62:35: error: expected ';' at end of declaration
cargo:warning= __uint128_t wide = __uint128_t{range} * hash;
cargo:warning= ^
cargo:warning= ;
cargo:warning=3 errors generated.
exit status: 1
~~not sure yet if x86-32bit builds on android.~~ EDIT: it does not, i added these targets above.
@r10s what is the NDK version you are building against?
I got it to build by setting the following things
TARGET_CC=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android28-clang \
CC=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android28-clang \
CXX=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android28-clang++ \
cargo build --target x86_64-linux-android -p deltachat_ffi --features vendored
And for any ndk version > 21 needs a workaround like this: https://github.com/godot-rust/godot-rust/pull/920
@r10s what is the NDK version you are building against?
just having a look: i am using locally r22b, Dockerimage uses r23c.
And for any ndk version > 21 needs a workaround like this: https://github.com/godot-rust/godot-rust/pull/920
that seems to be already done at https://github.com/deltachat/deltachat-android/blob/master/scripts/ndk-make.sh#L95
I got it to build by setting the following things
TARGET_CC=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android28-clang
CC=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android28-clang
CXX=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android28-clang++
cargo build --target x86_64-linux-android -p deltachat_ffi --features vendored
k, stepping away from ./scripts/ndk-make.sh for a moment.
i tried the following:
-
cd jni/deltachat-core-rust - executing the command from above (with paths adapted to local mac environment)
compiling seem to run through for that target, so, some tiny steps, but linking throws the error:
= note: ld: unknown option: --version-script=/var/folders/24/mxfz55k547g94mql66v050ww0000gn/T/rustcaUsENY/list
clang: error: linker command failed with exit code 1 (use -v to see invocation)
wondering, where the option --version-script is set.
@r10s unclear to me where that is coming from either for me, looks like an option that is not available on macos/clangd. Can you build master with that command cleanly?
@r10s thanks to @fabricedesre I got this script which he uses to build his projects including iroh for android phones https://gist.github.com/dignifiedquire/6d9dc7c6efff2c68e430aa700d1a2e62
@r10s unclear to me where that is coming from either for me, looks like an option that is not available on macos/clangd. Can you build master with that command cleanly?
good aspect to test - and indeed building with command from above on master throws the same error for me on macos.
but i double checked ./ndk-make.sh on current master and recent iroh-share pr - the latter still fails with errors as initially shown.
fyi, we updated the build config for iroh to work on the ndk r25b. Relevant changes are setting AR and the linker:
https://github.com/capyloon/iroh/blob/e5a8a19435ab1ac2c833a4d432148bb86a958a1d/iroh-one/utils.sh#L85 https://github.com/capyloon/iroh/blob/e5a8a19435ab1ac2c833a4d432148bb86a958a1d/iroh-one/utils.sh#L178
some issues might also be related to the new toolchain, master was just updated to rust 1.65, so, let's see if master compiles and android now.
Closing this as #3489 is closed.