Skip to content

Conversation

@sbomer
Copy link
Member

@sbomer sbomer commented Jan 21, 2026

This eliminates the NDK dependency for NativeAOT builds by using our custom LLVM build (android-native-tools) that ships with the Android workload.

Changes:

  • Add LinkNativeAotLibrary task that invokes ld.lld from android-native-tools
  • Set NativeCompilationDuringPublish=false and NativeLib=Static so ILC produces only object files, then we link them ourselves
  • Add -z nostart-stop-gc linker flag for __start/__stop symbols
  • Include sysroot libraries (libc++_static.a, libunwind.a, etc.) in NativeAOT runtime pack
  • Fix duplicate assembly error by removing items before re-adding them to ResolvedFileToPublish
  • Keep legacy NDK path behind AndroidNativeAotUseNdk=true flag

This eliminates the NDK dependency for NativeAOT builds by using our
custom LLVM build (android-native-tools) that ships with the Android
workload.

Changes:
- Add LinkNativeAotLibrary task that invokes ld.lld from android-native-tools
- Set NativeCompilationDuringPublish=false and NativeLib=Static so ILC
  produces only object files, then we link them ourselves
- Add -z nostart-stop-gc linker flag for __start/__stop symbols
- Include sysroot libraries (libc++_static.a, libunwind.a, etc.) in
  NativeAOT runtime pack
- Fix duplicate assembly error by removing items before re-adding them
  to ResolvedFileToPublish
- Keep legacy NDK path behind AndroidNativeAotUseNdk=true flag
NativeAOT's DWARF-based stack unwinder (LLVM libunwind) requires the
.eh_frame_hdr section to locate Frame Description Entries during GC
stack walking. Without this section, the runtime crashes with SIGSEGV
when attempting to read unwind information from invalid memory.
Quote the soname argument to handle project names containing spaces.
Without this fix, a project named 'Test Me' would cause the linker to
fail with 'cannot open Me: No such file or directory' because the
unquoted soname would be split into separate arguments.
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