docs: Cuprate cross-compiles for Android aarch64 (NDK r28c, minSdk 26) #93

Merged
sirius merged 1 commit from wt/cuprate-android-crosscompile-spike into main 2026-09-17 04:08:29 +00:00
Owner

Spike answer for the Phase 1 Android question (kanban t_8293d96d): does the Cuprate-in-process dependency tree cross-compile for the Android NDK target aarch64-linux-android?

Yes. Both halves were run, on the cuprate-poc graph (cuprated git 4f8fcd1b, randomx-rs git 76c2385, arti-client 0.46 + 0.44):

  • cargo check --release --target aarch64-linux-android -> EXIT=0 (cold target dir: 152 crates, 43.66 s)
  • full cargo build --release + link -> EXIT=0; file says ELF 64-bit LSB pie executable, ARM aarch64 ... interpreter /system/bin/linker64, for Android 26, built by NDK r28c

RandomX (the C++ part):

  • librandomx.a member aes_hash.cpp.o is ELF64 / AArch64 (readelf -h) - real cross-built objects
  • the ARM64 JIT sources are in the build (jit_compiler_a64.cpp.o, jit_compiler_a64_static.S.o), -march=armv8-a+crypto, HAVE_HWCAP
  • DARCH=native from randomx-rs's build.rs is a no-op (RandomX's CMakeLists never reads DARCH), so no -march=native host-arch hazard today

What the doc records (docs/cuprate-android-spike.md), each item cost a run:

  1. PATH must put rustup's cargo/rustc first, else E0463 can't find crate for std.
  2. plain cargo check --target ... is not enough - cc-rs cannot find aarch64-linux-android-clang and libsqlite3-sys fails first; cargo ndk-env supplies the NDK C toolchain env.
  3. CMake needs ANDROID_NDK/ANDROID_NDK_ROOT exported or Android-Determine.cmake aborts ("Neither the NDK or a standalone toolchain was found"), even though cmake-rs passes CMAKE_SYSTEM_NAME=Android.
  4. cargo-ndk-env's exported LINKER is cargo-ndk itself, which dies on rustc's -Wl,... args ("unexpected argument '-W' found") and leaves a stale directory named librandomx_rs-<hash>.so in target/.../deps that breaks the next run; use the NDK clang as linker.
  5. the final link needs -lc++_static -lc++abi (NDK's libstdc++.a is a stub; -static-libstdc++ is ignored by NDK clang) and -lclang_rt.builtins-aarch64-android for RandomX's __clear_cache.
  6. API 26 (-P 26, matching android/app/build.gradle.kts minSdk), because at the NDK default 21 rand's fork handler leaves pthread_atfork undefined (API 23+).

Scope: docs only - one new file plus one sentence in docs/payment-integration-plan.md section 7a. The spike harness and logs live under /var/tmp/cuprate-android-poc and are not committed (throwaway spike code). No repo build was run because the change is documentation; the evidence is cargo/cmake output.

Not claimed: a cargo ndk / Gradle build of the SDK with Cuprate in it, and runtime behaviour on a device. The remaining Android work is packaging plumbing (wiring those link args into cargoBuildAndroid), not a Cuprate gap.

Spike answer for the Phase 1 Android question (kanban `t_8293d96d`): **does the Cuprate-in-process dependency tree cross-compile for the Android NDK target `aarch64-linux-android`?** Yes. Both halves were run, on the `cuprate-poc` graph (`cuprated` git `4f8fcd1b`, `randomx-rs` git `76c2385`, `arti-client` 0.46 + 0.44): - `cargo check --release --target aarch64-linux-android` -> **EXIT=0** (cold target dir: 152 crates, 43.66 s) - full `cargo build --release` + link -> **EXIT=0**; `file` says `ELF 64-bit LSB pie executable, ARM aarch64 ... interpreter /system/bin/linker64, for Android 26, built by NDK r28c` RandomX (the C++ part): - `librandomx.a` member `aes_hash.cpp.o` is `ELF64 / AArch64` (readelf -h) - real cross-built objects - the ARM64 JIT sources are in the build (`jit_compiler_a64.cpp.o`, `jit_compiler_a64_static.S.o`), `-march=armv8-a+crypto`, `HAVE_HWCAP` - `DARCH=native` from `randomx-rs`'s build.rs is a **no-op** (RandomX's CMakeLists never reads `DARCH`), so no `-march=native` host-arch hazard today What the doc records (`docs/cuprate-android-spike.md`), each item cost a run: 1. `PATH` must put rustup's cargo/rustc first, else `E0463 can't find crate for std`. 2. plain `cargo check --target ...` is not enough - cc-rs cannot find `aarch64-linux-android-clang` and `libsqlite3-sys` fails first; `cargo ndk-env` supplies the NDK C toolchain env. 3. CMake needs `ANDROID_NDK`/`ANDROID_NDK_ROOT` exported or `Android-Determine.cmake` aborts ("Neither the NDK or a standalone toolchain was found"), even though cmake-rs passes `CMAKE_SYSTEM_NAME=Android`. 4. `cargo-ndk-env`'s exported LINKER is `cargo-ndk` itself, which dies on rustc's `-Wl,...` args ("unexpected argument '-W' found") and leaves a stale *directory* named `librandomx_rs-<hash>.so` in `target/.../deps` that breaks the next run; use the NDK clang as linker. 5. the final link needs `-lc++_static -lc++abi` (NDK's `libstdc++.a` is a stub; `-static-libstdc++` is ignored by NDK clang) and `-lclang_rt.builtins-aarch64-android` for RandomX's `__clear_cache`. 6. API 26 (`-P 26`, matching `android/app/build.gradle.kts` minSdk), because at the NDK default 21 `rand`'s fork handler leaves `pthread_atfork` undefined (API 23+). Scope: docs only - one new file plus one sentence in `docs/payment-integration-plan.md` section 7a. The spike harness and logs live under `/var/tmp/cuprate-android-poc` and are not committed (throwaway spike code). No repo build was run because the change is documentation; the evidence is cargo/cmake output. Not claimed: a `cargo ndk` / Gradle build of the SDK with Cuprate in it, and runtime behaviour on a device. The remaining Android work is packaging plumbing (wiring those link args into `cargoBuildAndroid`), not a Cuprate gap.
Spike evidence for the Phase 1 Android question: cargo check --release --target
aarch64-linux-android exits 0 and the PoC binary links as an Android 26 aarch64 ELF.
Documents the env recipe, the four link args the C++ RandomX build needs, the
cargo-ndk linker-wrapper bug, and the RANDOMX_DIR/DARCH no-op.
sirius merged commit 918fa4d8a8 into main 2026-09-17 04:08:29 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!93
No description provided.