Skip to content

Commit

Permalink
[msbuild/dotnet] Add support for passing --aot arguments to the AOT c…
Browse files Browse the repository at this point in the history
…ompiler.

Pick up --aot arguments in MtouchExtraArgs and pass them to the AOT compiler
when building a .NET project. This makes it possible to work around #14887 by
manually increasing the number of trampolines.

Ref: #14887
  • Loading branch information
rolfbjarne committed May 9, 2022
1 parent 07b9d90 commit 0d1bc18
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@
<AOTCompile
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
AotArguments="@(_AotArguments)"
Assemblies="@(_AssembliesToAOT)"
AOTCompilerPath="$(_AOTCompiler)"
InputDirectory="$(_AOTInputDirectory)"
Expand Down
5 changes: 5 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks.Core/Tasks/AOTCompileTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace Xamarin.MacDev.Tasks {
public abstract class AOTCompileTaskBase : XamarinTask {
public ITaskItem [] AotArguments { get; set; } = Array.Empty<ITaskItem> ();

[Required]
public string AOTCompilerPath { get; set; } = string.Empty;

Expand Down Expand Up @@ -71,6 +73,7 @@ public override bool Execute ()
{ "MONO_PATH", Path.GetFullPath (InputDirectory) },
};

var globalAotArguments = AotArguments?.Select (v => v.ItemSpec).ToList ();
for (var i = 0; i < Assemblies.Length; i++) {
var asm = Assemblies [i];
var input = inputs [i];
Expand All @@ -95,6 +98,8 @@ public override bool Execute ()
return false;
}
arguments.Add ($"{string.Join (",", parsedArguments)}");
if (globalAotArguments is not null)
arguments.Add ($"--aot={string.Join (",", globalAotArguments)}");
arguments.AddRange (parsedProcessArguments);
arguments.Add (input);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace Xamarin.MacDev.Tasks {
public abstract class ParseBundlerArgumentsTaskBase : XamarinTask {
public string ExtraArgs { get; set; }

[Output]
public ITaskItem [] Aot { get; set; }

[Output]
public ITaskItem [] DlSym { get; set; }

Expand Down Expand Up @@ -65,6 +68,7 @@ public override bool Execute ()
var args = CommandLineArgumentBuilder.Parse (ExtraArgs);
List<string> xml = null;
List<string> customLinkFlags = null;
var aot = new List<ITaskItem> ();
var envVariables = new List<ITaskItem> ();
var dlsyms = new List<ITaskItem> ();

Expand Down Expand Up @@ -100,6 +104,9 @@ public override bool Execute ()
}

switch (name) {
case "aot":
aot.Add (new TaskItem (value));
break;
case "nosymbolstrip":
// There's also a version that takes symbols as arguments:
// --nosymbolstrip:symbol1,symbol2
Expand Down Expand Up @@ -207,6 +214,12 @@ public override bool Execute ()
dlsyms.AddRange (DlSym);
DlSym = dlsyms.ToArray ();
}

if (aot.Count > 0) {
if (Aot is not null)
aot.AddRange (Aot);
Aot = aot.ToArray ();
}
}

return !Log.HasLoggedErrors;
Expand Down
2 changes: 2 additions & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1763,12 +1763,14 @@ Copyright (C) 2018 Microsoft. All rights reserved.

<Target Name="_ParseBundlerArguments">
<ParseBundlerArguments
Aot="@(_AotArguments)"
ExtraArgs="$(_BundlerArguments)"
NoSymbolStrip="$(NoSymbolStrip)"
NoDSymUtil="$(NoDSymUtil)"
PackageDebugSymbols="$(PackageDebugSymbols)"
Verbosity="$(_BundlerVerbosity)"
>
<Output TaskParameter="Aot" ItemName="_AotArguments" />
<Output TaskParameter="CustomBundleName" PropertyName="_CustomBundleName" />
<Output TaskParameter="CustomLinkFlags" ItemName="_CustomLinkFlags" />
<Output TaskParameter="DlSym" ItemName="_BundlerDlsym" />
Expand Down

0 comments on commit 0d1bc18

Please sign in to comment.