-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Remove redundant trimmer warning suppressions #73238
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
Conversation
|
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsRemoved suppressions identified as redundant by the linker (dotnet/linker#2922). \cc @vitek-karas
|
|
Yikes, I just added annotations with RDC and therefore more redundant suppressions x.x |
|
Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @sbomer, @joperezr Issue DetailsRemoved suppressions identified as redundant by the linker (dotnet/linker#2922). \cc @vitek-karas
|
The current linker changes will not detect RDC related suppressions - for that we would have to port it over to NativeAOT and run the libraries through NativeAOT (somehow). |
|
@eerhardt: still a draft, but could you please take a look? |
...Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitCachingMemberAccessor.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Linq.Queryable/src/System/Linq/EnumerableRewriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.Core.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs
Outdated
Show resolved
Hide resolved
|
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries Issue DetailsRemoved suppressions identified as redundant by the linker (dotnet/linker#2922). \cc @vitek-karas
|
Co-authored-by: Eric Erhardt <[email protected]>
...oreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/InMemoryAssemblyLoader.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
Outdated
Show resolved
Hide resolved
...tem.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Linq.Queryable/src/System/Linq/EnumerableRewriter.cs
Outdated
Show resolved
Hide resolved
|
|
||
| return matchingMethods[0]; | ||
|
|
||
| [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", |
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.
src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs
Outdated
Show resolved
Hide resolved
| _transactionDispenser = localDispenser; | ||
| whereabouts = tmpWhereabouts; | ||
|
|
||
| [UnconditionalSuppressMessage("Trimming", "IL2050", Justification = "Leave me alone")] |
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.
@AaronRobinsonMSFT is this a leftover from your code review ;-) (it sounds like you)
In any case @jkurdek could you please change the Justification to something more professional - like "The PInvoke has object/interface typed parameters which are potentially trim incompatible, but in this case they're OK".
@AaronRobinsonMSFT - I don't know the details of the implicit COM interop , but I'm not actually sure this IS OK - There are two parameters which are potentially problematic:
pvConfigParams (typed as object) - but we're passing in null, so there's no trimming problem.
ppvObject which is declared as [MarshalAs(UnmanagedType.Interface)] out ITransactionDispenser ppvObject - my understanding is that the interop will take the managed definition of ITransactionDespenser and assume the vtable coming from native matches the managed definition. With trimming, that means we have to guarantee that we preserve the entire ITransactionDespenser as-is. Additionally the code will try to cast this to couple of other interface types (ITmNodeName, ITransactionImportWhereabouts and IResourceManagerFactory2) all of which will need the same treatment I guess.
Isn't this something which should use ComWrappers to be trim-compatible? I guess that is covered in #75031 ?
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.
is this a leftover from your code review ;-) (it sounds like you)
100 % me, apologies. Please update as appropriate.
I don't know the details of the implicit COM interop
I think there was discussion that the Windows version of Transactions wasn't trim-compatible at all. However, how we express that isn't clear to me and at the time I was simply trying to get it to "leave me alone". Your analysis makes sense to me as far as why it may not be okay.
Isn't this something which should use ComWrappers to be trim-compatible? I guess that is covered in #75031 ?
From my conversations this particular part is a legacy or at the very least non-forward looking feature set that will not have a lot of investment in the future. It is unclear if ComWrappers will be worth the long term effort but perhaps #75031 is meant to track that conversation. @roji is the product owner here and can help guide us toward the correct solution.
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.
Ah sorry, the unprofessional comment was my bad - @AaronRobinsonMSFT just proposed a draft PR with this, and I was supposed to change the text. Definitely go ahead and update as appropriate.
As @AaronRobinsonMSFT wrote, System.Transactions generally isn't a forward-looking components; the reason we ported the code containing the COM interop is to unblock .NET Framework users depending on distributed transactions and allow them to port to .NET. I very much doubt we'll invest more in this in the future; if we see a real need for a cross-platform API, we'll be implementing new support for that (#71769), but that likely wouldn't involve direct COM interop in any way.
I'll post a comment in #75031 clarifying the situation.
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs
Show resolved
Hide resolved
| [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] | ||
| [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] | ||
| [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2063:UnrecognizedReflectionPattern", | ||
| Justification = "Linker doesn't recognize always throwing method. https://github.com/mono/linker/issues/2025")] |
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 have references to this bug under src/coreclr/nativeaot as well - how was the redundant suppression analysis for NativeAOT done? I wonder why it didn't find those (they should be redundant because they were just a bug workaround).
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 redundant warning suppression detection has not been ported to nativeaot yet (#75201). The suppression you mentioned should be identified after the functionality is ported and run witihin nativeaot.
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 PR has a change in src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/Assignability.cs - what mechanism was used to detect it?
(NativeAOT doesn't run on code that is unreferenced and doesn't have a "library mode" like illink does - so the ability to detect redundant suppressions is somewhat limited even if we were to port the feature - we would have to come up with an app that includes all the code in NativeAOT's libraries. It will only flag things that are used, making it easy for us to ship with an actual warning that only some customers will see - customers who happen to use that part of the library.)
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.
It was detected because linker was used to "trim libraries for warnings" (The sfx project run of linker) and it was given the AOT corelib as input. Jeremi found out that this happens when you run build Clr.Aot+Libs -rc Debug -lc Release, in which case linker gets artifacts\bin\coreclr\windows.x64.Debug\aotsdk\System.Private.CoreLib.dll as one of the input assemblies.
As for the comment about NativeAOT not having libraries mode - that should not matter. The detection works in the "trim app" mode as well - it only reports redundant warnings on methods which were "marked".
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.
It was detected because linker was used to "trim libraries for warnings" (The sfx project run of linker) and it was given the AOT corelib as input
I see, yes, there can only be one corelib project for the libs partition but we have 3 in this repo.
The corelib is selected here:
Lines 261 to 263 in e8b1491
| <CoreLibProject Condition="'$(RuntimeFlavor)' == 'CoreCLR'">$([MSBuild]::NormalizePath('$(CoreClrProjectRoot)', 'System.Private.CoreLib', 'System.Private.CoreLib.csproj'))</CoreLibProject> | |
| <CoreLibProject Condition="'$(RuntimeFlavor)' == 'Mono'">$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'System.Private.CoreLib', 'System.Private.CoreLib.csproj'))</CoreLibProject> | |
| <CoreLibProject Condition="'$(UseNativeAotCoreLib)' == 'true'">$([MSBuild]::NormalizePath('$(CoreClrProjectRoot)', 'nativeaot', 'System.Private.CoreLib', 'src', 'System.Private.CoreLib.csproj'))</CoreLibProject> |
|
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Removed suppressions identified as redundant by the linker (dotnet/linker#2922).
\cc @vitek-karas