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

[wasm] Fix trimming errors for library tests, to help building with AOT #50885

Closed
wants to merge 32 commits into from

Conversation

radical
Copy link
Member

@radical radical commented Apr 7, 2021

No description provided.

@ghost
Copy link

ghost commented Apr 7, 2021

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

Issue Details
Author: radical
Assignees: -
Labels:

area-Infrastructure-libraries

Milestone: -

@@ -0,0 +1,13 @@
<linker>
Copy link
Member

Choose a reason for hiding this comment

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

All these files should have Descriptors in the name following the naming pattern set by the linker.

See the docs here:
https://github.com/mono/linker/blob/55bd0ebd00ddbf2cd817314b1cf6824003cfb463/docs/data-formats.md#descriptor-format

@@ -0,0 +1,10 @@
<linker>
<assembly fullname="System.Private.DataContractSerialization">
<type fullname="System.Runtime.Serialization.KeyValue`2" />
Copy link
Member

Choose a reason for hiding this comment

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

cc @joperezr - is your change going to make it so this is no longer necessary?

Copy link
Member

Choose a reason for hiding this comment

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

In general, I don't think we should be adding ILLink.Descriptors files for our own assemblies. Instead we should be fixing our assemblies to be trimmable.

<type fullname="System.Runtime.Serialization.KeyValuePairAdapter`2" />
</assembly>
<assembly fullname="System.Private.Xml.Linq">
<type fullname="System.Xml.Linq.XElement" />
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? It shouldn't be.

<linker>
<assembly fullname="System.Data.Common">
<type fullname="System.Data.DataColumn">
<method signature="System.Void .ctor()" />
Copy link
Member

Choose a reason for hiding this comment

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

cc @krwq - is your change going to fix this?

@@ -0,0 +1,7 @@
<linker>
<assembly fullname="System.Private.CoreLib">
<type fullname="System.Collections.ArrayList" />
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? It shouldn't be.

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 was seeing this as:

02:19:20] fail: [FAIL] System.Reflection.Tests.TypeInfoTests.IsAssignable(type: typeof(System.Collections.IList), c: typeof(System.Collections.ArrayList), expected: True)
[02:19:20] info: Assert.Equal() Failure
[02:19:20] info: Expected: True
[02:19:20] info: Actual:   False
[02:19:20] info:    at System.Reflection.Tests.TypeInfoTests.IsAssignable(Type type, Type c, Boolean expected)
[02:19:20] info:    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

radical@3cdf08a

This PR is an attempt to remove the trimming errors, to enable AOT tests to be built. I didn't delve into why the linker wasn't being able to pick up the usage. We could look into that, when I make a clean PR based on main.

<linker>
<assembly fullname="System.Diagnostics.TraceSource">
<type fullname="System.Diagnostics.TraceListener">
<method signature="System.Void .ctor()" />
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why this is necessary? It shouldn't be.

@@ -0,0 +1,7 @@
<linker>
<assembly fullname="System.Diagnostics.TraceSource">
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is a bit unexpected, do you know where is it used?

Copy link
Member

Choose a reason for hiding this comment

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

Agreed - this shouldn't be necessary because all the ILLink warnings are fixed in this assembly. This might be a product bug somewhere.

@@ -0,0 +1,3 @@
<linker>
<assembly fullname="mscorlib" />
Copy link
Member

Choose a reason for hiding this comment

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

Is this still necessary with the latest linker? We had a few fixes that went in to preserve facade assemblies.

@@ -14,5 +14,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestExe\System.Reflection.TestExe.csproj" />

<TrimmerRootDescriptor Include="$(MSBuildThisFileDirectory)..\ILLink.Descriptors.CoreCLR.xml" />
Copy link
Member

Choose a reason for hiding this comment

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

Can this ILLink.Descriptors.CoreCLR.xml file move next to the .csproj that needs it?

@@ -6,6 +6,7 @@
<TestDependsOn Condition="'$(TestNoBuild)' != 'true' and '$(BuildAllProjects)' != 'true'">Build</TestDependsOn>
<TestDependsOn>$(TestDependsOn);GenerateRunScript;RunTests</TestDependsOn>
<VSTestNoLogo>true</VSTestNoLogo>
<ILDescriptorsPath>$(MSBuildThisFileDirectory)ildescriptors\</ILDescriptorsPath>
Copy link
Member

Choose a reason for hiding this comment

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

This needs a better name. How about?

<ILLinkDescriptorsPath>$(MSBuildThisFileDirectory)ILLinkDescriptors\</ILLinkDescriptorsPath>

@eerhardt
Copy link
Member

This file should go in the ILLinkDescriptors folder.


Refers to: eng/testing/ILLink.Descriptors.TestUtilities.xml:1 in e8cb433. [](commit_id = e8cb433, deletion_comment = False)

@@ -0,0 +1,10 @@
<linker>
<assembly fullname="System.Private.DataContractSerialization">
<type fullname="System.Runtime.Serialization.KeyValue`2" />
Copy link
Member

Choose a reason for hiding this comment

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

Are these still necessary on the latest main? @joperezr addressed the ILLink warnings in this assembly, so these might be fixed.

If they aren't fixed, we should open a bug to make sure we don't have a product bug here.

Copy link
Member

Choose a reason for hiding this comment

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

DCS is annotated now but most of it was annotated as unsafe. It would be good to understand who actually needs this so that we can check why is the type not being preserved and to find out if it is expected or not

@@ -0,0 +1,7 @@
<linker>
<assembly fullname="System.Private.CoreLib">
<type fullname="System.Collections.ArrayList" />
Copy link
Member

Choose a reason for hiding this comment

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

This is suprising. Why is this necessary?

<linker>
<assembly fullname="System.Data.Common">
<type fullname="System.Data.DataColumn">
<method signature="System.Void .ctor()" />
Copy link
Member

Choose a reason for hiding this comment

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

fyi @krwq again here

@radical
Copy link
Member Author

radical commented Apr 22, 2021

@eerhardt This PR was based on another big PR which got merged last night. And I had been working on this over the last few weeks. So, it's definitely possible that some of the changes aren't needed anymore, as you suggested.

I'm going to enable all the tests on separate temporary PR, and then apply the fixes that are still useful, and we can have the current error messages etc. Then I can reset the history here.

@marek-safar
Copy link
Contributor

I think it'd be better to enable trimming analyzer warnings for this than trying to guess where stuff can break. We could exclude the 3rd party libs to make it less noisy.

@marek-safar marek-safar added linkable-framework Issues associated with delivering a linker friendly framework and removed area-Build-mono area-Infrastructure-libraries trimming-for-aot `EnableAggressiveTrimming=true` used for running tests with AOT labels Apr 23, 2021
@ghost
Copy link

ghost commented Apr 23, 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
Author: radical
Assignees: -
Labels:

arch-wasm, linkable-framework

Milestone: -

@eerhardt
Copy link
Member

be better to enable trimming analyzer warnings

For our test assemblies? I'm unsure if that would be worth the effort.

@marek-safar
Copy link
Contributor

I'm unsure if that would be worth the effort.

Why? Isn't that what this and probably more upcoming PRs will do?

@eerhardt
Copy link
Member

  1. Addressing ILLink warnings isn't trivial. It takes quite a bit of effort.
  2. The maintenance cost of keeping ILLink warnings out of our tests would be an on-going tax for developers.
  3. It doesn't completely solve the problem, because of 3rd party libraries, as noted above.

@marek-safar
Copy link
Contributor

marek-safar commented Apr 23, 2021

The maintenance cost of keeping ILLink warnings out of our tests would be an on-going tax for developers.

Once this PR goes it that will be the case, every PR touching libraries will have to ensure the tests are not failing with the linker running for the browser's test

@radical
Copy link
Member Author

radical commented Apr 23, 2021

Once this PR goes it that will be the case, every PR touching libraries will have to ensure the tests are not failing with the linker running for the browser's test

It's already enabled on main, see https://dev.azure.com/dnceng/public/_build/results?buildId=1104194&view=logs&j=fddee5b2-3265-5a91-40c1-750d81e69f3f .

@radical
Copy link
Member Author

radical commented Apr 26, 2021

I have re-tested, and applied all the relevant changes with clean commits in #51697 . Some changes weren't needed with the latest main.

Closing this in favor of that PR.

@radical radical closed this Apr 26, 2021
@radical radical deleted the build-wasm-aot-helix-test branch April 26, 2021 22:40
@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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants