Skip to content

Add android port#77

Merged
dallison merged 17 commits into
mainfrom
android
May 26, 2026
Merged

Add android port#77
dallison merged 17 commits into
mainfrom
android

Conversation

@dallison

Copy link
Copy Markdown
Owner

This adds android support to subspace

dallison added 17 commits March 24, 2026 12:07
…paths

Patch Boost.Asio to skip -lpthread on Android (pthreads are in bionic's
libc), enabling all 9 RPC test targets to build and pass. Also fix
hardcoded /tmp paths in bridge_test, client_test, and split_buffer_test
to use /data/local/tmp on Android.
cc_library does not support the linkshared attribute. Switch to cc_binary
(the correct rule for producing a .so) and add target_compatible_with to
skip it on non-Android CI builds.
register_toolchains in MODULE.bazel causes Bazel to eagerly fetch the
NDK repo on all builds, failing CI where ANDROID_NDK_HOME is unset.
Move the registration to --extra_toolchains in .bazelrc so it only
triggers when --config=android_arm64 (or x86_64) is active.
Cross-compile all test targets for Android x86_64 and run them on a
hardware-accelerated emulator via reactivecircus/android-emulator-runner.
Also complete the android_x86_64 bazelrc config with --cpu and linkopt
flags matching the arm64 config.
The emulator-runner action executes script lines individually via
sh -c, breaking multi-line if/fi blocks. Move the test logic to a
proper bash script invoked as a single command.
- Add missing sources (split_buffer.cc, system_info.cc) to common/Android.bp
- Add proper dependency declarations for coroutines, cpp_toolbelt, and
  abseil throughout all Android.bp files
- Provide reference Android.bp files for external deps (coroutines,
  cpp_toolbelt) in external/ directory
- Document AOSP/Soong build process in docs/android.md
Use API 30 google_apis image instead of API 28 default (more stable on
CI runners). Increase boot timeout to 900s and add robust adb
reconnection logic after root.
- Add SUBSPACE_ANDROID define when building with NDK toolchain
- Fix -lrt linking (Linux-only, not Android/macOS)
- Add -llog for Android targets
- Include pre-generated protobuf files for cross-compilation (avoids
  needing a host-native protoc matching the library version)
- proto/CMakeLists.txt auto-detects cross-compilation and uses
  pre-generated files or falls back to a host protoc

Usage:
  cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
        -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-28 ..
Tests expect plugins at relative path plugins/*.so. Build plugins in
the cross-compile step and push them to the correct location on the
emulator.
Ensure build-dir includes take priority over source-dir so freshly
generated proto files are always preferred in native builds. Document
the CMake Android cross-compilation workflow.
Builds the project for Android arm64-v8a using the NDK toolchain file
and the pre-generated protobuf files.
Build x86_64 binaries via CMake and run them on an Android emulator,
matching what the Bazel android job does. Tests core subspace
functionality (common, split_buffer, client, c_client, shadow).
The Cargo-based Rust build doesn't support cross-compilation via
CMake's toolchain file. Skip it when CMAKE_CROSSCOMPILING is set.
Android's lld requires all symbols resolved at link time for shared
libraries (--unresolved-symbols=ignore-all is not supported). Link
plugins against their full dependency chain on Android.
Use path pattern */x86_64-linux-android/* instead of *x86_64* which
was incorrectly matching the riscv64 library.
@dallison dallison merged commit c7da4c2 into main May 26, 2026
34 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.

1 participant