Skip to content

[runtime] Use SYSTEM_CORELIB_DIRECTORY to locate System.Private.CoreLib.dll#26009

Open
rolfbjarne wants to merge 1 commit into
mainfrom
dev/rolf/issue-25578-use-system-corelib-directory-to-specify-26911e
Open

[runtime] Use SYSTEM_CORELIB_DIRECTORY to locate System.Private.CoreLib.dll#26009
rolfbjarne wants to merge 1 commit into
mainfrom
dev/rolf/issue-25578-use-system-corelib-directory-to-specify-26911e

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

dotnet/runtime#128278 removed the TPA-scanning fallback in CoreCLR's BindToSystem, which broke scenarios (like ours) where coreclr isn't located next to System.Private.CoreLib.dll. dotnet/runtime#128734 added a new well-known host property, SYSTEM_CORELIB_DIRECTORY, that lets the host explicitly point the runtime at the directory containing CoreLib instead of relying on implicit scanning.

This PR makes us use that property:

  • Added xamarin_compute_system_corelib_directory () in runtime/runtime.m, which looks for System.Private.CoreLib.dll in the bundle directory and the runtimeidentifier-specific subdirectory, and returns the directory that contains it.
  • Pass its result as the SYSTEM_CORELIB_DIRECTORY property when initializing the runtime in xamarin_vm_initialize.
  • Registered SYSTEM_CORELIB_DIRECTORY in the _RuntimeConfigReservedProperties list in Xamarin.Shared.Sdk.targets (all properties passed to the VM must be listed there).

Notes for reviewers:

  • If CoreLib can't be found, the helper returns an empty string. An empty value is treated by the runtime as if the property wasn't set, so behavior is unchanged in that case.
  • The property is placed before STARTUP_HOOKS in the key/value arrays because STARTUP_HOOKS must stay last (it's conditionally dropped by decrementing the property count).

Depends on dotnet/runtime#128734 flowing into our runtime pack.

Fixes: #25578

🤖 Pull request created by Copilot

…ind System.Private.CoreLib.dll

dotnet/runtime#128734 added a new well-known host property,
SYSTEM_CORELIB_DIRECTORY, that lets the host explicitly specify the
directory containing System.Private.CoreLib.dll. This is needed because
dotnet/runtime#128278 removed the TPA-scanning fallback in BindToSystem,
which broke scenarios (such as ours) where coreclr isn't located next to
System.Private.CoreLib.dll.

Compute the directory containing System.Private.CoreLib.dll (the bundle
directory or the runtimeidentifier-specific subdirectory) and pass it as
the SYSTEM_CORELIB_DIRECTORY property when initializing the runtime. An
empty value (when the file isn't found) is treated by the runtime as if
the property wasn't set.

Fixes #25578

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne marked this pull request as ready for review July 10, 2026 09:42
Copilot AI review requested due to automatic review settings July 10, 2026 09:42

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 updates the macios CoreCLR host initialization to explicitly provide CoreCLR with the directory containing System.Private.CoreLib.dll, using the new SYSTEM_CORELIB_DIRECTORY well-known host property. This addresses the removal of CoreCLR’s prior implicit TPA-scanning fallback and prevents failures when coreclr is not co-located with CoreLib in the app bundle.

Changes:

  • Added xamarin_compute_system_corelib_directory () to locate the directory that contains System.Private.CoreLib.dll (bundle root or RID-specific subdirectory).
  • Passed SYSTEM_CORELIB_DIRECTORY into xamarin_bridge_vm_initialize during xamarin_vm_initialize (keeping STARTUP_HOOKS last due to existing truncation logic).
  • Registered SYSTEM_CORELIB_DIRECTORY as a reserved runtimeconfig property in Xamarin.Shared.Sdk.targets so it can be safely passed to the VM.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
runtime/runtime.m Computes and supplies SYSTEM_CORELIB_DIRECTORY to CoreCLR initialization, and frees the allocated value.
dotnet/targets/Xamarin.Shared.Sdk.targets Adds SYSTEM_CORELIB_DIRECTORY to _RuntimeConfigReservedProperties to allow passing it through runtimeconfig parsing.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 4ad0d7c597bd41515b84a01d53e4cccc65ba9e72 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #4ad0d7c] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 199 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 18 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 4ad0d7c597bd41515b84a01d53e4cccc65ba9e72 [PR build]

@rolfbjarne rolfbjarne enabled auto-merge (squash) July 10, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use SYSTEM_CORELIB_DIRECTORY to specify where CoreCLR can find System.Private.CoreLib.dll

3 participants