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

[main] Update dependencies from dotnet/linker #67701

Merged
merged 18 commits into from
Apr 22, 2022

Conversation

dotnet-maestro[bot]
Copy link
Contributor

@dotnet-maestro dotnet-maestro bot commented Apr 7, 2022

This pull request updates the following dependencies

From https://github.com/dotnet/linker

  • Subscription: 0d6d6ae4-f71f-4395-53e6-08d8e409d87d
  • Build: 20220420.4
  • Date Produced: April 21, 2022 12:19:25 AM UTC
  • Commit: 6374217e191b8cef0c5a3d862f4291583eb959f4
  • Branch: refs/heads/main

…406.2

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22205.1 -> To Version 7.0.100-1.22206.2
@vitek-karas
Copy link
Member

I'll be looking into the linker warning failure.

dotnet-maestro bot and others added 2 commits April 8, 2022 12:25
…407.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22205.1 -> To Version 7.0.100-1.22207.1
The GetSerializationCtor doesn't seem to be used. It's actually not in the build output since it's trimmed away. With the improved linker it produces a warning (correctly), but as it's not needed, it can be removed.
@dotnet-maestro dotnet-maestro bot requested a review from marek-safar as a code owner April 8, 2022 19:37
@lewing
Copy link
Member

lewing commented Apr 9, 2022

@vitek-karas latest failures look real

…408.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22205.1 -> To Version 7.0.100-1.22208.1
@vitek-karas
Copy link
Member

Thanks @lewing - I know. The fix is relatively simple, but I would rather figure out "why" first.

/cc @marek-safar as this is likely related to the constant propagation change (I don't know for sure though)

The failure is on Mono only.
What happens is:

  • We build System.Private.CoreLib and it includes ResourceReader.InitializeBinaryFormatter method
  • We trim System.Private.CoreLib in library mode
    • This removed the InitializeBinaryFormatter method
    • Note that the method is private and doesn't implement any interface method
  • We then run the "framework" (sfx) run of linker on the output (all libraries at once to gather warning)
    • The ILLinkSubstitutions.Shared.xml in System.Private.CoreLib has a line which substitutes the InitializeBinaryFormatter method with a false
    • This produces a warning since the method doesn't exist in the input

Note: It's intentional that linker warns if there are methods in substitution XML which don't resolve. This is to protect against typos, as it would be really easy to make a typo, no failure happens anywhere, but the substitution didn't work.

This probably means that the method is not used on Mono and the new linker can remove the InitializeBinaryFormatter method in the Mono build now, while older version couldn't do it.

CoreCLR probably has a hard reference to the method and thus linker has to keep it.

What we need to do:

  • Figure out if the above theory is correct
  • Figure out what change in the linker caused the removal of the method - and if it's actually correct
  • If the above comes out OK, the fix would be to move the substitution for InitializeBinaryFormatter into the CoreCLR specific part of substitutions for CoreLib.

@vitek-karas
Copy link
Member

/cc @sbomer as my backup as I'm feeling a bit ill and it might take a while for me to figure this out.

@marek-safar marek-safar force-pushed the darc-main-9714be7e-f6e4-4abc-923d-558ca47ea2b8 branch from 9065f46 to 3ae2982 Compare April 11, 2022 16:48
@marek-safar marek-safar force-pushed the darc-main-9714be7e-f6e4-4abc-923d-558ca47ea2b8 branch from 3ae2982 to dcf8462 Compare April 11, 2022 17:40
@sbomer
Copy link
Member

sbomer commented Apr 11, 2022

I'll take a look to see if I can confirm the theory.

@sbomer
Copy link
Member

sbomer commented Apr 12, 2022

@vitek-karas your theory is pretty much correct. The missing detail was that mono-wasm has a substitution that stubs out InitializeBinaryFormatter:

<method signature="System.Boolean InitializeBinaryFormatter()" body="stub" value="false" />

So that gets inlined when building SPC for wasm and the method isn't marked.

Maybe a way to fix this is to remove the wasm-specific substitution, and instead stub it out by passing a feature setting to the linker (EnableUnsafeBinaryFormatterSerialization = false) - since the substitution is effectively saying that the feature is unsupported on wasm, and it seems redundant to declare the stub in two places. But this would need to be set for the shared fx link and also when linking in the SDK.

Or we could ensure that the shared fx substitutions for wasm don't contain the feature switch definition, by moving it to a separate XML file for non-wasm targets only - probably the quickest solution.

Generally I think the feature switches need a mechanism to "remember" that a feature setting got baked in. We are doing optimizations based on a baked-in value but are still shipping with an XML that declares that corelib supports the feature switch - and now that we are doing more optimizations based on the setting it's causing problems. @marek-safar curious what you think.

…411.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22205.1 -> To Version 7.0.100-1.22211.1
@marek-safar
Copy link
Contributor

@sbomer / @vitek-karas I think it's ok to remove this "outliner" from ILLink.Substitutions.wasm.xml. The SDK already set EnableUnsafeBinaryFormatterSerialization to false by default for every other project anyway.

Another option could be to not apply substitutions during library build but I'm not convinced that's the right fix for this case.

marek-safar and others added 4 commits April 12, 2022 19:04
…412.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22205.1 -> To Version 7.0.100-1.22212.1
…413.2

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22205.1 -> To Version 7.0.100-1.22213.2
@ViktorHofer
Copy link
Member

@marek-safar @sbomer @vitek-karas kindly asking for an update on the PR as my change depends on the newer linker version and is currently blocked.

@sbomer
Copy link
Member

sbomer commented Apr 15, 2022

@marek-safar the icu test is still failing on some platforms:

Assert.NotNull() Failure
   at System.Globalization.Tests.IcuTests.IcuShouldBeUsedByDefault() in /_/src/libraries/System.Globalization/tests/IcuTests.cs:line 38

IcuGetCultureDataFromRegionName is probably getting inlined causing your new assert to fail:

private static CultureData? IcuGetCultureDataFromRegionName() => null;

dotnet-maestro bot and others added 5 commits April 19, 2022 12:28
…418.2

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22205.1 -> To Version 7.0.100-1.22218.2
…419.2

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22205.1 -> To Version 7.0.100-1.22219.2
…ub.com:dotnet/runtime into darc-main-9714be7e-f6e4-4abc-923d-558ca47ea2b8
marek-safar and others added 3 commits April 21, 2022 14:11
…420.4

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22205.1 -> To Version 7.0.100-1.22220.4
The analyzer was kicking in producing warnings. The sgen tool is not going to be trimmed, so there's no point running the analyzer on it.
@marek-safar
Copy link
Contributor

Failures are unrelated

@marek-safar marek-safar merged commit de73d82 into main Apr 22, 2022
@marek-safar marek-safar deleted the darc-main-9714be7e-f6e4-4abc-923d-558ca47ea2b8 branch April 22, 2022 07:32
@ViktorHofer
Copy link
Member

@marek-safar The tar issues were already fixed but unsure about the wasm failure. I filed an issue for the new runtime failure so that the area owners know about flakiness in that test: #68376.

@AndyAyersMS
Copy link
Member

AndyAyersMS commented Apr 27, 2022

Possible regression (though no clue why this change would lead to these tests regressing):

@ghost ghost locked as resolved and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-codeflow for labeling automated codeflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants