-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 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
Looks like this is still broken:
|
src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Data.Common/src/System/Data/Common/DbConnectionStringBuilder.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Data.Common/src/System/Data/Common/DbConnectionStringBuilder.cs
Outdated
Show resolved
Hide resolved
....Private.DataContractSerialization/src/System/Runtime/Serialization/PrimitiveDataContract.cs
Outdated
Show resolved
Hide resolved
- 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
A few more trimmer errors in tests:
|
e1257f8
to
c353468
Compare
Microsoft.NET.ILLink.Tasks From Version 6.0.100-preview.6.21378.1 -> To Version 6.0.100-preview.6.21402.2
@@ -627,6 +627,9 @@ internal sealed class LicenseInteropProxy | |||
private object? _licContext; | |||
private Type? _targetRcwType; | |||
|
|||
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"); // IL2026
class Foo {
[RUC("RUC")]
public static void RUC() {}
}
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, it does. Good question about DynamicDependency. I only found one place where the annotation was ultimately used:
runtime/src/libraries/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs
Lines 45 to 51 in f9cbd72
PropertyInfo? propInfo = type.GetProperty("Null", BindingFlags.Public | BindingFlags.Static); | |
if (propInfo != null) | |
{ | |
return propInfo.GetValue(null, null)!; | |
} | |
FieldInfo fieldInfo = type.GetField("Null", BindingFlags.Public | BindingFlags.Static)!; |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/libraries/System.Diagnostics.Tracing/tests/TrimmingTests/EventSourceManifestTest.cs
Outdated
Show resolved
Hide resolved
@@ -209,6 +209,10 @@ public override Type GetEnumUnderlyingType() | |||
return _underlyingType; | |||
} | |||
|
|||
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed dotnet/linker#2188 about the warning origin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sbomer !
…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