[NativeAOT] Stop shipping libc++ archives in the runtime packs - #12524
Merged
simonrozsival merged 1 commit intoAug 28, 2026
Conversation
12 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces the size of the shipped Android NativeAOT runtime packs by stopping the inclusion of libc++-related NDK archives (libc++_static.a, libc++abi.a, libunwind.a) that are no longer linked by NativeAOT. It does this by introducing a new NDK redistributable “Kind” (CplusPlus) and only packaging those assets for the CoreCLR runtime flavor.
Changes:
- Introduce a new
_AndroidNdkRedistributable.KindvalueCplusPlusfor the three C++ archives. - Update local pack staging (
src/native/native.targets) to includeCplusPlusassets only for CoreCLR. - Update shipped NuGet runtime pack creation (
Microsoft.Android.Runtime.proj) to includeCplusPlusassets only for CoreCLR.
Show a summary per file
| File | Description |
|---|---|
| src/native/native.targets | Adds CoreCLR-only inclusion of CplusPlus NDK archives when copying assets into the local runtime pack directory layout. |
| build-tools/scripts/Ndk.targets | Re-tags libc++/libunwind NDK archives from Toolchain to the new CplusPlus kind. |
| build-tools/create-packs/Microsoft.Android.Runtime.proj | Adds CoreCLR-only inclusion of CplusPlus NDK archives when creating the shipped runtime pack NuGets. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 26, 2026 14:39
d165234 to
6cd95f9
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 27, 2026 06:25
6cd95f9 to
880e1de
Compare
This was referenced Aug 27, 2026
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 27, 2026 10:21
880e1de to
98acccd
Compare
jonathanpeppers
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 27, 2026 14:25
98acccd to
1401b7f
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 27, 2026 15:47
1401b7f to
4acae6c
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 27, 2026 16:09
4acae6c to
c81efce
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 27, 2026 21:42
c81efce to
fdd347d
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 28, 2026 07:54
fdd347d to
7a5a5c7
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 28, 2026 08:47
7a5a5c7 to
2872174
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 28, 2026 08:55
2872174 to
92b7f75
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 28, 2026 09:51
92b7f75 to
15895a5
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 28, 2026 10:29
15895a5 to
08b4765
Compare
Now that NativeAOT applications no longer link libc++, the NativeAOT runtime packs still carry `libc++_static.a`, `libc++abi.a` and `libunwind.a` as dead weight. The NDK redistributables were split into just `System` and `Toolchain`, and the `Toolchain` group was shipped to both CoreCLR and NativeAOT. NativeAOT still needs `crtbegin_so.o`, `crtend_so.o` and `libclang_rt.builtins-*.a` from that group, so the group cannot simply be dropped. Introduce a third `CplusPlus` kind for the three C++ archives and ship it only for CoreCLR, which still links libc++. Per ABI this removes 18,398,848 bytes from the NativeAOT runtime pack: | Archive | Size | | --- | ---: | | `libc++_static.a` | 15,182,348 | | `libc++abi.a` | 3,125,348 | | `libunwind.a` | 91,152 | Across the three shipped ABIs (`android-arm`, `android-arm64`, `android-x64`) that is roughly 55 MB. Contributes to #12139. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0a35a0db-502d-48c0-8468-e73b5dd0ab2e
simonrozsival
force-pushed
the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
from
August 28, 2026 12:06
08b4765 to
a970e21
Compare
simonrozsival
deleted the
dev/simonrozsival/nativeaot-drop-libcpp-packs
branch
August 28, 2026 12:42
Member
Author
|
Consolidated into #12523 to reduce the depth of the #12546 stack. No code changed: the commits from this PR are now part of #12523 unmodified, and the resulting tree is byte-identical. This PR sat directly on top of #12523 and touched the same files, so reviewing them together is easier than reviewing the same file across two intermediate states. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributes to #12139. Builds on #12523, which stopped linking libc++ into NativeAOT applications.
The NativeAOT runtime packs still ship
libc++_static.a,libc++abi.aandlibunwind.aeven though nothing links them any more.Why this needs a new item kind
_AndroidNdkRedistributable(inbuild-tools/scripts/Ndk.targets) tagged NDK files with just two kinds:System—libc.so,libdl.so,liblog.so,libm.so,libz.so— shipped to every runtime.Toolchain—crtbegin_so.o,crtend_so.o,libc++_static.a,libc++abi.a,libclang_rt.builtins-*.a,libunwind.a— shipped to CoreCLR and NativeAOT, since both do native linking.NativeAOT still needs
crtbegin_so.o,crtend_so.oandlibclang_rt.builtins-*.a, so theToolchaingroup cannot just be dropped for NativeAOT.This adds a third kind,
CplusPlus, for the three C++ archives, and ships it only for CoreCLR. Both packaging sites are updated:src/native/native.targets— the localbin/<Config>/lib/packslayout.build-tools/create-packs/Microsoft.Android.Runtime.proj— the shipped NuGet packs.Size
Per ABI, removed from the NativeAOT runtime pack:
libc++_static.alibc++abi.alibunwind.aAcross
android-arm,android-arm64andandroid-x64that is roughly 55 MB of pack content. This does not change application size — that was #12523 — but it shrinks what users restore.Testing
Deleted each pack directory and regenerated it via
_CopyToPackDirs, rather than checking a pack that could still contain stale files.NativeAOT (
android-arm64) — the three archives are gone, and everything NativeAOT links is still present:CoreCLR (
android-arm64) — all three are still shipped:Mono is unaffected — it only ever received the
Systemkind.