From 4371133cf7413aa8f3e8ee79a8817b96ef65d202 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 9 Aug 2021 09:45:58 +0200 Subject: [PATCH] [dotnet] Remove workaround for private symbols for AOT. (#12334) * [dotnet] Remove workaround for private symbols for AOT. * [tools] Make Application.AotArguments a list of string. This is just a simple refactoring to make Application.AotArguments a list of strings instead of a comma-separated list of values. * [tools] Only use direct-icalls when linking mono statically. Ref: https://github.com/dotnet/runtime/issues/55000 * [mtouch] Fix aot arguments comparison. * [tests] Adjust mtouch test according to mtouch changes. * [tests] Add minimum OS version to the Mac Catalyst variation of the MySimpleApp test case. --- dotnet/targets/Xamarin.Shared.Sdk.targets | 2 -- tests/dotnet/MySimpleApp/MacCatalyst/Info.plist | 3 +++ tests/mtouch/MTouch.cs | 2 +- tools/common/Application.cs | 8 ++++++-- tools/mtouch/Application.mtouch.cs | 6 ++++-- tools/mtouch/mtouch.cs | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index c2c4e268d3..d1c926967a 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -704,13 +704,11 @@ <_AOTInputDirectory>$(_IntermediateNativeLibraryDir)aot-input/ <_AOTOutputDirectory>$(_IntermediateNativeLibraryDir)aot-output/ - <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And '$(_RunAotCompiler)' == 'true'">static <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And ('$(ComputedPlatform)' != 'iPhone' Or '$(_PlatformName)' == 'macOS')">dylib <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == ''">static <_LibMonoExtension Condition="'$(_LibMonoLinkMode)' == 'dylib'">dylib <_LibMonoExtension Condition="'$(_LibMonoLinkMode)' == 'static'">a - <_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == '' And '$(_RunAotCompiler)' == 'true'">static <_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == '' And '$(ComputedPlatform)' != 'iPhone' And '$(_PlatformName)' != 'macOS'">dylib <_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == ''">static <_LibXamarinExtension Condition="'$(_LibXamarinLinkMode)' == 'dylib'">dylib diff --git a/tests/dotnet/MySimpleApp/MacCatalyst/Info.plist b/tests/dotnet/MySimpleApp/MacCatalyst/Info.plist index 6631ffa6f2..246b63052c 100644 --- a/tests/dotnet/MySimpleApp/MacCatalyst/Info.plist +++ b/tests/dotnet/MySimpleApp/MacCatalyst/Info.plist @@ -2,5 +2,8 @@ + + LSMinimumSystemVersion + 11.0 diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index f805db9287..9c35b2965c 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -1386,7 +1386,7 @@ public class B : A {} app.WarnAsError = new int [] { 113 }; app.AotArguments = "dwarfdebug"; // doesn't matter exactly what, just that it's different from the extension. app.AssertExecuteFailure (MTouchAction.BuildDev, "build app"); - app.AssertError (113, "Native code sharing has been disabled for the extension 'testServiceExtension' because the arguments to the AOT compiler are different between the container app (dwarfdebug,static,asmonly,direct-icalls,) and the extension (static,asmonly,direct-icalls,)."); + app.AssertError (113, "Native code sharing has been disabled for the extension 'testServiceExtension' because the arguments to the AOT compiler are different between the container app (dwarfdebug) and the extension ()."); } } } diff --git a/tools/common/Application.cs b/tools/common/Application.cs index 2e07299fb2..12a8e28616 100644 --- a/tools/common/Application.cs +++ b/tools/common/Application.cs @@ -72,7 +72,7 @@ namespace Xamarin.Bundler { public HashSet IgnoredSymbols = new HashSet (); // The AOT arguments are currently not used for macOS, but they could eventually be used there as well (there's no mmp option to set these yet). - public string AotArguments = "static,asmonly,direct-icalls,"; + public List AotArguments = new List (); public List AotOtherArguments = null; public DlsymOptions DlsymOptions; @@ -1463,7 +1463,11 @@ namespace Xamarin.Bundler { aotArguments = new List (); aotArguments.Add ($"--aot=mtriple={(enable_thumb ? arch.Replace ("arm", "thumb") : arch)}-ios"); aotArguments.Add ($"data-outfile={dataFile}"); - aotArguments.AddRange (app.AotArguments.Split (new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries)); + aotArguments.Add ("static"); + aotArguments.Add ("asmonly"); + if (app.LibMonoLinkMode == AssemblyBuildTarget.StaticObject) + aotArguments.Add ("direct-icalls"); + aotArguments.AddRange (app.AotArguments); if (llvm_only) aotArguments.Add ("llvmonly"); else if (interp) { diff --git a/tools/mtouch/Application.mtouch.cs b/tools/mtouch/Application.mtouch.cs index fc538e5ab4..a31d681c5e 100644 --- a/tools/mtouch/Application.mtouch.cs +++ b/tools/mtouch/Application.mtouch.cs @@ -508,8 +508,10 @@ namespace Xamarin.Bundler { } // All arguments to the AOT compiler must be identical - if (AotArguments != appex.AotArguments) { - ErrorHelper.Warning (113, Errors.MT0113, appex.Name, String.Format (Errors.MT0113_d, AotArguments, appex.AotArguments)); + var allAotArguments = string.Join (",", AotArguments); + var allAppexAotArguments = string.Join (",", appex.AotArguments); + if (allAotArguments != allAppexAotArguments) { + ErrorHelper.Warning (113, Errors.MT0113, appex.Name, String.Format (Errors.MT0113_d, allAotArguments, allAppexAotArguments)); continue; } diff --git a/tools/mtouch/mtouch.cs b/tools/mtouch/mtouch.cs index 2efad9616c..a836912dba 100644 --- a/tools/mtouch/mtouch.cs +++ b/tools/mtouch/mtouch.cs @@ -388,7 +388,7 @@ namespace Xamarin.Bundler var os = new OptionSet () { { "dot:", "Generate a dot file to visualize the build tree.", v => dotfile = v ?? string.Empty }, { "aot=", "Arguments to the static compiler", - v => app.AotArguments = v + (v.EndsWith (",", StringComparison.Ordinal) ? String.Empty : ",") + app.AotArguments + v => app.AotArguments.AddRange (v.Split (new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries)) }, { "aot-options=", "Non AOT arguments to the static compiler", v => {