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

Bug: Linker errors on Android #235

Open
2 of 3 tasks
zhongzc opened this issue Nov 19, 2024 · 7 comments
Open
2 of 3 tasks

Bug: Linker errors on Android #235

zhongzc opened this issue Nov 19, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@zhongzc
Copy link

zhongzc commented Nov 19, 2024

Describe the bug

See GreptimeTeam/greptimedb#5016

I encountered linker errors when trying to build greptime for Android (aarch64-linux-android) using cargo ndk. The errors indicate undefined symbols for SIMD functions (e.g., simsimd_cos_f32, simsimd_dot_f32, simsimd_l2sq_f32) from the simsimd crate.

cargo ndk --platform 23 -t aarch64-linux-android build --locked --profile release --bin greptime --bin greptime --no-default-features
    Building arm64-v8a (aarch64-linux-android)
...
...
...
Compiling cmd v0.9.5 (/greptimedb/src/cmd)error: linking with /root/.cargo/bin/cargo-ndk failed: exit status: 1

  = note: ld: error: undefined symbol: simsimd_cos_f32
          >>> referenced by lib.rs:447 (rust/lib.rs:447)
          >>>               simsimd-9910860383191831.simsimd.a55a236d9e83b92-cgu.0.rcgu.o:(_$LT$f32$u20$as$u20$simsimd..SpatialSimilarity$GT$::cos::hffc7059aa27c91f8) in archive /greptimedb/target/aarch64-linux-android/release/deps/libsimsimd-9910860383191831.rlib
          
          ld: error: undefined symbol: simsimd_dot_f32
          >>> referenced by lib.rs:457 (rust/lib.rs:457)
          >>>               simsimd-9910860383191831.simsimd.a55a236d9e83b92-cgu.0.rcgu.o:(_$LT$f32$u20$as$u20$simsimd..SpatialSimilarity$GT$::dot::h02288694ae51f515) in archive /greptimedb/target/aarch64-linux-android/release/deps/libsimsimd-9910860383191831.rlib
          
          ld: error: undefined symbol: simsimd_l2sq_f32
          >>> referenced by lib.rs:467 (rust/lib.rs:467)
          >>>               simsimd-9910860383191831.simsimd.a55a236d9e83b92-cgu.0.rcgu.o:(_$LT$f32$u20$as$u20$simsimd..SpatialSimilarity$GT$::l2sq::h646b02bc768ea724) in archive /greptimedb/target/aarch64-linux-android/release/deps/libsimsimd-9910860383191831.rlib
          clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: could not compile cmd (bin "greptime") due to 1 previous error
note: If the build failed due to a missing target, you can run this command:
note: 
note:     rustup target install aarch64-linux-android
make: *** [Makefile:75: build] Error 101
make: *** [Makefile:93: build-android-bin] Error 2

I'm not familiar with Android. Your guidance will be greatly appreciated if the problem is too simple or troublesome.

Steps to reproduce

git clone https://github.com/GreptimeTeam/greptimedb.git  
cd greptimedb
make build-android-bin

Expected behavior

Pass the build.

SimSIMD version

v6.0.5

Operating System

Android

Hardware architecture

Arm

Which interface are you using?

Rust bindings

Contact Details

No response

Are you open to being tagged as a contributor?

  • I am open to being mentioned in the project .git history as a contributor

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@zhongzc zhongzc added the bug Something isn't working label Nov 19, 2024
@zhongzc
Copy link
Author

zhongzc commented Nov 19, 2024

simsimd = "4" can be compiled, but "=5.0.0" fails

@ashvardanian
Copy link
Owner

Does it only fail on Android and passes everywhere else?

@zhongzc
Copy link
Author

zhongzc commented Nov 19, 2024

Does it only fail on Android and passes everywhere else?

Yes

@ashvardanian
Copy link
Owner

@zhongzc, any chance you could reproduce its build pipeline in an isolated GitHub CI job and add it to prerelease.yml? In that case I can research the issue and probably fix it 🤗

@discord9
Copy link

discord9 commented Nov 20, 2024

@zhongzc, any chance you could reproduce its build pipeline in an isolated GitHub CI job and add it to prerelease.yml? In that case I can research the issue and probably fix it 🤗

I can reproduce using cargo ndk, and here is a minimal available case(it need docker to run), more instructions on how to reproduce is in the readme.md
reproduce.zip
Note the docker image it is using is not yet minimal, still working on reduce the docker image to minimal dependency, but hopefully that could be useful enough for now
edited: I found a mininal reproduce case! very strange, I think, it might be a misconfigure in cargo ndk after all, see more in new README.MD. Basically build with instrumentisto/cargo-ndk works, but build with saschpe/android-ndk then install cargo ndk would cause same error, anyway see the new README.md in reproduce_min.zip!
reproduce_min.zip

@discord9
Copy link

More tests show that this is introduced in 5.0.0, it can compile (in the dockerfile image from reproduce_min.zip) using simsimd="=4.4.0" but failed with the same error ld: error: undefined symbol: simsimd_l2sq_f64 on simsimd="=5.0.0"

@ashvardanian
Copy link
Owner

Yes, that part is clear. The older versions didn't use dynamic dispatch in Rust. The new ones seem to work fine with Rust on most platforms, but we may need to find a different approach on Android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants