Skip to content
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

cross compiling to linux android #66

Closed
jianshu93 opened this issue Aug 6, 2024 · 10 comments
Closed

cross compiling to linux android #66

jianshu93 opened this issue Aug 6, 2024 · 10 comments

Comments

@jianshu93
Copy link

Hi @jguhlin,

I am not sure whether this is interesting to others but I want to report here. I was trying to import and compile many Rust software packages to Linux-based android device so that we can run them on phones for a mobile bioinformatic era (CPU for phones are now quite powerful, like SnapDragon 3 generation). For pure Rust based packages, I have no problems for example, my GSearch crate, sourmash crate, rust-mDBG crate and many others. However, when I was trying to compiling minimap2-rs, there are tons of problems:

install android studio first and deploy it for rust in .bash_profile like this:

android compiling and ld library

export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="/Users/jianshuzhao/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android35-clang"
export CXX_aarch64_linux_android="/Users/jianshuzhao/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android35-clang++"
export CC_aarch64_linux_android="/Users/jianshuzhao/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android35-clang"
export AR_aarch64_linux_android="/Users/jianshuzhao/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"

$ rustup target add aarch64-linux-android
$ cargo build --target aarch64-linux-android --release

error: linking with /Users/jianshuzhao/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android35-clang failed: exit status: 1
|
= note: LC_ALL="C" PATH="/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/Users/jianshuzhao/Github/SPAdes-4.0.0-Darwin/bin:/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin:/usr/local/bin:/opt/homebrew/bin:/Users/jianshuzhao/bin:/opt/homebrew/opt/bzip2/bin:/Users/jianshuzhao/Github/mummer-4.0.0beta5/bin:/Users/jianshuzhao/go/bin:/Users/jianshuzhao/Github/hmmer-3.4/bin:/opt/homebrew/opt/llvm/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/Cellar/coreutils/9.1/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jianshuzhao/Github/SPAdes-4.0.0-Darwin/bin:/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin:/usr/local/bin:/opt/homebrew/bin:/Users/jianshuzhao/bin:/opt/homebrew/opt/bzip2/bin:/Users/jianshuzhao/Github/mummer-4.0.0beta5/bin:/Users/jianshuzhao/go/bin:/Users/jianshuzhao/Github/hmmer-3.4/bin:/opt/homebrew/opt/llvm/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/Cellar/coreutils/9.1/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jianshuzhao/Github/SPAdes-4.0.0-Darwin/bin:/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin:/usr/local/bin:/opt/homebrew/bin:/Users/jianshuzhao/bin:/opt/homebrew/opt/bzip2/bin:/Users/jianshuzhao/Github/mummer-4.0.0beta5/bin:/Users/jianshuzhao/go/bin:/Users/jianshuzhao/Github/hmmer-3.4/bin:/opt/homebrew/opt/llvm/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/Cellar/coreutils/9.1/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jianshuzhao/Github/SPAdes-4.0.0-Darwin/bin:/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin:/usr/local/bin:/opt/homebrew/bin:/Users/jianshuzhao/bin:/opt/homebrew/opt/bzip2/bin:/Users/jianshuzhao/Github/mummer-4.0.0beta5/bin:/Users/jianshuzhao/go/bin:/Users/jianshuzhao/Github/hmmer-3.4/bin:/opt/homebrew/opt/llvm/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/Cellar/coreutils/9.1/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jianshuzhao/Github/SPAdes-4.0.0-Darwin/bin:/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin:/usr/local/bin:/opt/homebrew/bin:/Users/jianshuzhao/bin:/opt/homebrew/opt/bzip2/bin:/Users/jianshuzhao/Github/mummer-4.0.0beta5/bin:/Users/jianshuzhao/go/bin:/Users/jianshuzhao/Github/hmmer-3.4/bin:/opt/homebrew/opt/llvm/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/Cellar/coreutils/9.1/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jianshuzhao/Github/SPAdes-4.0.0-Darwin/bin:/Users/jianshuzhao/.cargo/bin:/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin:/Users/jianshuzhao/perl5/bin:/usr/local/bin:/opt/homebrew/bin:/Users/jianshuzhao/bin:/opt/homebrew/opt/bzip2/bin:/Users/jianshuzhao/Github/mummer-4.0.0beta5/bin:/Users/jianshuzhao/go/bin:/Users/jianshuzhao/Github/hmmer-3.4/bin:/opt/homebrew/opt/llvm/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/Cellar/coreutils/9.1/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/TeX/texbin:/usr/local/go/bin" VSLANG="1033" "/Users/jianshuzhao/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android35-clang" "-Wl,--version-script=/var/folders/mr/8qybn91j5fgdbrcdmq7ckftw0000gn/T/rustcOO9CIw/list" "-Wl,--no-undefined-version" "/var/folders/mr/8qybn91j5fgdbrcdmq7ckftw0000gn/T/rustcOO9CIw/symbols.o" "/Users/jianshuzhao/Github/minimap2-rs-test/target/aarch64-linux-android/release/deps/minimap2_sys-48223b1ce1d5498d.minimap2_sys.49addbfa3dae579b-cgu.0.rcgu.o" "/Users/jianshuzhao/Github/minimap2-rs-test/target/aarch64-linux-android/release/deps/minimap2_sys-48223b1ce1d5498d.035gy82oxncw2556qjxih17mk.rcgu.o" "-Wl,--as-needed" "-Wl,-Bdynamic" "-lm" "-lpthread" "-Wl,-Bstatic" "-llibminimap" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libstd-e8850eccf2f3dd32.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libpanic_unwind-a094c6be714bf5e8.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libobject-bd105c046d7d3f4a.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libmemchr-b65977fbd4d13b26.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libaddr2line-c59b235c1428dacb.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libgimli-4dc541cf9acc0f28.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/librustc_demangle-fcbcb6953c2582a4.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libstd_detect-a5c6c9bf9652d1e7.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libhashbrown-402a49b850a42e97.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/librustc_std_workspace_alloc-19962e45d6dd8556.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libminiz_oxide-778d7232beb22b27.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libadler-ce6b56ec013571c3.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libunwind-7757d29c205c9e38.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libcfg_if-439f5a2fb94b85f2.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/liblibc-cbc1d2077079a2d7.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/liballoc-cbbe8b3cfeaabbd2.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/librustc_std_workspace_core-d80ded003c259869.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libcore-556f2758be89c720.rlib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-linux-android/lib/libcompiler_builtins-bb1d92eb991222e1.rlib" "-Wl,-Bdynamic" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/Users/jianshuzhao/Github/minimap2-rs-test/target/aarch64-linux-android/release/build/minimap2-sys-47359202de654a64/out" "-o" "/Users/jianshuzhao/Github/minimap2-rs-test/target/aarch64-linux-android/release/deps/libminimap2_sys-48223b1ce1d5498d.so" "-Wl,--gc-sections" "-shared" "-Wl,-soname=libminimap2_sys-48223b1ce1d5498d.so" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs"
= note: ld.lld: error: unable to find library -lpthread
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The following warnings were emitted during compilation:

warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]

I can see that android clang does not support -lpthread, which is only for linux. However the android libc (bionic) does support many pthread functions: In Android, all pthread functionality is directly available through the Bionic libc without requiring explicit linking. This means that while you can use pthread functions like pthread_create or pthread_mutex_init, you don't add -lpthread to your linker flags.

I am wondering whther it is possible to add a conditional compiling for android devices so that -phthread is not used but it is actually functioning.

I also want to hear how @lh3 thinks, #63 (comment)_

Thanks,

Jianshu

jguhlin added a commit that referenced this issue Aug 7, 2024
Works with cross build --target aarch64-linux-android

Initial work on #66
@jguhlin
Copy link
Owner

jguhlin commented Aug 7, 2024

@jianshu93 I've created an android branch, can you try to compile it and run tests?

minimap2-sys compiles just fine, but the main crate is complaining about missing libz.so, but I believe it is in the NDK (I'm just using cross to compile).

Let me know how you get on.

@jianshu93
Copy link
Author

jianshu93 commented Aug 7, 2024

Hi @jguhlin,

I just tested, it was successful. Maybe we need some code cleaning for the new Rust v1.82? I attached the building and test:

warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
warning: minimap2-sys@0.1.19+minimap2.2.28: clang: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
warning: extern block uses type u128, which is not FFI-safe
--> minimap2-sys/src/bindings.rs:7242:10
|
7242 | ) -> u128;
| ^^^^ not FFI-safe
|
= note: 128-bit integers don't currently have a known stable ABI
= note: #[warn(improper_ctypes)] on by default

warning: extern block uses type u128, which is not FFI-safe
--> minimap2-sys/src/bindings.rs:7787:18
|
7787 | __value: u128,
| ^^^^ not FFI-safe
|
= note: 128-bit integers don't currently have a known stable ABI

warning: extern block uses type u128, which is not FFI-safe
--> minimap2-sys/src/bindings.rs:7795:18
|
7795 | __value: u128,
| ^^^^ not FFI-safe
|
= note: 128-bit integers don't currently have a known stable ABI

warning: extern block uses type u128, which is not FFI-safe
--> minimap2-sys/src/bindings.rs:7803:18
|
7803 | __value: u128,
| ^^^^ not FFI-safe
|
= note: 128-bit integers don't currently have a known stable ABI

warning: extern block uses type u128, which is not FFI-safe
--> minimap2-sys/src/bindings.rs:7830:18
|
7830 | __value: u128,
| ^^^^ not FFI-safe
|
= note: 128-bit integers don't currently have a known stable ABI

warning: extern block uses type u128, which is not FFI-safe
--> minimap2-sys/src/bindings.rs:7840:18
|
7840 | __value: u128,
| ^^^^ not FFI-safe
|
= note: 128-bit integers don't currently have a known stable ABI

warning: minimap2-sys (lib) generated 6 warnings
Compiling minimap2 v0.1.20+minimap2.2.28 (/Users/jianshuzhao/minimap2-rs-android)
warning: unused variable: aligner
--> src/lib.rs:1145:13
|
1145 | let aligner = jh.join().unwrap();
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: _aligner
|
= note: #[warn(unused_variables)] on by default

warning: unused variable: jh0
--> src/lib.rs:1174:13
|
1174 | let jh0 = thread::spawn(move || {
| ^^^ help: if this is intentional, prefix it with an underscore: _jh0

warning: unused variable: jh1
--> src/lib.rs:1182:13
|
1182 | let jh1 = thread::spawn(move || {
| ^^^ help: if this is intentional, prefix it with an underscore: _jh1

warning: unused variable: results
--> src/lib.rs:1220:13
|
1220 | let results = sequences
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: _results

warning: unused variable: x
--> src/lib.rs:1240:13
|
1240 | let x: IdxOpt = Default::default();
| ^ help: if this is intentional, prefix it with an underscore: _x

warning: unused variable: x
--> src/lib.rs:1245:13
|
1245 | let x: mm_mapopt_t = Default::default();
| ^ help: if this is intentional, prefix it with an underscore: _x

warning: unused variable: y
--> src/lib.rs:1246:13
|
1246 | let y: MapOpt = Default::default();
| ^ help: if this is intentional, prefix it with an underscore: _y

warning: unused variable: aligner
--> src/lib.rs:1259:13
|
1259 | let aligner = Aligner {
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: _aligner

warning: unused variable: result
--> src/lib.rs:1271:13
|
1271 | let result = Aligner::builder();
| ^^^^^^ help: if this is intentional, prefix it with an underscore: _result

warning: unused variable: result
--> src/lib.rs:1276:13
|
1276 | let result = Aligner::builder().preset(Preset::LrHq);
| ^^^^^^ help: if this is intentional, prefix it with an underscore: _result

warning: unused variable: result
--> src/lib.rs:1281:13
|
1281 | let result = Aligner::builder()
| ^^^^^^ help: if this is intentional, prefix it with an underscore: _result

warning: value assigned to aligner is never read
--> src/lib.rs:1308:9
|
1308 | aligner = aligner
| ^^^^^^^
|
= help: maybe it is overwritten before being read?
= note: #[warn(unused_assignments)] on by default

warning: variable does not need to be mutable
--> src/lib.rs:1346:13
|
1346 | let mut aligner = aligner.with_cigar();
| ----^^^^^^^
| |
| help: remove this mut
|
= note: #[warn(unused_mut)] on by default

warning: unused variable: observed
--> src/lib.rs:1486:13
|
1486 | let observed = mappings.pop().unwrap();
| ^^^^^^^^ help: if this is intentional, prefix it with an underscore: _observed

warning: unused variable: aligner
--> src/lib.rs:1751:13
|
1751 | let aligner = Aligner {
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: _aligner

warning: minimap2 (lib test) generated 15 warnings (run cargo fix --lib -p minimap2 --tests to apply 1 suggestion)
Finished test profile [unoptimized + debuginfo] target(s) in 4.12s
Running unittests src/lib.rs (target/debug/deps/minimap2-c3d14460ee9a74ce)

running 23 tests
test tests::aligner_builder ... ok
test tests::aligner_builder_preset ... ok
test tests::aligner_builder_preset_with_threads ... ok
test tests::aligner_build_manually ... ok
test tests::does_it_work ... ok
test tests::create_index_file_missing ... ok
test tests::mapopt ... ok
test tests::idxopt ... ok
test tests::test_builder ... ok
test tests::test_send ... ok
test tests::test_strand_struct ... ok
test tests::test_struct_config ... ok
test tests::test_threadlocalbuffer ... ok
test tests::create_index ... ok
test tests::test_mappy_output_no_md ... ok
test tests::test_mappy_output ... ok
test tests::test_aligner_config_and_mapping ... ok
test tests::test_with_seq ... ok
test tests::test_aligner_struct ... ok
test tests::shared_aligner ... ok
test tests::test_mapping ... ok
test tests::rayon ... ok
test tests::aligner_between_threads ... ok

test result: ok. 23 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.19s

Doc-tests minimap2

running 23 tests
test src/lib.rs - (line 22) - compile ... ok
test src/lib.rs - Aligner::cdna (line 474) ... ok
test src/lib.rs - Aligner::asm10 (line 385) ... ok
test src/lib.rs - Aligner::ava_ont (line 447) ... ok
test src/lib.rs - Aligner::asm (line 368) ... ok
test src/lib.rs - Aligner (line 289) ... ok
test src/lib.rs - Aligner::asm20 (line 393) ... ok
test src/lib.rs - Aligner::ava_pb (line 438) ... ok
test src/lib.rs - Aligner::asm5 (line 377) ... ok
test src/lib.rs - Aligner::map10k (line 465) ... ok
test src/lib.rs - (line 38) - compile ... ok
test src/lib.rs - Aligner::map_hifi (line 420) ... ok
test src/lib.rs - Aligner::splice (line 350) ... ok
test src/lib.rs - Aligner::map_pb (line 411) ... ok
test src/lib.rs - Aligner::splice_hq (line 359) ... ok
test src/lib.rs - Aligner::with_index (line 562) ... ok
test src/lib.rs - Aligner::sr (line 402) ... ok
test src/lib.rs - Aligner::short (line 456) ... ok
test src/lib.rs - Aligner::map_ont (line 429) ... ok
test src/lib.rs - Aligner::with_index_threads (line 535) ... ok
test src/lib.rs - Aligner::with_cigar (line 500) ... ok
test src/lib.rs - Aligner::with_seq_and_id (line 666) ... ok
test src/lib.rs - Aligner::with_seq (line 648) ... ok

test result: ok. 23 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.42s

Thanks so much! let me know how I can use it when adding to crate.io (e.g., a feature?)

Thanks,

Jianshu

@jianshu93
Copy link
Author

Hi @jguhlin,

Check this for compiling with easy: https://github.com/BrainiumLLC/cargo-mobile

I still manually setup android studio toolchain path but this may be more convenient.

Thanks,

Jianshu

@jguhlin
Copy link
Owner

jguhlin commented Aug 7, 2024

@jianshu93 For now use the branch. Later it won't need a feature (probably). I don't want to merge this until I can get the tests to run using cross.

@jianshu93
Copy link
Author

Hi @jguhlin,

I forget to mention, you also need to configure the cargo configure file under ~/.cargo/config.toml:

[target.aarch64-linux-android]
linker = "/Users/jianshuzhao/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android35-clang"
ar = "/Users/jianshuzhao/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"

Tell the linker to use android studio provided clang. Not sure how this can be integrated.

@jianshu93
Copy link
Author

jianshu93 commented Aug 8, 2024

Also, the test module, binary is for android, we cannot run the binary to test right. I ran cargo test --target aarch64-linux-android, it told me that the binary cannot be executed:
Finished test profile [unoptimized + debuginfo] target(s) in 3.24s
Running unittests src/lib.rs (target/aarch64-linux-android/debug/deps/minimap2-69620e4f80f97be4)
/Users/jianshuzhao/Github/minimap2-rs-android/target/aarch64-linux-android/debug/deps/minimap2-69620e4f80f97be4: /Users/jianshuzhao/Github/minimap2-rs-android/target/aarch64-linux-android/debug/deps/minimap2-69620e4f80f97be4: cannot execute binary file
error: test failed, to rerun pass --lib

Caused by:
process didn't exit successfully: /Users/jianshuzhao/Github/minimap2-rs-android/target/aarch64-linux-android/debug/deps/minimap2-69620e4f80f97be4 (exit status: 126)
note: test exited abnormally; to see the full output pass --nocapture to the harness.

Thanks,

Jianshu

@jguhlin
Copy link
Owner

jguhlin commented Aug 8, 2024

@jianshu93

I've opened up a discussion on cross here: cross-rs/cross#1537

For not being able to run the binary, is it the same architecture? aarch64 and the machine you are running on? That's probably the error you are receiving. You could run qemu-aarch64 to emulate aarch64.

I'm using these commands to test:

cross test --target aarch64-unknown-linux-musl 
cross test --target x86_64-unknown-linux-musl
cross test --target aarch64-linux-android
cross test --target x86_64-linux-android
cross test --target armv7-linux-androideabi

The first two work, the rest do not. Hopefully someone will have some insight and we can merge into the main branch

It looks like cross does come with the NDK, so it should compile and run, but is having an issue finding the correct zlib.

@jianshu93
Copy link
Author

I am having an aarch64 macOS, not sure we can simulate a aarch64-Linux-android. I'm not succesful running the cross test:

Jianshus-MBP-2:minimap2-rs-android jianshuzhao$ cross test --target aarch64-linux-android
[cross] warning: using newer rustc 1.82.0-nightly (8b3870784 2024-08-07) for the target. Current active rustc on the host is rustc 1.82.0-nightly (176e54520 2024-08-04).

Update with rustup update
Trying to pull ghcr.io/cross-rs/aarch64-linux-android:0.2.5...
Error: choosing an image from manifest list docker://ghcr.io/cross-rs/aarch64-linux-android:0.2.5: no image found in image index for architecture "arm64", variant "v8", OS "linux"

Jianshu

@jguhlin
Copy link
Owner

jguhlin commented Aug 20, 2024

@jianshu93 Haven't had any luck figuring out a workaround with cross, but I've merged this branch into main for now. If it does work when you deploy it let me know and I'll make a note of it.

jguhlin added a commit that referenced this issue Nov 22, 2024
@jguhlin
Copy link
Owner

jguhlin commented Nov 27, 2024

Android compiles are working for x86 and aarch64.

@jguhlin jguhlin closed this as completed Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants