From 2116ba59de4a2b054505017955baa12447230909 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 15 Jul 2021 11:57:21 +0200 Subject: [PATCH] [tools] Pass the AOTCompiler property to the ComputeAOTArguments linker steps. So that the ComputeAOTArguments can compute the llvm-path value to pass to the AOT compiler (the llvm-path value states where the opt and llc command-line tools are, and they're next to the AOT compiler). --- dotnet/targets/Xamarin.Shared.Sdk.targets | 1 + tools/common/Application.cs | 11 ++++++++--- tools/dotnet-linker/LinkerConfiguration.cs | 4 ++++ tools/dotnet-linker/Steps/ComputeAOTArguments.cs | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 82a5fc9d33..fdeedefa66 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -356,6 +356,7 @@ <_CustomLinkerOptions> AssemblyName=$(AssemblyName).dll + AOTCompiler=$(_AOTCompiler) AOTOutputDirectory=$(_AOTOutputDirectory) CacheDirectory=$(_LinkerCacheDirectory) Debug=$(_BundlerDebug) diff --git a/tools/common/Application.cs b/tools/common/Application.cs index 8bf93ee708..dd83b7993c 100644 --- a/tools/common/Application.cs +++ b/tools/common/Application.cs @@ -1408,7 +1408,7 @@ namespace Xamarin.Bundler { return processArguments; } - public void GetAotArguments (string filename, Abi abi, string outputDir, string outputFile, string llvmOutputFile, string dataFile, out List processArguments, out List aotArguments) + public void GetAotArguments (string filename, Abi abi, string outputDir, string outputFile, string llvmOutputFile, string dataFile, out List processArguments, out List aotArguments, string llvm_path = null) { string fname = Path.GetFileName (filename); processArguments = new List (); @@ -1472,8 +1472,13 @@ namespace Xamarin.Bundler { aotArguments.Add ($"msym-dir={msymdir}"); } - if (enable_llvm) - aotArguments.Add ($"llvm-path={Driver.GetFrameworkCurrentDirectory (app)}/LLVM/bin/"); + if (enable_llvm) { + if (!string.IsNullOrEmpty (llvm_path)) { + aotArguments.Add ($"llvm-path={llvm_path}"); + } else { + aotArguments.Add ($"llvm-path={Driver.GetFrameworkCurrentDirectory (app)}/LLVM/bin/"); + } + } aotArguments.Add ($"outfile={outputFile}"); if (enable_llvm) diff --git a/tools/dotnet-linker/LinkerConfiguration.cs b/tools/dotnet-linker/LinkerConfiguration.cs index c48914dc87..1008854862 100644 --- a/tools/dotnet-linker/LinkerConfiguration.cs +++ b/tools/dotnet-linker/LinkerConfiguration.cs @@ -17,6 +17,7 @@ using ObjCRuntime; namespace Xamarin.Linker { public class LinkerConfiguration { public List Abis; + public string AOTCompiler; public string AOTOutputDirectory; public string CacheDirectory { get; private set; } public Version DeploymentTarget { get; private set; } @@ -104,6 +105,9 @@ namespace Xamarin.Linker { // This is the AssemblyName MSBuild property for the main project (which is also the root/entry assembly) Application.RootAssemblies.Add (value); break; + case "AOTCompiler": + AOTCompiler = value; + break; case "AOTOutputDirectory": AOTOutputDirectory = value; break; diff --git a/tools/dotnet-linker/Steps/ComputeAOTArguments.cs b/tools/dotnet-linker/Steps/ComputeAOTArguments.cs index 079b08e2f5..0b6535c636 100644 --- a/tools/dotnet-linker/Steps/ComputeAOTArguments.cs +++ b/tools/dotnet-linker/Steps/ComputeAOTArguments.cs @@ -39,7 +39,7 @@ namespace Xamarin.Linker { var llvmFile = string.Empty; if ((abi & Abi.LLVM) == Abi.LLVM) throw ErrorHelper.CreateError (99, $"Support for LLVM hasn't been implemented yet."); - app.GetAotArguments (asm.FullPath, abi, outputDirectory, aotAssembly, llvmFile, aotData, out var processArguments, out var aotArguments); + app.GetAotArguments (asm.FullPath, abi, outputDirectory, aotAssembly, llvmFile, aotData, out var processArguments, out var aotArguments, Path.GetDirectoryName (Configuration.AOTCompiler)); item.Metadata.Add ("Arguments", StringUtils.FormatArguments (aotArguments)); item.Metadata.Add ("ProcessArguments", StringUtils.FormatArguments (processArguments)); item.Metadata.Add ("Abi", abiString);