Repository navigation
[native] Stop linking libc++ into the CoreCLR and NativeAOT runtimes - #12572
Conversation
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/native/CMakePresets.json.in — 💡 Maintainability — coreclr-default-common duplicates ANDROID_CPP_FEATURES from… |
What changed in this PR
Removes the C++ standard library (libc++/libc++abi) and libunwind from the CoreCLR native host build and runtime packs now that the host no longer references the C++ standard library, while keeping compiler built-ins available for linking.
Changes:
- Stop shipping/linking libc++/libc++abi/libunwind for CoreCLR by pruning NDK redistributables and runtime pack asset lists.
- Introduce a CoreCLR-specific CMake preset baseline (
ANDROID_STL=none) and adjust CoreCLR presets to inherit from it. - Narrow
libunwindbuild to MonoVM-only and rename the native archive set fromCplusPlusRuntimetoCompilerRuntime(clang builtins).
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs | Renames the “c++” archive set to “compiler-rt” and removes libc++/libc++abi/libunwind archives from the known archive list. |
| src/Xamarin.Android.Build.Tasks/Tasks/LinkNativeRuntime.cs | Updates the set used for the “compiler support” archive group when ordering link inputs. |
| src/native/native.targets | Stops copying NDK “CplusPlus” redistributable archives into CoreCLR runtime packs. |
| src/native/CMakePresets.json.in | Adds coreclr-default-common preset with ANDROID_STL=none and updates CoreCLR presets to inherit from it. |
| src/native/CMakeLists.txt | Builds common/libunwind only for MonoVM (where it is actually linked). |
| build-tools/scripts/Ndk.targets | Removes libc++/libc++abi/libunwind from the NDK redistributable item list. |
| build-tools/scripts/Ndk.projitems | Removes now-unused UnwindArchDir metadata. |
| build-tools/create-packs/Microsoft.Android.Runtime.proj | Stops including NDK “CplusPlus” redistributables in the CoreCLR runtime pack assets. |
5f2f049 to
30ed2fc
Compare
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
No actionable code issues found. I reviewed the native preset split, explicit unwinder suppression, runtime-pack composition/cleanup, compiler-runtime link ordering, and the added CoreCLR/NativeAOT coverage. The latest Azure DevOps run is still in progress, so this review does not treat CI as green yet.
Generated by Android PR Reviewer for #12572 · gpt56 · 232.3 AIC · ⌖ 20.7 AIC · ⊞ 27.7K
Comment /review to run again
Pull Request is not mergeable
Pull Request is not mergeable
Pull Request is not mergeable
Now that the CoreCLR host has zero references to the C++ standard
library, we can stop linking it in entirely.
* Add a `coreclr-default-common` CMake preset that sets
`ANDROID_STL=none` (mirroring `nativeaot-default-common`, but
without the STL). This drops `-static-libstdc++` from the link
line and replaces it with `-nostdlib++`. Every CMake target
already adds `${SYSROOT_CXX_INCLUDE_DIR}` explicitly, so the
libc++ *headers* remain available.
* Stop building `common/libunwind` for CoreCLR. Only `mono/tracing`
links `xa::unwind`; the CoreCLR host built it and never used it.
* Stop shipping `libc++_static.a`, `libc++abi.a` and `libunwind.a`
in the CoreCLR runtime pack, and drop them from the archive list
used by `LinkNativeRuntime`. `KnownSets.CplusPlusRuntime` now only
holds the clang built-ins archive, so it is renamed to
`KnownSets.CompilerRuntime`.
Verified on `android-arm64` Release: the host builds and links
cleanly with `ANDROID_STL=none`, `libnet-android.release.so` is
unchanged at 203,776 bytes, has zero undefined libc++/libunwind
symbols, and its `DT_NEEDED` list is unchanged. MonoVM and NativeAOT
are unaffected.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0a35a0db-502d-48c0-8468-e73b5dd0ab2e
NativeAOT already had zero references to the C++ standard library after #12523, so switching `nativeaot-default-common` to `ANDROID_STL=none` costs nothing and turns any future libc++ use into a link error instead of silently pulling the archive back in. Verified on `android-arm64` Release with a clean configure: all three NativeAOT artifacts -- `libnaot-android.release.so`, `libnaot-android.release-static-release.a` and `libxa-java-interop-release.a` -- are byte-for-byte identical to the `c++_static` build. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0a35a0db-502d-48c0-8468-e73b5dd0ab2e
…rchives Suppress Clang's implicit libunwind dependency when ANDROID_STL is none. Preserve obsolete-archive cleanup for CoreCLR and NativeAOT packs, exclude stale Xamarin unwind archives, and verify app linking without C++ archives on all supported ABIs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Separate CoreCLR prebuilt-runtime smoke coverage from NativeAOT archive-link checks, simplify runtime-pack assertions, and share no-STL defaults while isolating Mono's libc++ settings. Track generated presets in native configuration inputs, remove the nonexistent startup input, and drop unused unwinder include paths. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
30ed2fc to
1eb5203
Compare
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
✅ LGTM
The runtime split is coherent: CoreCLR and NativeAOT now use no-STL/no-unwinder linking, Mono retains libc++ and the Xamarin unwinder, compiler-rt remains available to static linking, and stale pack artifacts are explicitly removed. The PR narrative matches the implementation, and CI is green.
Findings: 0 errors · 0 warnings · 1 suggestion (test hardening)
Generated by Android PR Reviewer for #12572 · gpt56 · 142.4 AIC · ⌖ 8.86 AIC · ⊞ 25.7K
Comment /review to run again

Stop linking libc++ and libunwind into the CoreCLR and NativeAOT hosts now that their C++ runtime dependencies have been removed. This is the payoff PR for the CoreCLR half of #12533.
Changes
default-common, which setsANDROID_STL=none.mono-default-commonoverrides this toc++_staticfor MonoVM. Existing entry-point preset names are unchanged, and libc++ headers remain available for header-only facilities.--unwindlib=nonewhenANDROID_STL=none; disabling libc++ alone still lets Clang addlibunwind.aimplicitly.xa::unwind. Remove the unused CoreCLR/NativeAOT unwinder include references as well.libc++_static.a,libc++abi.a, andlibunwind.a, and stop including Xamarin unwinder archives in the CoreCLR pack. Clean obsolete copies from existing CoreCLR/NativeAOT pack directories and prevent stale build outputs from being copied back. MonoVM retains its existing dependencies.NativeRuntimeComponentsand rename the remaining clang built-ins set toCompilerRuntime(compiler-rt).CMakePresets.jsonin the runtime, archive-stub, and test-JNI configuration inputs. Remove the nonexistentclr/startup/CMakeLists.txtinput that forced CoreCLR to reconfigure on every build.Removing the libraries from the link command makes accidental reintroduction of a C++ runtime dependency a link error, rather than silently pulling libc++ back into the host.
Coverage and validation
Local Release SDK build and native builds completed:
Unified static CoreCLR linking
This PR does not enable
_AndroidEnableNativeRuntimeLinking. An explicit attempt reachedLinkNativeRuntimebut failed: the current dotnet/runtime pack supplieslibcoreclr.so, not the requiredlibcoreclr_static.a, and the dormant path has additional unresolved dependencies. Consequently, CoreCLR app coverage is explicitly a smoke test using the prebuilt runtime, not a claim that unified static CoreCLR linking works.