Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for symbol stripping #70233

Merged

Conversation

am11
Copy link
Member

@am11 am11 commented Jun 4, 2022

Usage:

dotnet publish -c Release -p:PublishAot=true -p:StripSymbols=true --use-current-runtime

Also added a fallback for compiler introspection (clang or gcc).

Fixes #69847

@am11 am11 requested a review from MichalStrehovsky as a code owner June 4, 2022 03:10
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Jun 4, 2022
@am11 am11 requested a review from jkotas June 4, 2022 03:10
@am11 am11 force-pushed the feature/nativeaot/symbols-stripping branch from bedd546 to a531506 Compare June 4, 2022 05:19
@hez2010
Copy link
Contributor

hez2010 commented Jun 4, 2022

How about making StripSymbols default to true?

@am11
Copy link
Member Author

am11 commented Jun 4, 2022

How about making StripSymbols default to true?

Per @MichalStrehovsky's findings #69847 (comment), other (comparable) toolchains produce unstripped binaries by default.

@jkotas
Copy link
Member

jkotas commented Jun 4, 2022

Could you please also update https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/optimizing.md#special-considerations-for-linuxmacos ?

@am11 am11 force-pushed the feature/nativeaot/symbols-stripping branch from c9aad9e to fc7aeab Compare June 4, 2022 21:05
@am11 am11 force-pushed the feature/nativeaot/symbols-stripping branch from 8b0b86b to 5cf5a88 Compare June 4, 2022 22:14
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@am11 am11 force-pushed the feature/nativeaot/symbols-stripping branch from 5cf5a88 to cca2f7e Compare June 4, 2022 23:10
Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thank you!

@jkotas
Copy link
Member

jkotas commented Jun 5, 2022

@MichalStrehovsky Could you please review this as well?

@Suchiman
Copy link
Contributor

Suchiman commented Jun 5, 2022

How is this different from setting <DebugSymbols>false, which respectively sets <NativeDebugSymbols>false which enables stripping by appending -Wl,--strip-debug to the linker args?

@MichalStrehovsky
Copy link
Member

MichalStrehovsky commented Jun 5, 2022

How is this different from setting <DebugSymbols>false, which respectively sets <NativeDebugSymbols>false which enables stripping by appending -Wl,--strip-debug to the linker args?

<DebugSymbols>false</DebugSymbols> will throw away all debugging information on all platforms.

The new <StripSymbols> option places debugging information on non-Windows systems into a separate file, similar to Windows PDB.

Copy link
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

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

Thank you!

@am11
Copy link
Member Author

am11 commented Jun 6, 2022

StripSymbols strips away all the unneeded symbols from binary and place them into a separate file, not just the debug symbols.

Original size of Hello World executable on linux: 18 MB
With -p:NativeDebugSymbols=false: 11 MB
With -p:StripSymbols=true: 5.7 MB

@MichalStrehovsky
Copy link
Member

The NativeAOT leg failed because there was a Helix delay of 1 hour and 40 minutes for System.IO.FileSystem.Tests:

"Queued":"2022-06-06T04:42:54.942+00:00",
"Started":"2022-06-06T06:23:06.736+00:00",
"Finished":"2022-06-06T06:23:07.158+00:00",
"Delay":"01:40:11.7940000",
"Duration":"00:00:00.4220000"

We'll have to see if this is a pattern.

Cc @LakshanF just FYI

@MichalStrehovsky MichalStrehovsky merged commit 374f788 into dotnet:main Jun 6, 2022
@am11 am11 deleted the feature/nativeaot/symbols-stripping branch June 6, 2022 09:10
@ghost ghost locked as resolved and limited conversation to collaborators Jul 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Symbol stripping in NativeAOT to reduce binary size
5 participants