Skip to content

Enable linker GC for Android native release builds#11504

Draft
simonrozsival wants to merge 3 commits into
mainfrom
dev/simonrozsival/native-linker-gc-sections
Draft

Enable linker GC for Android native release builds#11504
simonrozsival wants to merge 3 commits into
mainfrom
dev/simonrozsival/native-linker-gc-sections

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

What

Enable section splitting for common Android native compilation and pass --gc-sections to the linker for non-Debug, non-sanitizer native builds.

This is an experiment inspired by dotnet/runtime#128232.

Local validation

  • Built src/native/native-mono.csproj for arm64 with the change.
  • Built src/native/native-clr.csproj for arm64 with the change.
  • Compared dynamic exports for rebuilt arm64 Release libmono-android.release.so and libnet-android.release.so; exported symbol sets matched the previous local copies.
  • Launched a minimal CoreCLR + trimmable typemap arm64 Release Android app on a connected SM_A165F; it stayed alive with no fatal crash, tombstone, JNI error, or unresolved native library error in logcat.

Local size observation

Compared against the previous local packed arm64 runtime copies:

  • libmono-android.release.so: 1,387,904 -> 1,276,304 bytes (-111,600, -8.04%)
  • libnet-android.release.so: 1,366,776 -> 1,258,008 bytes (-108,768, -7.96%)

This is still a draft because broader ABI/runtime/device coverage is needed.

simonrozsival and others added 3 commits May 26, 2026 17:07
Use section splitting for common native compilation and pass --gc-sections to the linker for non-debug, non-sanitizer native builds. This mirrors the Unix native dead-code elimination pattern used by dotnet/runtime and reduces unused code in Android native runtime libraries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Refresh apkdesc baselines from PR CI after enabling native linker GC sections.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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