core icon indicating copy to clipboard operation
core copied to clipboard

iroh resp. rocksdb does not compile on android

Open r10s opened this issue 3 years ago • 4 comments

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 avatar Sep 01 '22 09:09 r10s

@r10s what is the NDK version you are building against?

dignifiedquire avatar Sep 01 '22 18:09 dignifiedquire

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

dignifiedquire avatar Sep 01 '22 19:09 dignifiedquire

And for any ndk version > 21 needs a workaround like this: https://github.com/godot-rust/godot-rust/pull/920

dignifiedquire avatar Sep 01 '22 19:09 dignifiedquire

@r10s what is the NDK version you are building against?

just having a look: i am using locally r22b, Dockerimage uses r23c.

r10s avatar Sep 01 '22 19:09 r10s

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

r10s avatar Oct 08 '22 14:10 r10s

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:

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 avatar Oct 08 '22 16:10 r10s

@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?

dignifiedquire avatar Oct 09 '22 10:10 dignifiedquire

@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

dignifiedquire avatar Oct 09 '22 10:10 dignifiedquire

@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.

r10s avatar Oct 09 '22 16:10 r10s

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

fabricedesre avatar Oct 09 '22 17:10 fabricedesre

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.

r10s avatar Dec 05 '22 15:12 r10s

Closing this as #3489 is closed.

link2xt avatar Mar 15 '23 22:03 link2xt