[tools] Move Driver.GetAotArguments to shared code.
This commit is contained in:
Родитель
03cef5c3c2
Коммит
8f36d37659
|
@ -3,10 +3,12 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using Mono.Linker;
|
||||
using Mono.Tuner;
|
||||
|
||||
using Xamarin;
|
||||
using Xamarin.Linker;
|
||||
|
@ -69,6 +71,10 @@ namespace Xamarin.Bundler {
|
|||
public SymbolMode SymbolMode;
|
||||
public HashSet<string> IgnoredSymbols = new HashSet<string> ();
|
||||
|
||||
// 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<string> AotOtherArguments = null;
|
||||
|
||||
public DlsymOptions DlsymOptions;
|
||||
public List<Tuple<string, bool>> DlsymAssemblies;
|
||||
|
||||
|
@ -1422,6 +1428,82 @@ namespace Xamarin.Bundler {
|
|||
return !IsInterpreted (assembly);
|
||||
}
|
||||
|
||||
public IList<string> GetAotArguments (string filename, Abi abi, string outputDir, string outputFile, string llvmOutputFile, string dataFile)
|
||||
{
|
||||
string fname = Path.GetFileName (filename);
|
||||
var args = new List<string> ();
|
||||
var app = this;
|
||||
bool enable_llvm = (abi & Abi.LLVM) != 0;
|
||||
bool enable_thumb = (abi & Abi.Thumb) != 0;
|
||||
bool enable_debug = app.EnableDebug;
|
||||
bool enable_debug_symbols = app.PackageManagedDebugSymbols;
|
||||
bool llvm_only = app.EnableLLVMOnlyBitCode;
|
||||
bool interp = app.IsInterpreted (Assembly.GetIdentity (filename));
|
||||
bool interp_full = !interp && app.UseInterpreter;
|
||||
bool is32bit = (abi & Abi.Arch32Mask) > 0;
|
||||
string arch = abi.AsArchString ();
|
||||
|
||||
args.Add ("--debug");
|
||||
|
||||
if (enable_llvm)
|
||||
args.Add ("--llvm");
|
||||
|
||||
if (!llvm_only && !interp)
|
||||
args.Add ("-O=gsharedvt");
|
||||
if (app.AotOtherArguments != null)
|
||||
args.AddRange (app.AotOtherArguments);
|
||||
var aot = new StringBuilder ();
|
||||
aot.Append ("--aot=mtriple=");
|
||||
aot.Append (enable_thumb ? arch.Replace ("arm", "thumb") : arch);
|
||||
aot.Append ("-ios,");
|
||||
aot.Append ("data-outfile=").Append (dataFile).Append (",");
|
||||
aot.Append (app.AotArguments);
|
||||
if (llvm_only)
|
||||
aot.Append ("llvmonly,");
|
||||
else if (interp) {
|
||||
if (fname != Driver.CorlibName + ".dll")
|
||||
throw ErrorHelper.CreateError (99, Errors.MX0099, fname);
|
||||
aot.Append ("interp,");
|
||||
} else if (interp_full) {
|
||||
aot.Append ("interp,full,");
|
||||
} else
|
||||
aot.Append ("full,");
|
||||
|
||||
var aname = Path.GetFileNameWithoutExtension (fname);
|
||||
var sdk_or_product = Profile.IsSdkAssembly (aname) || Profile.IsProductAssembly (aname);
|
||||
|
||||
if (enable_llvm)
|
||||
aot.Append ("nodebug,");
|
||||
else if (!(enable_debug || enable_debug_symbols))
|
||||
aot.Append ("nodebug,");
|
||||
else if (app.DebugAll || app.DebugAssemblies.Contains (fname) || !sdk_or_product)
|
||||
aot.Append ("soft-debug,");
|
||||
|
||||
aot.Append ("dwarfdebug,");
|
||||
|
||||
/* Needed for #4587 */
|
||||
if (enable_debug && !enable_llvm)
|
||||
aot.Append ("no-direct-calls,");
|
||||
|
||||
if (!app.UseDlsym (filename))
|
||||
aot.Append ("direct-pinvoke,");
|
||||
|
||||
if (app.EnableMSym) {
|
||||
var msymdir = Path.Combine (outputDir, "Msym");
|
||||
aot.Append ($"msym-dir={msymdir},");
|
||||
}
|
||||
|
||||
if (enable_llvm)
|
||||
aot.Append ("llvm-path=").Append (Driver.GetFrameworkCurrentDirectory (app)).Append ("/LLVM/bin/,");
|
||||
|
||||
aot.Append ("outfile=").Append (outputFile);
|
||||
if (enable_llvm)
|
||||
aot.Append (",llvm-outfile=").Append (llvmOutputFile);
|
||||
args.Add (aot.ToString ());
|
||||
args.Add (filename);
|
||||
return args;
|
||||
}
|
||||
|
||||
public string AssemblyName {
|
||||
get {
|
||||
return Path.GetFileName (RootAssemblies [0]);
|
||||
|
|
|
@ -42,8 +42,6 @@ namespace Xamarin.Bundler {
|
|||
|
||||
public string Compiler = string.Empty;
|
||||
|
||||
public string AotArguments = "static,asmonly,direct-icalls,";
|
||||
public List<string> AotOtherArguments = null;
|
||||
public bool? LLVMAsmWriter;
|
||||
public Dictionary<string, string> LLVMOptimizations = new Dictionary<string, string> ();
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ namespace Xamarin.Bundler {
|
|||
aotInfo.AotDataFiles.Add (data);
|
||||
|
||||
var aotCompiler = Driver.GetAotCompiler (App, abi, Target.Is64Build);
|
||||
var aotArgs = Driver.GetAotArguments (App, assembly_path, abi, build_dir, asm_output ?? other_output, llvm_aot_ofile, data);
|
||||
var aotArgs = App.GetAotArguments (assembly_path, abi, build_dir, asm_output ?? other_output, llvm_aot_ofile, data);
|
||||
var task = new AOTTask
|
||||
{
|
||||
Assembly = this,
|
||||
|
|
|
@ -52,24 +52,15 @@ using System.IO;
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
using Mono.Options;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using Mono.Tuner;
|
||||
|
||||
using MonoTouch.Tuner;
|
||||
using Registrar;
|
||||
using ObjCRuntime;
|
||||
|
||||
using Xamarin.Linker;
|
||||
using Xamarin.Utils;
|
||||
|
||||
using Xamarin.MacDev;
|
||||
|
||||
public enum OutputFormat {
|
||||
Default,
|
||||
Xml,
|
||||
|
@ -221,81 +212,6 @@ namespace Xamarin.Bundler
|
|||
}
|
||||
}
|
||||
|
||||
public static IList<string> GetAotArguments (Application app, string filename, Abi abi, string outputDir, string outputFile, string llvmOutputFile, string dataFile)
|
||||
{
|
||||
string fname = Path.GetFileName (filename);
|
||||
var args = new List<string> ();
|
||||
bool enable_llvm = (abi & Abi.LLVM) != 0;
|
||||
bool enable_thumb = (abi & Abi.Thumb) != 0;
|
||||
bool enable_debug = app.EnableDebug;
|
||||
bool enable_debug_symbols = app.PackageManagedDebugSymbols;
|
||||
bool llvm_only = app.EnableLLVMOnlyBitCode;
|
||||
bool interp = app.IsInterpreted (Assembly.GetIdentity (filename));
|
||||
bool interp_full = !interp && app.UseInterpreter;
|
||||
bool is32bit = (abi & Abi.Arch32Mask) > 0;
|
||||
string arch = abi.AsArchString ();
|
||||
|
||||
args.Add ("--debug");
|
||||
|
||||
if (enable_llvm)
|
||||
args.Add ("--llvm");
|
||||
|
||||
if (!llvm_only && !interp)
|
||||
args.Add ("-O=gsharedvt");
|
||||
if (app.AotOtherArguments != null)
|
||||
args.AddRange (app.AotOtherArguments);
|
||||
var aot = new StringBuilder ();
|
||||
aot.Append ("--aot=mtriple=");
|
||||
aot.Append (enable_thumb ? arch.Replace ("arm", "thumb") : arch);
|
||||
aot.Append ("-ios,");
|
||||
aot.Append ("data-outfile=").Append (dataFile).Append (",");
|
||||
aot.Append (app.AotArguments);
|
||||
if (llvm_only)
|
||||
aot.Append ("llvmonly,");
|
||||
else if (interp) {
|
||||
if (fname != "mscorlib.dll")
|
||||
throw ErrorHelper.CreateError (99, Errors.MX0099, fname);
|
||||
aot.Append ("interp,");
|
||||
} else if (interp_full) {
|
||||
aot.Append ("interp,full,");
|
||||
} else
|
||||
aot.Append ("full,");
|
||||
|
||||
var aname = Path.GetFileNameWithoutExtension (fname);
|
||||
var sdk_or_product = Profile.IsSdkAssembly (aname) || Profile.IsProductAssembly (aname);
|
||||
|
||||
if (enable_llvm)
|
||||
aot.Append ("nodebug,");
|
||||
else if (!(enable_debug || enable_debug_symbols))
|
||||
aot.Append ("nodebug,");
|
||||
else if (app.DebugAll || app.DebugAssemblies.Contains (fname) || !sdk_or_product)
|
||||
aot.Append ("soft-debug,");
|
||||
|
||||
aot.Append ("dwarfdebug,");
|
||||
|
||||
/* Needed for #4587 */
|
||||
if (enable_debug && !enable_llvm)
|
||||
aot.Append ("no-direct-calls,");
|
||||
|
||||
if (!app.UseDlsym (filename))
|
||||
aot.Append ("direct-pinvoke,");
|
||||
|
||||
if (app.EnableMSym) {
|
||||
var msymdir = Path.Combine (outputDir, "Msym");
|
||||
aot.Append ($"msym-dir={msymdir},");
|
||||
}
|
||||
|
||||
if (enable_llvm)
|
||||
aot.Append ("llvm-path=").Append (GetFrameworkCurrentDirectory (app)).Append ("/LLVM/bin/,");
|
||||
|
||||
aot.Append ("outfile=").Append (outputFile);
|
||||
if (enable_llvm)
|
||||
aot.Append (",llvm-outfile=").Append (llvmOutputFile);
|
||||
args.Add (aot.ToString ());
|
||||
args.Add (filename);
|
||||
return args;
|
||||
}
|
||||
|
||||
public static void CopyAssembly (string source, string target, string target_dir = null)
|
||||
{
|
||||
if (File.Exists (target))
|
||||
|
|
Загрузка…
Ссылка в новой задаче