ci: R2R-compile staged DLLs (crossgen2) before nupkg pack#1
Open
oysteinkrog wants to merge 1 commit intoif/mainfrom
Open
ci: R2R-compile staged DLLs (crossgen2) before nupkg pack#1oysteinkrog wants to merge 1 commit intoif/mainfrom
oysteinkrog wants to merge 1 commit intoif/mainfrom
Conversation
Stock dotnet/wpf DLLs in Microsoft.WindowsDesktop.App ship with ReadyToRun native code, baked in by dotnet/runtime's runtime-pack assembly step. Our fork builds the libraries via build.cmd but does not run that step, so the DLLs we ship in the InitialForce.WPF nupkg are JIT-only. This caused stack overflows in consumers: JIT'd frames are slightly fatter than R2R'd frames, and WPF code paths that are already deep on the stack (dispatcher unhandled-exception handler -> MessageDialog.xaml -> BAML -> WPFLocalizeExtension's 800-culture iteration) overflow the 1 MB thread stack. Add a workflow step that downloads the upstream Microsoft.NETCore.App.Crossgen2.win-x64 NuGet package (cached under .tools-cache/) and runs crossgen2 over the 4 staged DLLs in both packaging trees (InitialForce.WPF and InitialForce.WPF.RuntimeOverride). Each output is verified to contain the R2R magic before replacing the input. --targetarch matches the matrix.arch so we get win-arm64 R2R images for the arm64 build. Verified locally: crossgen2 10.0.7 successfully R2R-compiles all 4 patched DLLs (PresentationCore, PresentationFramework, WindowsBase, System.Xaml). Output sizes grow ~0-145% (varies by symbol density), all contain the RTR magic at the expected offset, and consuming the R2R'd DLLs eliminates the deep-stack SO that the previous nupkgs exhibited. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a crossgen2 (ReadyToRun) compilation step to the nupkg build pipeline so the published `InitialForce.WPF` and `InitialForce.WPF.RuntimeOverride` nupkgs contain native code, matching stock `Microsoft.WindowsDesktop.App` behavior.
Why
Stock dotnet/wpf DLLs ship with R2R native code baked in by dotnet/runtime's runtime-pack assembly step. Our fork builds the libraries via `build.cmd` but does not run that step, so the DLLs in our nupkgs were JIT-only.
JIT'd frames are slightly fatter than R2R'd frames. WPF code paths that are already deep on the stack — notably the dispatcher unhandled-exception handler loading `MessageDialog.xaml` → BAML callbacks → WPFLocalizeExtension's 800-culture iteration — overflowed the 1 MB thread stack in consumers, taking the process down instead of merely showing the user an error.
What changed
Verified locally
Companion fix
There is also a master-side defense-in-depth fix in InitialForce/ScDesktop#6790 that defers error-dialog construction off the deep dispatcher stack. Either fix alone resolves the SO; together they belt-and-suspenders the issue for any consumer of our WPF nupkgs.
Test plan
🤖 Generated with Claude Code