[runtime] Use SYSTEM_CORELIB_DIRECTORY to locate System.Private.CoreLib.dll#26009
[runtime] Use SYSTEM_CORELIB_DIRECTORY to locate System.Private.CoreLib.dll#26009rolfbjarne wants to merge 1 commit into
Conversation
…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>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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 containsSystem.Private.CoreLib.dll(bundle root or RID-specific subdirectory). - Passed
SYSTEM_CORELIB_DIRECTORYintoxamarin_bridge_vm_initializeduringxamarin_vm_initialize(keepingSTARTUP_HOOKSlast due to existing truncation logic). - Registered
SYSTEM_CORELIB_DIRECTORYas a reserved runtimeconfig property inXamarin.Shared.Sdk.targetsso 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. |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
🚀 [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 macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
dotnet/runtime#128278 removed the TPA-scanning fallback in CoreCLR's
BindToSystem, which broke scenarios (like ours) wherecoreclrisn't located next toSystem.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:
xamarin_compute_system_corelib_directory ()inruntime/runtime.m, which looks forSystem.Private.CoreLib.dllin the bundle directory and the runtimeidentifier-specific subdirectory, and returns the directory that contains it.SYSTEM_CORELIB_DIRECTORYproperty when initializing the runtime inxamarin_vm_initialize.SYSTEM_CORELIB_DIRECTORYin the_RuntimeConfigReservedPropertieslist inXamarin.Shared.Sdk.targets(all properties passed to the VM must be listed there).Notes for reviewers:
STARTUP_HOOKSin the key/value arrays becauseSTARTUP_HOOKSmust 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