Skip to content

feat(android): enable aarch64-linux-android cross-compilation#99

Merged
chrishayuk merged 1 commit into
mainfrom
feat/android-aarch64-blas-gate
May 15, 2026
Merged

feat(android): enable aarch64-linux-android cross-compilation#99
chrishayuk merged 1 commit into
mainfrom
feat/android-aarch64-blas-gate

Conversation

@chrishayuk
Copy link
Copy Markdown
Owner

Summary

Cherry-picked from #94 — credits @metavacua as the original author of this change. Pulls in only the BLAS-gating commit. None of #94's other scope (workflow rewrites, REUSE/AGPL re-licensing, wasmtime→wasmi swap, compliance pipeline) is included here.

  • Gates extern crate blas_src and the ndarray blas feature behind a 4-OS cfg (linux/freebsd/macos/windows).
  • On Android, ndarray falls back to its pure-Rust matrixmultiply path.
  • All existing platforms keep their existing BLAS backends unchanged.

Affected crates: larql-compute, larql-inference, larql-kv.

Build instructions (machine-local, not committed)

NDK linker/ar entries in .cargo/config.toml plus:

export ANDROID_NDK_ROOT=/path/to/android-ndk-r27c
export CC_aarch64_linux_android=$NDK_BIN/aarch64-linux-android21-clang
export CXX_aarch64_linux_android=$NDK_BIN/aarch64-linux-android21-clang++
export AR_aarch64_linux_android=$NDK_BIN/llvm-ar
export OPENSSL_DIR=/path/to/openssl-android-arm64
export OPENSSL_STATIC=1
export RUSTFLAGS="-C target-feature=+dotprod"   # required by sdot in q4k kernel

cargo build --target aarch64-linux-android

#94 confirmed this produces valid Android ELF64 PIE binaries.

Test plan

  • cargo test -p larql-compute --lib — 162 passed / 0 failed
  • cargo test -p larql-inference --lib — 907 passed / 0 failed
  • cargo test -p larql-inference --tests — 14 passed / 0 failed
  • cargo test -p larql-kv --lib — 200 passed / 0 failed
  • cargo build --target aarch64-linux-android (requires NDK; verified upstream in feat(android): enable aarch64-linux-android cross-compilation #94)

Notes

  • dotprod requirement in q4k_q8k_dot.rs targets ARMv8.2+ (Cortex-A55 / ~2017+); a #[cfg(target_feature = "dotprod")] scalar fallback would broaden device coverage but is out of scope here.
  • armv7-linux-androideabi (32-bit) is blocked upstream by Cranelift lacking a 32-bit ARM backend — also out of scope.

Supersedes scope from #94 (which should be closed in favour of focused follow-ups).

@chrishayuk chrishayuk force-pushed the feat/android-aarch64-blas-gate branch from 96efd8d to f3831ce Compare May 14, 2026 23:59
Gate `extern crate blas_src` and the ndarray `blas` feature behind
platform-specific cfg so the codebase builds for Android, which has
no system BLAS. On Android, ndarray falls back to its pure-Rust
matrixmultiply path; all existing platforms (Linux/FreeBSD/macOS/
Windows) retain their BLAS backends unchanged.

Affected crates: larql-compute, larql-inference, larql-kv.

Build requirements (not committed — machine-local):
  - Android NDK r27+ with .cargo/config.toml for linker/ar
  - Cross-compiled OpenSSL for aarch64-linux-android (OPENSSL_DIR)
  - RUSTFLAGS="-C target-feature=+dotprod" (sdot in q4k kernel)
@chrishayuk chrishayuk merged commit 5134e9d into main May 15, 2026
22 of 24 checks passed
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

Successfully merging this pull request may close these issues.

2 participants