Repository navigation
[release/11.0.1xx] [build] Avoid registrar compilation for MVID-only edits. Fixes #26728 - #26824
Conversation
The CoreCLR trimmable static registrar previously embedded every registered assembly MVID in registrar.mm. An app-only IL edit therefore changed the large Objective-C++ file and made Clang recompile it even when all registration metadata was stable. Emit the assembly table in a small registrar-assemblies.mm translation unit with an external C symbol, and include both sources and their object files in incremental build and clean tracking. Cover two real managed edits, the linked MVID, reuse of the large registrar object, a registered-method change, and Mac Catalyst runtime registration in an integration test; document the generated layout. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
For CoreCLR trimmable-static builds targeting arm64 or x86_64, write assembly names and MVIDs into a relocatable Mach-O object with the exported registration symbol and section-relative pointer relocations. This eliminates the separate Objective-C++ compilation on MVID-only edits while preserving native relinking and the source-based fallback for other architectures. Pass the generated object directly to the native linker, track it for incremental linking and clean, and cover the binary layout and iOS and Mac Catalyst registration behavior with regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35b7dbf0-b000-4ac5-9769-8fe0f272f9e9
Mac Catalyst records an iOS-style SDK version in its Mach-O build-version command, which can differ from the underlying macOS SDK version. Pass the converted SDK version already held by Application so emitted objects keep matching the platform metadata produced by Clang. Exercise a real dotnet clean in the incremental registrar test instead of the test helper that deletes bin and obj directories directly. This checks that the generated assembly object is removed by the build system. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35b7dbf0-b000-4ac5-9769-8fe0f272f9e9
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation is consistent with the linker pipeline and includes focused binary-layout, runtime, incremental-build, and cleanup coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Optimizes CoreCLR trimmable-static registrar builds by separating volatile assembly MVID data from registrar.mm.
Changes:
- Emits arm64/x86_64 assembly tables directly as Mach-O objects.
- Updates incremental compilation, linking, and cleanup.
- Adds layout, runtime, and incremental regression tests.
| File | Description |
|---|---|
tools/mtouch/mtouch.csproj |
Includes the object writer. |
tools/dotnet-linker/Steps/RegistrarStep.cs |
Selects object or source emission. |
tools/dotnet-linker/dotnet-linker.csproj |
Includes the object writer. |
tools/common/StaticRegistrar.cs |
Separates MVID data from registrar code. |
tools/common/RegistrarAssembliesObjectWriter.cs |
Generates relocatable Mach-O objects. |
tools/common/MachO.cs |
Adds required Mach-O constants. |
tools/assembly-preparer/assembly-preparer.csproj |
Includes the object writer. |
tests/dotnet/UnitTests/RegistrarTest.cs |
Tests incremental and runtime behavior. |
tests/dotnet/UnitTests/RegistrarAssembliesObjectWriterTest.cs |
Validates emitted object layout. |
tests/dotnet/UnitTests/DotNetUnitTests.csproj |
Includes writer tests. |
dotnet/targets/Xamarin.Shared.Sdk.targets |
Tracks, links, and cleans generated objects. |
docs/managed-static-registrar.md |
Documents the optimized flow. |
✅ 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 |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #45792c5] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 269 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Summary
An app-only IL edit changes its assembly MVID without changing registration metadata. Previously, embedding that MVID in
registrar.mmcaused Clang to recompile the entire large Objective-C++ registrar source.registrar.mmstable across MVID-only edits and emit the ordered assembly-name/MVID table directly asregistrar-assemblies.ofor arm64 and x86_64. The object contains the exported registration symbol, pointer relocations, and platform-specific Mach-O build-version metadata.registrar.mm.Performance
For the same 193-assembly table, 30 warm scratch-prototype runs took a median of 168 ms to compile with Clang versus 41 ms to emit directly from a Node process. Production writes the object in-process; these numbers are not an end-to-end app-build measurement. Native relinking is still required.
Fixes #26728
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
Backport of #26747.