Skip to content

Android: build scripts for the collector and the async runtime - #507

Merged
ASDAlexander77 merged 2 commits into
mainfrom
android-runtime-build
Oct 5, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
android-runtime-build

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

What

Two local build scripts (Windows host, Android NDK) for the native pieces a program compiled with -mtriple=<arch>-linux-android29 links. Both take an ABI, arm64-v8a or x86_64, or build both when given none:

  • scripts/build_gc_release_android.bat builds Boehm gc 8.2.12 (static, PIC, threads) into 3rdParty/gc/android/<abi>/release.
  • scripts/build_tslang_runtime_release_android.bat builds libTypeScriptAsyncRuntime.a into __build/tslang-runtime/release/android/<abi>, through the standalone tslang/runtime project, which needs no LLVM or MLIR libraries.

Both use the NDK's CMake toolchain with ANDROID_PLATFORM=android-29, read ANDROID_NDK_HOME, and need Ninja. Tested with NDK r30.

The default library side is ASDAlexander77/TypeScriptCompilerDefaultLib, branch android-build.

Runtime project drift (affects x86 too)

tslang/runtime/CMakeLists.txt compiled only AsyncRuntime.cpp and DynamicRuntime.cpp. Since #412 and #419, the in-tree lib/TypeScriptAsyncRuntime also has:

  • AsyncGCThreads.cpp: GC_enable_threads, which the entry point calls in every gc program.
  • ProcessHeap.cpp: __tslang_heap_*, which ProcessHeapPass makes Windows programs call. It compiles to nothing off Windows.

Both are added back. A Win32 build of the project now has _GC_enable_threads and ___tslang_heap_malloc in TypeScriptAsyncRuntime.lib; before, the x86 library lacked them.

Verification

  • Both scripts build both ABIs cleanly. The only warning is the existing MLIR_ASYNC_RUNTIME_EXPORT redefinition, which every non-Windows build of AsyncRuntime.cpp gets.
  • A test program (class, assert, number to string, Date, async/await, fetch) was compiled with tslang -mtriple=<arch>-linux-android29 -relocation-model=pic. It was then linked with NDK clang++ -pie -static-libstdc++ against these libraries and the Android default library. That ran for both ABIs, under gc, rc and none (release), and gc (debug):
    • all 8 link;
    • the dynamic dependencies are libc, libm and libdl only;
    • GC_enable_threads resolves under gc;
    • rc and none contain no GC_*.
  • Link-only: there's no Android device or emulator on the dev machine, so nothing has been run.

Not in this PR

  • tslang --emit=exe for Android still uses the Linux link line. It doesn't use the NDK sysroot or Android compiler-rt/libunwind, and it passes -lcurl, -lpthread and -lrt, which Android doesn't have. Programs are linked with the NDK by hand for now (see the DefaultLib README).
  • A CI job, then a new release: v0.0-pre-alpha89 predates Codegen picks the target's CRT, not the host's (Android cross-compile) #506.

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits October 5, 2026 13:34
scripts/build_gc_release_android.bat and
scripts/build_tslang_runtime_release_android.bat build Boehm and
TypeScriptAsyncRuntime for Android API 29 (arm64-v8a and x86_64) with the
NDK's CMake toolchain, from ANDROID_NDK_HOME. The runtime goes through the
standalone tslang/runtime project, which needs no LLVM or MLIR libraries.

tslang/runtime had drifted from lib/TypeScriptAsyncRuntime: it lacked
AsyncGCThreads.cpp (GC_enable_threads, needed by every gc program that is
linked against it) and ProcessHeap.cpp (__tslang_heap_*, which
ProcessHeapPass makes Windows programs call). Both are back, for the x86
Windows build too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 7e8be21 into main Oct 5, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the android-runtime-build branch October 5, 2026 13:41
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