Skip to content

Re-enable symbol stripping for Apple platforms#124266

Draft
kotlarmilos wants to merge 17 commits intodotnet:mainfrom
kotlarmilos:bugfix/enable-strip-symbols
Draft

Re-enable symbol stripping for Apple platforms#124266
kotlarmilos wants to merge 17 commits intodotnet:mainfrom
kotlarmilos:bugfix/enable-strip-symbols

Conversation

@kotlarmilos
Copy link
Member

@kotlarmilos kotlarmilos commented Feb 11, 2026

Description

This PR re-enables symbol stripping for Apple platforms that was disabled as a workaround in #123687.

Changes

  1. Re-enable stripping in ILCompiler_publish.csproj, crossgen2_publish.csproj, ilasm.csproj, and XUnitLogChecker.csproj by removing the StripSymbols=false workaround.

  2. Handle non-fatal dsymutil warnings by adding IgnoreStandardErrorWarningFormat="true" to the dsymutil <Exec> tasks in Microsoft.NETCore.Native.targets, Microsoft.NET.CrossGen.targets, and native-library.targets. Apple's pre-built Swift runtime static libraries (swiftCore, swiftFoundation) contain DWARF debug info with -gmodules references to .pcm module cache files that only existed on Apple's build machines. dsymutil outputs error: messages for these missing files but exits with code 0 (non-fatal). Without this flag, MSBuild's <Exec> task parses the output for error: patterns and incorrectly counts them as build errors. Non-zero exit codes (real failures) are still caught.

  3. Fix Apple platform detection in eng/toolAot.targets for NativeSymbolExt and DsymUtilOptions. The _IsApplePlatform property from the NativeAOT NuGet package is not available at this evaluation point, so use PortableOS instead. Broadened the condition to UseNativeAotForComponents (from AotOrSingleFile and UseNativeAotForComponents) to cover components like XUnitLogChecker that set PublishAot directly.

Fixes #123687

Copy link
Contributor

Copilot AI left a comment

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 re-enables symbol stripping for Apple platforms by removing a temporary workaround that was added in PR #123386. The workaround disabled symbol stripping (StripSymbols=false) to avoid dsymutil module cache errors that occurred when Swift code was compiled with -g (full debug info). Now that the underlying Swift compilation has been fixed to use -gline-tables-only instead, symbol stripping can be safely re-enabled.

Changes:

  • Removes StripSymbols=false workaround from three .csproj files (ILCompiler, crossgen2, and XUnitLogChecker)
  • Adds symbol stripping logic to the CrossGen2 test script for Apple mobile runtime tests

Reviewed changes

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

File Description
src/coreclr/tools/aot/ILCompiler/ILCompiler_publish.csproj Removes the StripSymbols=false workaround, allowing default symbol stripping behavior to apply
src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj Removes the StripSymbols=false workaround, allowing default symbol stripping behavior to apply
src/tests/Common/XUnitLogChecker/XUnitLogChecker.csproj Removes the StripSymbols=false workaround, allowing default symbol stripping behavior to apply
src/tests/Common/CLRTest.CrossGen.targets Adds symbol stripping command after linking for Mach-O format outputs when StripSymbols is true

Copilot AI review requested due to automatic review settings February 27, 2026 09:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

@kotlarmilos
Copy link
Member Author

The macOS jobs are still reporting missing module cache files (.pcm).

Copilot AI review requested due to automatic review settings March 4, 2026 13:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 16, 2026 11:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

kotlarmilos and others added 2 commits March 16, 2026 17:39
The NativeAOT SDK targets invoke dsymutil during symbol stripping. Apple's
pre-built Swift runtime static libraries contain -gmodules debug info with
references to .pcm module cache files that don't exist on build machines.
dsymutil outputs 'error:' for these missing files but exits 0 (non-fatal).
MSBuild's Exec task parses the output and treats them as build errors.

The tool AOT publish (ILCompiler, crossgen2, XUnitLogChecker) uses the SDK's
NativeAOT targets, not the source-tree targets, so the IgnoreStandardError
WarningFormat fix in Microsoft.NETCore.Native.targets doesn't apply here.
Redirecting dsymutil stderr via DsymUtilOptions suppresses the non-fatal
warnings while preserving exit code based error detection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 17, 2026 16:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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


You can also share your feedback on Copilot code review. Take the survey.

kotlarmilos and others added 2 commits March 18, 2026 10:53
dsymutil outputs 'error: <path>.pcm: No such file or directory' messages
to stdout (not stderr) when processing binaries linked against Apple's
Swift runtime static libraries. The previous 2>/dev/null only suppressed
stderr, leaving stdout errors visible to MSBuild's error pattern matching.

Change to >/dev/null 2>&1 to suppress both streams since dsymutil's
diagnostic output is not needed (the .dwarf file is the actual output).
This fix applies regardless of whether local or NuGet package NativeAOT
targets are used, since DsymUtilOptions is set in eng/toolAot.targets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the Apple platform settings (DsymUtilOptions, NativeSymbolExt) out of
the AotOrSingleFile condition gate into a UseNativeAotForComponents-only
PropertyGroup. This ensures projects like XUnitLogChecker that set
PublishAot directly (without AotOrSingleFile) also get the dsymutil stdout
suppression needed to avoid non-fatal PCM error messages breaking the build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 18, 2026 12:52
@kotlarmilos kotlarmilos marked this pull request as draft March 18, 2026 12:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.


You can also share your feedback on Copilot code review. Take the survey.

- Revert -gline-tables-only from src/native/libs/CMakeLists.txt
- Revert -gnone back to -gline-tables-only for Swift compilation
- Revert CLRTest.CrossGen.targets stripping change
- Remove >/dev/null 2>&1 from DsymUtilOptions (redundant with IgnoreStandardErrorWarningFormat)
- Consolidate PropertyGroups in eng/toolAot.targets

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 20, 2026 09:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

<PropertyGroup Condition="'$(AotOrSingleFile)' == 'true' and '$(UseNativeAotForComponents)' == 'true'">
<PublishAot>true</PublishAot>
<PropertyGroup Condition="'$(UseNativeAotForComponents)' == 'true'">
<PublishAot Condition="'$(AotOrSingleFile)' == 'true'" >true</PublishAot>
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space before the closing angle bracket in the <PublishAot ...> element (... == 'true'" >true). This is inconsistent with the surrounding XML formatting and should be removed to keep the file tidy and avoid noisy diffs in future edits.

Suggested change
<PublishAot Condition="'$(AotOrSingleFile)' == 'true'" >true</PublishAot>
<PublishAot Condition="'$(AotOrSingleFile)' == 'true'">true</PublishAot>

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove StripSymbols workaround for macOS NativeAOT publish once Swift module debug fix is available

4 participants