[msbuild] Fix app crash at launch when _ExportSymbolsExplicitly=false. Fixes #25491#25494
[msbuild] Fix app crash at launch when _ExportSymbolsExplicitly=false. Fixes #25491#25494rolfbjarne wants to merge 5 commits into
Conversation
…Fixes #25491. When _ExportSymbolsExplicitly=false, the strip command was running without any flags on the main executable, which strips all symbols including ones the runtime needs, causing the app to crash at launch. Fix by: 1. Always passing the symbol file to strip (reverting the condition from PR #24800). 2. Making the SymbolStrip task resilient: if the symbol file doesn't exist (e.g. Windows remote builds), fall back to '-S -x' (strip debug and local symbols only) instead of bare 'strip'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Instead of falling back to different strip behavior when the symbol file is missing, ensure the file is always transferred to the remote Mac by implementing GetAdditionalItemsToBeCopied in the SymbolStrip task. This ensures remote builds behave identically to local builds. Co-authored-by: Copilot <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.
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.
The GetAdditionalItemsToBeCopied() method needs the local (Windows) path to know which file to copy to the remote Mac build server. Added a SymbolFileLocalPath property that holds the local path while SymbolFile retains the Mac-resolved path for the actual strip command. Co-authored-by: Copilot <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.
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
Fixes a launch-time crash caused by invoking strip without arguments when _ExportSymbolsExplicitly=false, by ensuring the exported-symbol list is still used during symbol stripping (and is available in remote builds).
Changes:
- Always provide the symbols list file to the post-processing
stripstep (regardless of_ExportSymbolsExplicitly). - Extend the
SymbolStripMSBuild task to include the symbols list among files copied to the remote Mac (Windows→Mac builds). - Add a unit test validating that required runtime symbols remain after stripping with
_ExportSymbolsExplicitly=false.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
msbuild/Xamarin.Shared/Xamarin.Shared.targets |
Always supplies the symbol list to SymbolStrip and threads through a local-path metadata for remote copy support. |
msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs |
Adds SymbolFileLocalPath and begins implementing remote-copy support via GetAdditionalItemsToBeCopied(). |
tests/dotnet/UnitTests/ProjectTest.cs |
Adds a regression test for stripping with _ExportSymbolsExplicitly=false. |
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.
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.
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.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #9170dd6] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [PR Build #9170dd6] Build passed (Build packages) ✅Pipeline on Agent |
✅ 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 |
✅ [PR Build #9170dd6] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #9170dd6] 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 |
When
_ExportSymbolsExplicitly=false, thestripcommand was running without any flags on the main executable, stripping all symbols including ones the runtime needs, causing the app to crash at launch.Changes
msbuild/Xamarin.Shared/Xamarin.Shared.targets— Always pass the symbol file to strip (revert the condition from PR [msbuild] Don't pass symbol file to strip when _ExportSymbolsExplicitly=false. Fixes #24582. #24800 that removed it when_ExportSymbolsExplicitly=false).msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs— ImplementGetAdditionalItemsToBeCopied()to ensure the symbol file is transferred to the remote Mac for Windows→Mac builds, so remote builds behave identically to local builds.tests/dotnet/UnitTests/ProjectTest.cs— AddStrippedWithExportSymbolsExplicitlyFalsetest that builds with_ExportSymbolsExplicitly=false, executes the app, and verifies required symbols remain in the binary.Root cause
PR #24800 fixed a build failure for remote Windows builds by removing the symbol file from the
stripcommand when_ExportSymbolsExplicitly=false. However, running barestrip(without-i -s <symbolfile>) removes all symbols from the main executable, including ones the .NET runtime needs at launch.Fix approach
Instead of conditionally omitting the symbol file, we now:
WriteLinesToFile)GetAdditionalItemsToBeCopied()This ensures consistent behavior between local and remote builds.
Fixes #25491
🤖 Pull request created by Copilot