Skip to content

[NativeAOT] Set TrimmerDefaultAction to link #1972

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

Merged
merged 1 commit into from
Mar 29, 2022
Merged

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented Mar 29, 2022

To ensure that trimmer only analyzes the parts of the dependencies that are used. With this setting, the build time for our samples project goes from 116 to 15 seconds! I've tested it with dotnet/performance microbenchmarks and everything works fine. In case it does not, users can still disable it:

builder.SeTrimmerDefaultAction("");

cc @MichalStrehovsky

… the parts of the dependencies that are used
@adamsitnik adamsitnik added this to the v0.13.2 milestone Mar 29, 2022
@adamsitnik adamsitnik merged commit 19679de into master Mar 29, 2022
@adamsitnik adamsitnik deleted the TrimmerDefaultAction branch March 29, 2022 15:08
Comment on lines +193 to +204
{
StringBuilder sb = new StringBuilder();

sb.AppendLine(rootAllApplicationAssemblies ? "<PublishTrimmed>false</PublishTrimmed>" : "<TrimMode>link</TrimMode>");

if (!string.IsNullOrEmpty(trimmerDefaultAction))
{
sb.Append($"<TrimmerDefaultAction>{trimmerDefaultAction}</TrimmerDefaultAction>");
}

return sb.ToString();
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: these setting got aligned with IL Linker defaults, so it's now:

  • PublishTrimmed is implied to be always true when publishing with NativeAOT. At least the framework needs to be trimmed because the experience of not trimming that is just really bad.
  • Application assemblies are rooted by default. One can opt them into trimming with <TrimmerDefaultAction>link</TrimmerDefaultAction>

So one could actually fold this into the existing bool rootAllApplicationAssemblies: if it's true, do nothing. If it's false, add <TrimmerDefaultAction>link</TrimmerDefaultAction>.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's almost hidden, but <TrimmerDefaultAction>link</TrimmerDefaultAction> is our default now.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've sent #1975 to address it

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.

2 participants