Skip to content

[CoreCLR] Remove native runtime linking p/invoke override#12025

Merged
simonrozsival merged 5 commits into
dotnet:mainfrom
simonrozsival:dev/simonrozsival/remove-coreclr-native-runtime-linking
Jul 9, 2026
Merged

[CoreCLR] Remove native runtime linking p/invoke override#12025
simonrozsival merged 5 commits into
dotnet:mainfrom
simonrozsival:dev/simonrozsival/remove-coreclr-native-runtime-linking

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Jul 9, 2026

Copy link
Copy Markdown
Member

Goal

Remove the unused CoreCLR app-build-time dynamic native-runtime-linking / dynamic p/invoke override path.

Background

This path was introduced for CoreCLR only:

The original purpose was to build a unified runtime DSO during the app build by statically linking the CoreCLR runtime pack, BCL native archives, and .NET for Android native runtime pieces together. In that layout, runtime/BCL native symbols were hidden inside the unified DSO, so CoreCLR could not use the normal separate-library resolution path. The dynamic p/invoke override generated app-specific lookup/preservation tables so those linked-in symbols could still be resolved and kept alive.

That support was never wired for MonoVM or NativeAOT. _AndroidEnableNativeRuntimeLinking is also an internal property, so this PR removes the dead CoreCLR implementation and stops defaulting/validating the internal knob instead of preserving an unsupported build error path.

Why remove it now

CoreCLR now uses the default separate-.so runtime layout with the precompiled p/invoke override path. In #11537, the precompiled path stopped serving BCL native library p/invokes from a hand-maintained static table and lets CoreCLR resolve those symbols itself from the standalone BCL .so files.

That means the dynamic unified-DSO path no longer buys us anything: it keeps extra generated/native code alive, carries symbol-table drift risk, and was only ever usable for the CoreCLR experiment it was added for.

Summary

  • remove the CoreCLR pinvoke-override-dynamic native target and dynamic.cc
  • stop packing/selecting the removed libpinvoke-override-dynamic-*.a archive
  • remove the stale precompiled p/invoke override comment that referenced the unified-DSO path
  • stop defaulting _AndroidEnableNativeRuntimeLinking
  • remove the _AndroidEnableNativeRuntimeLinking=true validation error

Validation

  • git diff --check
  • git grep -n "pinvoke-override-dynamic\|dynamic.cc\|XA_PINVOKE_OVERRIDE_DYNAMIC\|LIB_NAME_DYNAMIC" -- ':!src/native/mono/**' ':!bin/**' returned no tracked CoreCLR references

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 9, 2026 07:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the unused CoreCLR “native runtime linking” p/invoke override implementation (the unified-DSO pinvoke-override-dynamic path) and makes CoreCLR builds fail fast if _AndroidEnableNativeRuntimeLinking=true is manually enabled, preventing a dead/unsupported configuration from being used.

Changes:

  • Adds an MSBuild validation error when _AndroidEnableNativeRuntimeLinking=true under CoreCLR.
  • Removes the CoreCLR pinvoke-override-dynamic native implementation and its CMake target.
  • Stops selecting/packing the removed libpinvoke-override-dynamic-*.a archives and cleans up a now-stale explanatory comment.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets Adds CoreCLR validation target to error out when native runtime linking is enabled; adjusts defaulting behavior to avoid silently overriding user-set values.
src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs Removes the dynamic pinvoke override archive from the unified-runtime archive selection list.
src/native/clr/pinvoke-override/precompiled.cc Removes a stale comment referencing the removed unified-DSO dynamic override path.
src/native/clr/pinvoke-override/dynamic.cc Deletes the dynamic override implementation source (no longer supported/used).
src/native/clr/pinvoke-override/CMakeLists.txt Removes the pinvoke-override-dynamic library target and associated source list.
build-tools/create-packs/Microsoft.Android.Runtime.proj Stops packing libpinvoke-override-dynamic-*.a assets into the CoreCLR runtime pack.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 0

simonrozsival and others added 2 commits July 9, 2026 09:17
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival added the Area: CoreCLR Issues that only occur when using CoreCLR. label Jul 9, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival merged commit d620576 into dotnet:main Jul 9, 2026
42 checks passed
simonrozsival added a commit that referenced this pull request Jul 9, 2026
## Goal

Remove the obsolete `logcat-parse` diagnostic tool from Java.Interop and dotnet/android packaging.

## Motivation

`logcat-parse` is not part of the Android app runtime or normal app build path, but keeping it in `Java.Interop.sln` means CI restores and builds it during Java.Interop preparation. It depends on `Mono.Terminal`, and PR #12025 hit a red CI lane when `prepare java.interop Release` timed out restoring that package from the Azure DevOps feed:

```text
NU1301: Failed to retrieve information about 'Mono.Terminal'
The HTTP request ... has timed out after 100000ms.
```

Removing the unused tool removes that restore dependency and the associated CI flake surface.

## Summary

- delete `external/Java.Interop/tools/logcat-parse`
- delete `external/Java.Interop/tests/logcat-parse-Tests`
- remove `logcat-parse` projects from `Java.Interop.sln` and `Xamarin.Android.sln`
- remove the Java.Interop CI test entry for `logcat-parse-Tests`
- remove `Mono.Terminal` and `Mono.CSharp` package-version pins that were only used by `logcat-parse`
- stop packaging `logcat-parse.exe`, `logcat-parse.pdb`, and `Mono.CSharp.dll` in legacy installers
- update docs and test catalog references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: CoreCLR Issues that only occur when using CoreCLR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants