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

[illink] set $(TrimmerRemoveSymbols) by default #7365

Merged

Conversation

jonathanpeppers
Copy link
Member

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.

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.
@jonathanpeppers jonathanpeppers merged commit 0bd871e into dotnet:release/6.0.4xx Sep 9, 2022
@jonathanpeppers jonathanpeppers deleted the backport-6598 branch September 9, 2022 16:31
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants