Uh oh!
There was an error while loading. Please reload this page.
[main] Update dependencies from mono/linker - #56593
Conversation
dotnet/linker#2145 warns when accessing members annotated with DynamicallyAccessedMembers using reflection, and dotnet/linker#2162 updates the warning origin of warnings for DynamicallyAccessedMembers on types. This adds suppressions for the new warnings.
Microsoft.NET.ILLink.Tasks From Version 6.0.100-preview.6.21378.1 -> To Version 6.0.100-preview.6.21379.2
…5a93356-f7f7-4eda-8c0e-7abec4014df7
eerhardt
commented
Jul 30, 2021
Looks like this is still broken: |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Annotate mono's EnumBuilder and TypeBuilder - Add (non-unique) readable short names to the warning codes
Microsoft.NET.ILLink.Tasks From Version 6.0.100-preview.6.21378.1 -> To Version 6.0.100-preview.6.21380.2
akoeplinger
commented
Aug 2, 2021
A few more trimmer errors in tests: |
e1257f8 to
c353468CompareMicrosoft.NET.ILLink.Tasks From Version 6.0.100-preview.6.21378.1 -> To Version 6.0.100-preview.6.21402.2
| [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2111:RequiresDynamicallyAccessedMembers", | ||
| Justification = "The type parameter to LicenseManager.CreateWithContext method has PublicConstructors annotation. We only invoke this method" + | ||
| "from AllocateAndValidateLicense which annotates the value passed in with the same annotation.")] |
There was a problem hiding this comment.
Yay for extra validation. Caught a bug here...
| // https://github.com/mono/linker/issues/2136 tracks making it possible to add more granular suppressions at the member level, and with a different warning code. | ||
| [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", | ||
| Justification = "The use of GetType preserves members with RequiresUnreferencedCode, but the GetType callsites either " | ||
| [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2113:RequiresUnreferencedCode", |
There was a problem hiding this comment.
(nit) - "IL2113:RequiresUnreferencedCode" should be "IL2113:RequiresDynamicallyAccessedMembers" (or whatever short name we decided to give these new warnings).
This is repeated elsewhere for IL2112 in this file, and other files.
There was a problem hiding this comment.
My thinking was that RequiresUnreferencedCode here was about the DAM-on-type requiring methods annotated with RequiresUnreferencedCode. I renamed it to ReflectionToRequiresUnreferencedCode. Just note that some instances of IL2026 also represent ReflectionToRequiresUnreferencedCode, for instance:
typeof(Foo).GetMethod("RUC");// IL2026classFoo{[RUC("RUC")]publicstaticvoidRUC(){}}| Justification = "The problem is Type.TypeInitializer which requires constructors on the Type instance." + | ||
| "In this case the Type instance is about System.Type itself, so adding an explicit dependency on the same" + | ||
| "annotation here.")] | ||
| [DynamicDependency(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors, typeof(Type))] |
There was a problem hiding this comment.
Does the trimmer treat PublicConstructors | NonPublicConstructors as referencing static cctors?
I'm wondering if this DynamicDependency is truly necessary.
There was a problem hiding this comment.
Yup, it does. Good question about DynamicDependency. I only found one place where the annotation was ultimately used:
If I didn't miss anything I think it's ok to remove.
| // These suppressions can go away with https://github.com/mono/linker/issues/2175 | ||
| [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2113:RequiresUnreferencedCode", | ||
| Justification = "In EventSource, EnsureDescriptorsInitialized's use of GetType preserves methods on Delegate and MulticastDelegate " + | ||
| "because the nested type OverrideEventProvider's base type EventProvider defines a delegate. " + |
There was a problem hiding this comment.
I'm not sure I understand why DiagnosticSourceEventSource is getting warnings for OverrideEventProvider. If it is - why isn't all EventSource's getting this warning?
There was a problem hiding this comment.
The warning is due to DAMT.All on EventSource, which ensures that GetType keeps everything on EventSource - in this case the nested type OverrideEventProvider, plus its base type EventProvider, which has a delegate, which has some RUC methods: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Delegate.cs#L45.
Ideally we wouldn't produce this warning for derived types, and it would show up only on EventSource, but we haven't taught the linker about this (see dotnet/linker#2175).
In theory this should currently show up on every derived EventSource... but I believe due to dotnet/linker#2159 we only produce a warning for the first one that we see. :( /cc @LakshanF
There was a problem hiding this comment.
we only produce a warning for the first one that we see. :(
Oh no, that doesn't sound like a great situation.
There was a problem hiding this comment.
This sounds bad - could it lead to us getting warnings from CoreLib when trimming apps? For some reason linker will see this on another EventSource and will warn there - and it's not suppressed there. We need to fix this if that's the case.
Uh oh!
There was an error while loading. Please reload this page.
| [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2110:RequiresDynamicallyAccessedMembers", | ||
| Justification = "For instance member internal calls, the linker preserves all fields of the declaring type. " + | ||
| "The _tb field has DynamicallyAccessedMembersAttribute requirements, but the field access is safe because " + |
There was a problem hiding this comment.
This is a super weird place for this suppression IMO. You don't even see the _tb field around here.
Maybe it might help to use MethodImplOptions.InternalCall (or just InternalCall) in the suppression message instead of "internal calls".
…ger_proxy_attribute * origin/main: disable token info in traces. (dotnet#56780) [debugger] Fix debugger.break behavior (dotnet#56788) [mono][wasm] Allow setting env variables with '=' characters in the test runner. (dotnet#56802) Ecma edit for `conv.ovf.<to type>.un`. (dotnet#56450) Mark HandleProcessCorruptedStateExceptionsAttribute as obsolete (dotnet#56664) Enable SxS install of previews on Mac OS (dotnet#56797) CoreCLR runtime tests + Mono on the x64 iOS simulator (dotnet#43954) [main] Update dependencies from mono/linker (dotnet#56593) STJ: Fix deserialization of UInt16 properties (dotnet#56793)
This pull request updates the following dependencies
From https://github.com/mono/linker