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

Don't trim PNSE assemblies and enable trimming for inbox assets on all .NETCoreApp versions #58345

Merged
merged 2 commits into from
Oct 25, 2021

Conversation

ViktorHofer
Copy link
Member

@ViktorHofer ViktorHofer commented Aug 30, 2021

Don't trim platform not supported assemblies, since even in "library" trimming mode, the trimmer might remove some non-public members if they are not called within the assembly. In the case of PNSE assemblies this is most likely always the case.

Contributes to #58343
More information in dotnet/linker#2238

Don't trim platform not supported assemblies, since even in "library" trimming mode, the trimmer might remove some non-public members if they are not called within the assembly. In the case of PNSE assemblies this is most likely always the case.
@ghost
Copy link

ghost commented Aug 30, 2021

Tagging subscribers to this area: @Anipik, @safern, @ViktorHofer
See info in area-owners.md if you want to be subscribed.

Issue Details

Don't trim platform not supported assemblies, since even in "library" trimming mode, the trimmer might remove some non-public members if they are not called within the assembly. In the case of PNSE assemblies this is most likely always the case.

Author: ViktorHofer
Assignees: ViktorHofer
Labels:

area-Infrastructure-libraries

Milestone: -

@ViktorHofer ViktorHofer marked this pull request as ready for review August 30, 2021 12:06
@ViktorHofer ViktorHofer changed the title Don't trim PNSE assemblies Don't trim PNSE assemblies and enable trimming for inbox assets on all .NETCoreApp versions Aug 30, 2021
@stephentoub
Copy link
Member

Why are we doing this? If the issue is that implementations of public interfaces are getting trimmed as part of the library build, we should fix the linker / linker configuration to not do that. I don't think we should disable trimming entirely for these PNSE assemblies just because of that. If there are other reasons to disable the trimming, I'd like to understand them.

@ViktorHofer
Copy link
Member Author

ViktorHofer commented Aug 30, 2021

A PNSE assembly has the same compilation input as a reference assembly, the reference source (but transformed to throw PNSE). If we don't leverage the linker for one (ref), why would we want to use it for the other (PNSE) when the compilation input is nearly identical? A PNSE assembly throws at runtime regardless, so why is it important if it's "library" linked or not?

From a size perspective, System.Security.AccessControl's reference assembly is 28KB small vs. the linked PNSE source assembly which is 36KB small vs. the unlinked PNSE source assembly which is 53KB small.

@ViktorHofer
Copy link
Member Author

If we think that the size reduction makes sense then I'm happy to close this in favor of fixing the "library" linker mode.

Note the discussion in #58343 which revealed that many shipping .NETCoreApp assets aren't trimmed.

@ViktorHofer
Copy link
Member Author

Actually, let me close this right now. Thanks for raising your concern @stephentoub, I agree with you on this. Fortunately this revealed a bigger issue which we will follow-up on as part of #58343.

@ViktorHofer ViktorHofer deleted the ViktorHofer-dont-trim-pnses branch August 30, 2021 15:28
@ghost ghost locked as resolved and limited conversation to collaborators Sep 29, 2021
@ViktorHofer ViktorHofer restored the ViktorHofer-dont-trim-pnses branch September 30, 2021 08:51
@ViktorHofer ViktorHofer reopened this Sep 30, 2021
@ViktorHofer
Copy link
Member Author

/azp run runtime

1 similar comment
@ViktorHofer
Copy link
Member Author

/azp run runtime

@ViktorHofer
Copy link
Member Author

After quite a long discussion in, dotnet/linker#2238 we came to the conclusion that trimming PNSE assemblies is not worth the cost (extra linker invocations).

The failing linker tests are known and already handled by #60836 and others.

@ViktorHofer ViktorHofer merged commit 38cd1d6 into main Oct 25, 2021
@ViktorHofer ViktorHofer deleted the ViktorHofer-dont-trim-pnses branch October 25, 2021 17:00
Comment on lines +60 to +61
'$(GeneratePlatformNotSupportedAssembly)' != 'true' and
'$(GeneratePlatformNotSupportedAssemblyMessage)' == ''">true</ILLinkTrimAssembly>
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to check both GeneratePlatformNotSupportedAssembly and GeneratePlatformNotSupportedAssemblyMessage? Why isn't '$(GeneratePlatformNotSupportedAssembly)' != 'true' enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants