Skip to content
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
2 changes: 1 addition & 1 deletion tests/common/BundlerTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public virtual void AssertExecute (string message = null)
if (rv == 0)
return;
var errors = Messages.Where ((v) => v.IsError).ToList ();
Assert.Fail ($"Expected execution to succeed, but exit code was {rv}, and there were {errors.Count} error(s): {message}\n\t" +
Assert.Fail ($"Expected execution to succeed, but exit code was {rv}, and there were {errors.Count} error(s).\nCommand: {ToolPath} {StringUtils.FormatArguments (ToolArguments)}\nMessage: {message}\n\t" +
string.Join ("\n\t", errors.Select ((v) => v.ToString ())));
}

Expand Down
25 changes: 25 additions & 0 deletions tests/mtouch/MTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,31 @@ public void MT0180 (Profile profile, string name)
}
}

[Test]
[TestCase (Profile.tvOS, MTouchBitcode.ASMOnly, "arm64+llvm")]
[TestCase (Profile.tvOS, MTouchBitcode.Full, "arm64+llvm")]
[TestCase (Profile.tvOS, MTouchBitcode.Marker, "arm64+llvm")]
public void MT0186 (Profile profile, MTouchBitcode mode, string abi)
{
using (var mtouch = new MTouchTool ()) {
mtouch.Profile = profile;
if (profile == Profile.watchOS) {
mtouch.CreateTemporaryWatchKitExtension ();
} else {
mtouch.CreateTemporaryApp ();
}
mtouch.Abi = abi;
mtouch.Bitcode = mode;
mtouch.WarnAsError = new int[] { 186 };
if (Configuration.XcodeVersion.Major >= 14) {
Assert.AreEqual (1, mtouch.Execute (MTouchAction.BuildDev));
mtouch.AssertError (186, "Bitcode is enabled, but bitcode is not supported in Xcode 14+ and has been disabled. Please disable bitcode by removing the 'MtouchEnableBitcode' property from the project file.");
} else {
Assert.AreEqual (0, mtouch.Execute (MTouchAction.BuildDev));
}
}
}

[Test]
public void MT0095_SharedCode ()
{
Expand Down
6 changes: 6 additions & 0 deletions tools/common/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,12 @@ public void InitializeCommon ()
ErrorHelper.Warning (3007, Errors.MX3007);
}

if (Driver.XcodeVersion.Major >= 14 && BitCodeMode != BitCodeMode.None && Platform == ApplePlatform.TVOS) {
// We currently have to leave watchOS alone, because the process is to first build bitcode, then compile bitcode into native code, and finally remove the bitcode from the executable (this is likely fixable, but looks like it's a larger effort involving the runtime team).
ErrorHelper.Warning (186, Errors.MX0186 /* Bitcode is enabled, but bitcode is not supported in Xcode 14+ and has been disabled. Please disable bitcode by removing the 'MtouchEnableBitcode' property from the project file. */);
BitCodeMode = BitCodeMode.None;
}

Optimizations.Initialize (this, out var messages);
ErrorHelper.Show (messages);
if (Driver.Verbosity > 3)
Expand Down
9 changes: 8 additions & 1 deletion tools/mtouch/Application.mtouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,8 @@ void Initialize ()
break;
case BitCodeMode.None:
// If neither llvmonly nor asmonly is enabled, enable markeronly.
if (Driver.XcodeVersion.Major >= 14)
break;
if (Platform == ApplePlatform.TVOS || Platform == ApplePlatform.WatchOS)
BitCodeMode = BitCodeMode.MarkerOnly;
break;
Expand Down Expand Up @@ -1236,7 +1238,12 @@ public void StripBitcode (string macho_file)
{
var sb = new List<string> ();
sb.Add (macho_file);
switch (BitCodeMode) {

var mode = BitCodeMode;
if (Driver.XcodeVersion.Major >= 14)
mode = BitCodeMode.None;

switch (mode) {
case BitCodeMode.ASMOnly:
case BitCodeMode.LLVMOnly:
// do nothing, since we don't know neither if bitcode is needed (if we're publishing) or if native code is needed (not publishing).
Expand Down
6 changes: 6 additions & 0 deletions tools/mtouch/BuildTasks.mtouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ protected override async Task ExecuteAsync ()
}
}
}

if (code == 0 && Driver.XcodeVersion.Major >= 14 && Target.App.BitCodeMode != BitCodeMode.None)
Target.App.StripBitcode (OutputFile);
} catch (System.ComponentModel.Win32Exception wex) {
/* This means we failed to execute the linker, not that the linker itself returned with a failure */
if (wex.NativeErrorCode == 7 /* E2BIG = Too many arguments */ ) {
Expand Down Expand Up @@ -350,6 +353,9 @@ protected override async Task ExecuteAsync ()
// we can't trust the native linker to pick the right (non private) framework when an older TargetVersion is used
if (CompilerFlags.WeakFrameworks.Count > 0)
Target.AdjustDylibs (OutputFile);
// Remove bitcode from the binary
if (Driver.XcodeVersion.Major >= 14 && App.BitCodeMode != BitCodeMode.None)
App.StripBitcode (OutputFile);
}

protected override void CompilationFailed (int exitCode)
Expand Down
9 changes: 9 additions & 0 deletions tools/mtouch/Errors.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tools/mtouch/Errors.resx
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,10 @@
<value>The option '{0}' cannot take the value '{1}' when using CoreCLR.</value>
</data>

<data name="MX0186" xml:space="preserve">
<value>Bitcode is enabled, but bitcode is not supported in Xcode 14+ and has been disabled. Please disable bitcode by removing the 'MtouchEnableBitcode' property from the project file.</value>
</data>

<data name="MX1009" xml:space="preserve">
<value>Could not copy the assembly '{0}' to '{1}': {2}
</value>
Expand Down
2 changes: 1 addition & 1 deletion tools/mtouch/Target.mtouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ public NativeLinkTask NativeLink (BuildTasks build_tasks, Abi abi, string output
}

var bitcode = App.EnableBitCode;
if (bitcode)
if (bitcode && Driver.XcodeVersion.Major < 14)
linker_flags.AddOtherFlag (App.EnableMarkerOnlyBitCode ? "-fembed-bitcode-marker" : "-fembed-bitcode");

if (!App.EnablePie.HasValue)
Expand Down
8 changes: 8 additions & 0 deletions tools/mtouch/mtouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,14 @@ public static void CalculateCompilerPath (Application app)
// we try again with clang.
//

switch (app.Platform) {
case ApplePlatform.TVOS:
case ApplePlatform.WatchOS:
if (Driver.XcodeVersion.Major >= 14)
app.EnableCxx = true;
break;
}

if (string.IsNullOrEmpty (app.Compiler)) {
// by default we use `gcc` before iOS7 SDK, falling back to `clang`. Otherwise we go directly to `clang`
// so we don't get bite by the fact that Xcode5 has a gcc compiler (which calls `clang`, even if not 100%
Expand Down