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

Make System.Transactions.Local trimmable on Windows #75176

Merged
merged 7 commits into from
Sep 9, 2022

Conversation

eerhardt
Copy link
Member

@eerhardt eerhardt commented Sep 7, 2022

Remove IsTrimmable=false from the project, so this assembly is still trimmed with partial trimming on Windows.

Add a "LibraryBuild" ILLink warning, so when the distributed transaction code is not trimmed, the app developer gets a warning that it is not guaranteed to work.

Fix #75031

The full, correct fix here would be to use COMWrappers. However, #75031 (comment) indicates that level of investment isn't justified at this time. So using a temporary approach for now.

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

OK from my side on any strategy picked here.

Add the necessary DynamicDependency attributes to System.Transaction.Local in order for it to work with trimming on Windows. Also fix the UnconditionalSuppressMessage attribute to have a valid justification for suppressing, now that we are preserving the necessary interfaces for COM Interop.

Fix dotnet#75031
…warning that Distributed transactions don't work with trimming.
- Complete the list of all transaction interfaces
- Sort the DynamicDependencies
- Update the trim warning message
This gives a better message to users that distributed transactions don't work with trimming.
@eerhardt
Copy link
Member Author

eerhardt commented Sep 9, 2022

@vitek-karas @jkurdek - how do I fix the trimming error?

  sfx -> Trimming win-x86 shared framework assemblies with ILLinker...
D:\a\_work\1\s\artifacts\bin\ILLinkTrimAssembly\net7.0-windows-Release-x86\suppressions-xmls\ILLink.Suppressions.LibraryBuild.System.Transactions.Local.xml(4,6): Trim analysis error IL2121: Unused 'UnconditionalSuppressMessageAttribute' for warning 'IL2026'. Consider removing the unused warning suppression. [D:\a\_work\1\s\src\libraries\sfx.proj]
##[error]artifacts\bin\ILLinkTrimAssembly\net7.0-windows-Release-x86\suppressions-xmls\ILLink.Suppressions.LibraryBuild.System.Transactions.Local.xml(4,6): error IL2121: (NETCORE_ENGINEERING_TELEMETRY=Build) Unused 'UnconditionalSuppressMessageAttribute' for warning 'IL2026'. Consider removing the unused warning suppression.
D:\a\_work\1\s\artifacts\bin\ILLinkTrimAssembly\net7.0-windows-Release-x86\suppressions-xmls\ILLink.Suppressions.LibraryBuild.System.Transactions.Local.xml(4,6): Trim analysis error IL2121: Unused 'UnconditionalSuppressMessageAttribute' for warning 'IL2026'. Consider removing the unused warning suppression. [D:\a\_work\1\s\src\libraries\sfx.proj]
##[error]artifacts\bin\ILLinkTrimAssembly\net7.0-windows-Release-x86\suppressions-xmls\ILLink.Suppressions.LibraryBuild.System.Transactions.Local.xml(4,6): error IL2121: (NETCORE_ENGINEERING_TELEMETRY=Build) Unused 'UnconditionalSuppressMessageAttribute' for warning 'IL2026'. Consider removing the unused warning suppression.

Don't I need a ILLink.Suppressions.LibraryBuild.xml file? It looks like it is only happening on x86 builds, for some reason.

@vitek-karas
Copy link
Member

It's because of this:

        if (RuntimeInformation.ProcessArchitecture == Architecture.X86)
        {
            throw new PlatformNotSupportedException(SR.DistributedNotSupportOn32Bits);
        }

The constant prop/branch removal will effectively remove the rest of the method on X86, and thus the suppression is considered redundant because the code it relates to isn't there anymore.

This is a known limitation of the redundant suppression detection - it doesn't work correctly with branch removal (it sees the code after branch removal).

There were 2 or 3 other places where we hit this in the runtime. The workaround is to extract the rest of the method after the if into a separate method and point the suppression to that. On X86 that new method will be completely removed and there won't be any warnings (the redundant suppression detection doesn't trigger on unmarked methods at all).

@eerhardt
Copy link
Member Author

eerhardt commented Sep 9, 2022

Test failure is #490.

@eerhardt eerhardt merged commit fbb2ec3 into dotnet:main Sep 9, 2022
@eerhardt eerhardt deleted the Fix75031 branch September 9, 2022 21:24
eerhardt added a commit to eerhardt/runtime that referenced this pull request Sep 9, 2022
* Make System.Transactions.Local trimmable on Windows

Remove `IsTrimmable=false` from the project, so this assembly is still trimmed with `partial` trimming on Windows.

Add a "LibraryBuild" ILLink warning, so when the distributed transaction code is not trimmed, the app developer gets a warning that it is not guaranteed to work.

Fix dotnet#75031

* Fix x86 build. Move the ILLink suppression to a method that is completely trimmed on x86.
carlossanlop pushed a commit that referenced this pull request Sep 12, 2022
* Make System.Transactions.Local trimmable on Windows

Remove `IsTrimmable=false` from the project, so this assembly is still trimmed with `partial` trimming on Windows.

Add a "LibraryBuild" ILLink warning, so when the distributed transaction code is not trimmed, the app developer gets a warning that it is not guaranteed to work.

Fix #75031

* Fix x86 build. Move the ILLink suppression to a method that is completely trimmed on x86.
@ghost ghost locked as resolved and limited conversation to collaborators Oct 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make System.Transactions.Local trimmable on Windows
5 participants