-
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
[release/6.0] Add reference assembly for System.Private.CoreLib.dll #75311
[release/6.0] Add reference assembly for System.Private.CoreLib.dll #75311
Conversation
We now compile against the reference assembly in all places where we were compiling against the mono/coreclr System.Private.CoreLib.dll implementation assembly before. The new reference assembly consumes sources from the existing contracts to avoid checking in a generated version of SPC.dll (this would add ~20k lines of .cs which is mostly duplicated with System.Runtime.cs) Since a few contracts have only partially moved types to SPC we wrap contract types with `#if !BUILDING_CORELIB_REFERENCE` so we can hide them when compiling the SPC reference assembly.
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries Issue DetailsBackport of #72143 to release/6.0 We now compile against the reference assembly in all places where we were compiling against the mono/coreclr System.Private.CoreLib.dll implementation assembly before. The new reference assembly consumes sources from the existing contracts to avoid checking in a generated version of SPC.dll (this would add ~20k lines of .cs which is mostly duplicated with System.Runtime.cs) Since a few contracts have only partially moved types to SPC we wrap contract types with Customer ImpactFixes an issue where Xamarin.Android has duplicate assemblies. RiskTODO
|
Fixes: dotnet#7302 Context: dotnet/linker#2203 Context: dotnet/runtime#67660 Context: dotnet#6598 This partially backports 745214d. In addition to this backport to dotnet/runtime/release/6.0: dotnet/runtime#75311 We also have another change in .NET 7 that opts into `$(TrimmerRemoveSymbols)` by default for `Release` builds. This allows the .NET 7 linker to have stable MVIDs for assemblies for each architecture. There may potentially be a dotnet/linker issue here to look into further. However, this seems to be the best fix for getting .NET 6 projects building under .NET 7 at the moment.
Fixes: #7302 Context: dotnet/linker#2203 Context: dotnet/runtime#67660 Context: #6598 This partially backports 745214d. Building a `net6.0-android` app in `Release` mode with .NET 7 can fail with many errors like: error XA4215: The Java type `androidx.activity.contextaware.OnContextAvailableListener` is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. This happens because we end up with multiple assemblies, such as: obj/Release/net6.0-android/android-arm/linked/Xamarin.AndroidX.Activity.dll obj/Release/net6.0-android/android-arm64/linked/Xamarin.AndroidX.Activity.dll obj/Release/net6.0-android/android-x64/linked/Xamarin.AndroidX.Activity.dll obj/Release/net6.0-android/android-x86/linked/Xamarin.AndroidX.Activity.dll To fix this, in addition to this backport to dotnet/runtime/release/6.0: dotnet/runtime#75311 In .NET 7 we opt into `$(TrimmerRemoveSymbols)` by default for `Release` builds. This allows the .NET 7 linker to have stable MVIDs for assemblies for each architecture. Somehow when the linker outputs `.pdb` files, it creates different MVIDs per architecture. There may potentially be a dotnet/linker issue here to look into further. However, this seems to be the best fix for getting .NET 6 projects building under .NET 7 at the moment.
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.
@ViktorHofer gave your PR a like but not a sign-off 😄 . I'll sign-off. But just in case, @ericstj @lewing @steveisok would you mind also providing a review?
@akoeplinger do you think the CI failure is related to this change? Happened on System.Runtime.InteropServices.NFloat.Internal.Tests |
No, it's unrelated. I believe they are disabled upstream and just didn't make it here. |
Ok thanks. Let's get this merged then. |
Backport of #72143 to release/6.0
We now compile against the reference assembly in all places where we were compiling against the mono/coreclr System.Private.CoreLib.dll implementation assembly before.
The new reference assembly consumes sources from the existing contracts to avoid checking in a generated version of SPC.dll (this would add ~20k lines of .cs which is mostly duplicated with System.Runtime.cs)
Since a few contracts have only partially moved types to SPC we wrap contract types with
#if !BUILDING_CORELIB_REFERENCE
so we can hide them when compiling the SPC reference assembly.NOTE: to simplify the change for the 6.0 backport this does not include the GenAPI et.al. changes for regenerating the reference assembly sources since we won't be adding new APIs in 6.0.
Customer Impact
Fixes an issue where Xamarin.Android puts duplicate assemblies into the .apk because the MVID-based deduplication logic didn't work anymore due to an ILLinker fix which increased the app size a lot. This is necessary for 6.0 because the 7.0 SDK includes a new ILLinker which is used even when building a 6.0 app.
Risk
Low, it is a build-related change that should be transparent outside of dotnet/runtime.
Testing
Manual testing confirmed it fixes the issue.