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

[dotnet] Change the usage of the classic linker to be opt-in. #21231

Merged
merged 4 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1625,13 +1625,19 @@

<WriteLinesToFile SessionId="$(BuildSessionId)" File="$(_MtouchSymbolsList)" Lines="@(_ProcessedReferenceNativeSymbol)" Overwrite="true" />

<PropertyGroup>
<!-- There are known bugs in the classic linker with Xcode 15, so keep use the classic linker in that case -->
<!-- In Xcode 16 we don't know of any problems for now, so enable the new linker by default -->
<_UseClassicLinker Condition="'$(_UseClassicLinker)' == '' And $([MSBuild]::VersionGreaterThanOrEquals('$(_XcodeVersion)', '16.0'))">false</_UseClassicLinker>
<_UseClassicLinker Condition="'$(_UseClassicLinker)' == '' And $([MSBuild]::VersionGreaterThanOrEquals('$(_XcodeVersion)', '15.0'))">true</_UseClassicLinker>
</PropertyGroup>

<ItemGroup>
<_AllLinkerFlags Include="@(_AssemblyLinkerFlags);@(_MainLinkerFlags);@(_CustomLinkFlags)" />
<_AllLinkerFlags Condition="'$(_ExportSymbolsExplicitly)' != 'true'" Include="@(_ProcessedReferenceNativeSymbol->'-u%(Identity)')" />

<!-- check if needs to be removed: https://github.com/xamarin/xamarin-macios/issues/18693 -->
<_AllLinkerFlags Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(_XcodeVersion)', '15.0')) And '$(_UseClassicLinker)' != 'false'" Include="-Xlinker" />
<_AllLinkerFlags Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(_XcodeVersion)', '15.0')) And '$(_UseClassicLinker)' != 'false'" Include="-ld_classic" />
<_AllLinkerFlags Condition="'$(_UseClassicLinker)' == 'true'" Include="-Xlinker" />
<_AllLinkerFlags Condition="'$(_UseClassicLinker)' == 'true'" Include="-ld_classic" />
</ItemGroup>

<LinkNativeCode
Expand Down
1 change: 0 additions & 1 deletion tools/common/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ public bool IsDefaultMarshalManagedExceptionMode {

public bool SkipMarkingNSObjectsInUserAssemblies { get; set; }

// check if needs to be removed: https://github.com/xamarin/xamarin-macios/issues/18693
public bool DisableAutomaticLinkerSelection { get; set; }

// assembly_build_targets describes what kind of native code each assembly should be compiled into for mobile targets (iOS, tvOS, watchOS).
Expand Down
5 changes: 3 additions & 2 deletions tools/common/CompilerFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ public void WriteArguments (IList<string> args)
}
}

// check if needs to be removed: https://github.com/xamarin/xamarin-macios/issues/18693
if (Driver.XcodeVersion.Major >= 15 && !Application.DisableAutomaticLinkerSelection) {
// There are known bugs in the classic linker with Xcode 15, so keep use the classic linker in that case
// In Xcode 16 we don't know of any problems for now, so enable the new linker by default
if (Driver.XcodeVersion.Major >= 15 && Driver.XcodeVersion.Major < 16 && !Application.DisableAutomaticLinkerSelection) {
args.Insert (0, "-Xlinker");
args.Insert (1, "-ld_classic");
}
Expand Down