From f6cbea85458feb5525a120212319a713e9e2af35 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Apr 2017 12:49:16 +0200 Subject: [PATCH 1/2] [mtouch] Don't remove information when collecting all architectures. Fixes #55555. Of particular importance is if we're building for LLVM or not: this fixes a bug where we wouldn't pass --llvm to the AOT compiler when compiling assemblies to frameworks (which we do when sharing code). https://bugzilla.xamarin.com/show_bug.cgi?id=55555 --- tests/common/ExecutionHelper.cs | 6 ++++++ tests/mtouch/MTouch.cs | 30 ++++++++++++++++++++++++++++++ tests/mtouch/MTouchTool.cs | 9 +++++++++ tools/mtouch/Application.cs | 4 ++-- tools/mtouch/Target.cs | 2 +- 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/tests/common/ExecutionHelper.cs b/tests/common/ExecutionHelper.cs index 6a4395690d..c0c71ddd01 100644 --- a/tests/common/ExecutionHelper.cs +++ b/tests/common/ExecutionHelper.cs @@ -211,6 +211,12 @@ namespace Xamarin.Tests if (!HasOutputPattern (linePattern)) Assert.Fail (string.Format ("The output does not contain the line '{0}'", linePattern)); } + + public void ForAllOutputLines (Action action) + { + foreach (var line in OutputLines) + action (line); + } } class XBuild diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index ee51d2547b..432f178bb3 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -95,6 +95,36 @@ namespace Xamarin } } + [Test] + [TestCase ("code sharing 32-bit", "armv7+llvm", new string [] { "@sdk=framework=Xamarin.Sdk", "@all=staticobject" })] + [TestCase ("code sharing 64-bit", "arm64+llvm", new string [] { "@sdk=framework=Xamarin.Sdk", "@all=staticobject" })] + [TestCase ("32-bit", "armv7+llvm", new string [] { } )] + [TestCase ("64-bit", "arm64+llvm", new string [] { })] + public void CodeSharingLLVM (string name, string abi, string[] assembly_build_targets) + { + using (var mtouch = new MTouchTool ()) { + mtouch.CreateTemporaryApp (); + mtouch.CreateTemporaryCacheDirectory (); + mtouch.Abi = abi; + mtouch.AssemblyBuildTargets.AddRange (assembly_build_targets); + mtouch.Debug = false; + mtouch.NoStrip = true; // faster test + mtouch.NoSymbolStrip = string.Empty; // faster test + mtouch.Verbosity = 4; // This is needed to get mtouch to print the output we're verifying + mtouch.AssertExecute (MTouchAction.BuildDev, "build"); + // Check that --llvm is passed to the AOT compiler for every assembly we AOT. + var assemblies_checked = 0; + mtouch.ForAllOutputLines ((line) => + { + if (!line.Contains ("arm-darwin-mono-sgen") && !line.Contains ("arm64-darwin-mono-sgen")) + return; + StringAssert.Contains (" --llvm ", line, "aot command must pass --llvm to the AOT compiler"); + assemblies_checked++; + }); + Assert.That (assemblies_checked, Is.AtLeast (4), "We build at least 4, so we must have had at least 4 asserts above."); // mscorlib.dll, Xamarin.iOS.dll, System.dll, theApp.exe + } + } + [Test] [TestCase ("single", "", false)] [TestCase ("dual", "armv7,arm64", false)] diff --git a/tests/mtouch/MTouchTool.cs b/tests/mtouch/MTouchTool.cs index 6096e63a70..992c91364d 100644 --- a/tests/mtouch/MTouchTool.cs +++ b/tests/mtouch/MTouchTool.cs @@ -89,6 +89,7 @@ namespace Xamarin public bool? MSym; public bool? DSym; public bool? NoStrip; + public string NoSymbolStrip; public string Mono; public string GccFlags; @@ -222,6 +223,14 @@ namespace Xamarin if (NoStrip.HasValue && NoStrip.Value) sb.Append (" --nostrip"); + if (NoSymbolStrip != null) { + if (NoSymbolStrip.Length == 0) { + sb.Append (" --nosymbolstrip"); + } else { + sb.Append (" --nosymbolstrip:").Append (NoSymbolStrip); + } + } + if (MSym.HasValue) sb.Append (" --msym:").Append (MSym.Value ? "true" : "false"); diff --git a/tools/mtouch/Application.cs b/tools/mtouch/Application.cs index efa74c00cb..6edad1cb7c 100644 --- a/tools/mtouch/Application.cs +++ b/tools/mtouch/Application.cs @@ -502,10 +502,10 @@ namespace Xamarin.Bundler { if (all_architectures == null) { all_architectures = new HashSet (); foreach (var abi in abis) - all_architectures.Add (abi & Abi.ArchMask); + all_architectures.Add (abi); foreach (var ext in AppExtensions) { foreach (var abi in ext.Abis) - all_architectures.Add (abi & Abi.ArchMask); + all_architectures.Add (abi); } } return all_architectures; diff --git a/tools/mtouch/Target.cs b/tools/mtouch/Target.cs index e1781c2ca2..718465ed18 100644 --- a/tools/mtouch/Target.cs +++ b/tools/mtouch/Target.cs @@ -85,7 +85,7 @@ namespace Xamarin.Bundler foreach (var abi in App.AllArchitectures) { var a = abi & mask; if (a != 0) - all_architectures.Add (a); + all_architectures.Add (abi); } } return all_architectures; From 5c4d6a137a98fe437f9d686f56171565fe2c40a8 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Apr 2017 18:49:56 +0200 Subject: [PATCH 2/2] [mtouch] Work around bug #55553 by passing a magic flag to the native linker. --- tools/mtouch/Target.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/mtouch/Target.cs b/tools/mtouch/Target.cs index 718465ed18..11136e2ec1 100644 --- a/tools/mtouch/Target.cs +++ b/tools/mtouch/Target.cs @@ -1453,6 +1453,12 @@ namespace Xamarin.Bundler linker_flags.AddOtherFlag ("-fapplication-extension"); } + if (App.HasFrameworks && Is64Build) { + // Work around https://bugzilla.xamarin.com/show_bug.cgi?id=55553 + // This option was introduced in Xcode 5.1, so no need for Xcode version checks. + linker_flags.AddOtherFlag ("-Wl,-ignore_optimization_hints"); + } + link_task = new NativeLinkTask { Target = this,