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

Adding Infrastructure and post build step to run the linker on our OOB assemblies #52133

Closed
wants to merge 5 commits into from

Conversation

joperezr
Copy link
Member

@joperezr joperezr commented Apr 30, 2021

cc: @eerhardt @sbomer @krwq @vitek-karas @ViktorHofer

fixes #48488

This is mostly ready for review except that I'm still hitting dotnet/linker#1416 and trying to find the best way to suppress these warnings which for now are causing the build to fail. That means this PR isn't ready to go in, but sending it out for now to get initial feedback on the infrastructure.

This approach is mostly following the advise we are giving library devs here: https://github.com/dotnet/docs/blob/main/docs/core/deploying/prepare-libraries-for-trimming.md. We are only adding a few additional targets that are accounting for the fact that we have a slightly complex build system, but other than that this is mostly following the guidance on those docs provided by @sbomer

@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.

@joperezr joperezr added the linkable-framework Issues associated with delivering a linker friendly framework label Apr 30, 2021
@ghost
Copy link

ghost commented Apr 30, 2021

Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @sbomer
See info in area-owners.md if you want to be subscribed.

Issue Details

cc: @eerhardt @sbomer @krwq @vitek-karas @ViktorHofer

fixes #48488

This is mostly ready for review except that I'm still hitting dotnet/linker#1416 and trying to find the best way to suppress these warnings which for now are causing the build to fail. Once I figure that out I'll remove the 'Draft' from this PR, but sending it out as a draft for now to get initial feedback on the infrastructure

Author: joperezr
Assignees: -
Labels:

linkable-framework

Milestone: -

@joperezr joperezr force-pushed the AddOOBTrimmingInfrastructure branch from bc68a3a to 760489c Compare May 3, 2021 17:09
Comment on lines +145 to +147
<MSBuild Targets="Restore"
Projects="$(MSBuildThisFileDirectory)trimming\trimming.csproj"
Properties="$(TraversalGlobalProperties);MSBuildRestoreSessionId=$([System.Guid]::NewGuid())" />
Copy link
Member

Choose a reason for hiding this comment

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

Please avoid this extra restore invocation. We worked really hard in the past months / year to reduce extra invocations. If you put the trimming app under a "src" sub-directory it will be restored automatically. Another option would be to add a P2P in pretest.proj trimming.csproj.

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 don't think adding a P2P is the right thing to do in this case, specially since it is a Console application project and not a library, but I'll see how I can avoid this manual restore call.

Copy link
Member

Choose a reason for hiding this comment

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

That doesn't prevent the P2P. We do have a lot P2Ps to executables i.e. the test runners. Just make sure to set ReferenceOutputAssembly to false.

@@ -138,5 +138,20 @@
RootAttributes="@(FrameworkListRootAttribute)" />
</Target>

<Target Name="ILLinkTrimOOBLibraries"
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason that you aren't doing this in src.proj where we also trim the inbox ones?

Copy link
Member

Choose a reason for hiding this comment

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

Is it that you need a ready to use runtime pack?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do the shared framework on src.proj because we are manually invoking the linker and editing the command that we run, while for the OOBs we are instead following the steps we are asking third party library devs to follow but for that to work, we need to have the RuntimeList.xml file already generated in order to be able to build trimming.csproj against the produced shared framework, and that only happens after pretest.proj.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it that you need a ready to use runtime pack?

Yup, exactly

Copy link
Member

Choose a reason for hiding this comment

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

Hmm does that mean we can't restore before the runtime pack is available? If yes, did we consider treating this as a test instead of the product build? I.e. sourcebuild likely doesn't care about this logic.

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<linker>
<assembly fullname="System.Private.DataContractSerialization, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this. I thought you fixed this assembly in #50619. Why are we getting these 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 think this is because the wrong configuration of System.Private.DataContractSerialization is getting picked. One more reason why not to go with this approach I guess.

@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<linker>
<assembly fullname="System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
Copy link
Member

Choose a reason for hiding this comment

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

ConfigurationManager is not trimmable. See #49085. We probably don't need to waste time analyzing this assembly until we try to make it trimmable (which isn't in the near future).

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<linker>
<assembly fullname="System.ComponentModel.TypeConverter, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be needed. We have a LibraryBuild.xml file, and should be respecting that

Copy link
Member

Choose a reason for hiding this comment

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

Actually, in a perfect world, we shouldn't be analyzing the System.ComponentModel.TypeConverter library at all during the OOB trim analysis run.

@eerhardt
Copy link
Member

eerhardt commented May 3, 2021

There are a few assemblies here that I think we should set IsTrimmable=false on, and not analyze them at all. Here is my initial list I think we should skip trimming for:

  • System.CodeDom
  • System.ComponentModel.Composition*
  • System.Composition*
  • System.Configuration.ConfigurationManager (already has IsTrimmable=false on the assembly)
  • System.ServiceModel.Syndication ?
  • System.Speech

@joperezr
Copy link
Member Author

joperezr commented May 7, 2021

Closing this as this has been superseded by #52272

@joperezr joperezr closed this May 7, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
@joperezr joperezr deleted the AddOOBTrimmingInfrastructure branch August 11, 2021 21:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable ILLink warning analysis for OOB libraries
4 participants