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

[release/7.0.3xx] [dotnet] Link Mono and Xamarin statically in Mac Catalyst by default. Fixes #14686. #19134

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
4 changes: 4 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -922,11 +922,15 @@
<_AOTInputDirectory>$(_IntermediateNativeLibraryDir)aot-input/</_AOTInputDirectory>
<_AOTOutputDirectory>$(_IntermediateNativeLibraryDir)aot-output/</_AOTOutputDirectory>

<!-- default to 'static' for Mac Catalyst to work around https://github.com/xamarin/xamarin-macios/issues/14686 -->
<_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And '$(_PlatformName)' == 'MacCatalyst'">static</_LibMonoLinkMode>
<_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And ('$(ComputedPlatform)' != 'iPhone' Or '$(_PlatformName)' == 'macOS')">dylib</_LibMonoLinkMode>
<_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == ''">static</_LibMonoLinkMode>
<_LibMonoExtension Condition="'$(_LibMonoLinkMode)' == 'dylib'">dylib</_LibMonoExtension>
<_LibMonoExtension Condition="'$(_LibMonoLinkMode)' == 'static'">a</_LibMonoExtension>

<!-- default to 'static' for Mac Catalyst to work around https://github.com/xamarin/xamarin-macios/issues/14686 -->
<_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == '' And '$(_PlatformName)' == 'MacCatalyst'">static</_LibXamarinLinkMode>
<_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == '' And '$(ComputedPlatform)' != 'iPhone' And '$(_PlatformName)' != 'macOS'">dylib</_LibXamarinLinkMode>
<_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == ''">static</_LibXamarinLinkMode>
<_LibXamarinExtension Condition="'$(_LibXamarinLinkMode)' == 'dylib'">dylib</_LibXamarinExtension>
Expand Down
8 changes: 0 additions & 8 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,14 +1164,6 @@ public void CustomizedCodeSigning (ApplePlatform platform, string runtimeIdentif
var signedDylibs = new List<string> {
Path.Combine (sharedSupportDir, "app2.app", dylibDir, "lib2.dylib"),
};
if (platform == ApplePlatform.MacCatalyst) {
signedDylibs.Add (Path.Combine (dylibDir, "libSystem.IO.Compression.Native.dylib"));
signedDylibs.Add (Path.Combine (dylibDir, "libSystem.Native.dylib"));
signedDylibs.Add (Path.Combine (dylibDir, "libSystem.Net.Security.Native.dylib"));
signedDylibs.Add (Path.Combine (dylibDir, "libSystem.Security.Cryptography.Native.Apple.dylib"));
signedDylibs.Add (Path.Combine (dylibDir, "libmonosgen-2.0.dylib"));
signedDylibs.Add (Path.Combine (dylibDir, "libxamarin-dotnet-debug.dylib"));
}

foreach (var dylib in signedDylibs) {
var path = Path.Combine (appPath, dylib);
Expand Down
18 changes: 17 additions & 1 deletion tests/introspection/ApiPInvokeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,23 @@ protected void Check (Assembly a)
path = null;
break;
case "libSystem.Native":
path += ".dylib";
var staticallyLinked = false;
#if __MACCATALYST__
// always statically linked
staticallyLinked = true;
#elif __IOS__ || __TVOS__
// statically linked on device
staticallyLinked = Runtime.Arch == Arch.DEVICE;
#elif __MACOS__
// never statically linked (by default)
#else
#error Unknown platform
#endif
if (staticallyLinked) {
path = null;
} else {
path += ".dylib";
}
break;
#endif
case "libc":
Expand Down
3 changes: 3 additions & 0 deletions tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ bool ProcessMethod (MethodDefinition method)
Where (v => v.EndsWith (".dylib", StringComparison.OrdinalIgnoreCase) || v.EndsWith (".a", StringComparison.OrdinalIgnoreCase)).
Select (v => Path.GetFileNameWithoutExtension (v)).
Select (v => v.StartsWith ("lib", StringComparison.OrdinalIgnoreCase) ? v.Substring (3) : v).ToHashSet ();
#if !__MACOS__
monoLibraryVariations.Add ("System.Globalization.Native"); // System.Private.CoreLib has P/Invokes pointing to libSystem.Globalization.Native, but they're actually in libmonosgen-2.0
#endif
monoLibraryVariations.UnionWith (monoLibraryVariations.Select (v => "lib" + v).ToArray ());
monoLibraryVariations.UnionWith (monoLibraryVariations.Select (v => v + ".dylib").ToArray ());
// If the P/Invoke points to any of those libraries, then we add it as a P/Invoke symbol.
Expand Down