From 743a570dead93dc4045ad6cab30e9df6b2026d32 Mon Sep 17 00:00:00 2001 From: Anton Lapounov Date: Tue, 26 Jan 2021 14:24:45 -0800 Subject: [PATCH] Support cross-architecture compilation in ILC (#591) * Support cross-architecture compilation in ILC * Fix paths for CMake and build.sh * Fix slashes in #include's path * Replace 'git restore' with 'git checkout' * Use 'exit /b 1' consistently in build.cmd --- NuGet.config | 3 +- eng/Subsets.props | 10 ++--- eng/pipelines/runtimelab.yml | 2 +- .../Common/JitInterface/JitConfigProvider.cs | 4 -- .../tools/aot/ILCompiler/ILCompiler.csproj | 43 +++++++++++++++---- src/coreclr/tools/aot/ObjWriter/build.cmd | 11 +++-- src/coreclr/tools/aot/ObjWriter/build.sh | 2 +- src/coreclr/tools/aot/ObjWriter/objwriter.cpp | 2 +- .../tools/aot/ObjWriter/objwriter.proj | 2 +- 9 files changed, 52 insertions(+), 27 deletions(-) mode change 100644 => 100755 src/coreclr/tools/aot/ObjWriter/build.sh diff --git a/NuGet.config b/NuGet.config index db89e29d5129..7789ca1a6fb5 100644 --- a/NuGet.config +++ b/NuGet.config @@ -14,12 +14,11 @@ + - - diff --git a/eng/Subsets.props b/eng/Subsets.props index ab7e48355135..776762db0ae0 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -48,7 +48,7 @@ clr.runtime+clr.jit+clr.alljits+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.packages - clr.jit+nativeaot.tools+nativeaot.libs + clr.jit+clr.alljits+nativeaot.tools+nativeaot.libs mono.llvm+ mono.llvm+ @@ -235,6 +235,10 @@ + + + + @@ -242,10 +246,6 @@ - - - - diff --git a/eng/pipelines/runtimelab.yml b/eng/pipelines/runtimelab.yml index 5e4aecaf7c52..c590caea2a79 100644 --- a/eng/pipelines/runtimelab.yml +++ b/eng/pipelines/runtimelab.yml @@ -103,7 +103,7 @@ stages: isOfficialBuild: ${{ variables.isOfficialBuild }} timeoutInMinutes: 90 testGroup: innerloop - buildArgs: -s nativeaot+libs+nativeaot.packages -c release + buildArgs: -s nativeaot.objwriter+nativeaot+libs+nativeaot.packages -c release extraStepsTemplate: /eng/pipelines/runtimelab/runtimelab-post-build-steps.yml extraStepsParameters: uploadIntermediateArtifacts: ${{ variables.isOfficialBuild }} diff --git a/src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs b/src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs index b1b56fb67de5..b9a806007828 100644 --- a/src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs +++ b/src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs @@ -44,7 +44,6 @@ public static void Initialize( NativeLibrary.SetDllImportResolver(typeof(CorInfoImpl).Assembly, (libName, assembly, searchPath) => { IntPtr libHandle = IntPtr.Zero; -#if READYTORUN if (libName == CorInfoImpl.JitLibrary) { if (!string.IsNullOrEmpty(jitPath)) @@ -56,9 +55,6 @@ public static void Initialize( libHandle = NativeLibrary.Load("clrjit_" + GetTargetSpec(target), assembly, searchPath); } } -#else - Debug.Assert(jitPath == null); -#endif if (libName == CorInfoImpl.JitSupportLibrary) { libHandle = NativeLibrary.Load("jitinterface_" + RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(), assembly, searchPath); diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj b/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj index 7d1bfa0c10dc..9b701f7a85af 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj @@ -9,7 +9,7 @@ AnyCPU false true - $(RuntimeBinDir)/ilc + $(RuntimeBinDir)ilc true false linux-x64;win-x64;osx-x64 @@ -36,16 +36,18 @@ - 1.0.0-alpha-28820-01 + 6.0.0-preview.1.21075.1 1.0.1-prerelease-00005 + $(ArtifactsDir)llvm\build\bin\Release\$(LibraryNamePrefix)objwriter$(LibraryNameExtension) + true - - $(ObjectWriterVersion) + + $(ILCompilerVersion) $(CoreDisToolsVersion) @@ -53,13 +55,20 @@ - + + PreserveNewest + false + false + + + PreserveNewest false false - + PreserveNewest false false @@ -67,14 +76,13 @@ - + PreserveNewest false false - - $(LibraryNamePrefix)clrjitilc$(LibraryNameExtension) + PreserveNewest false false @@ -117,4 +125,21 @@ + + + unix + win + $(TargetOSComponent)_$(TargetArchitecture)_$(TargetArchitecture) + + + + + + + diff --git a/src/coreclr/tools/aot/ObjWriter/build.cmd b/src/coreclr/tools/aot/ObjWriter/build.cmd index 3109902ce789..1e03d3d7a921 100644 --- a/src/coreclr/tools/aot/ObjWriter/build.cmd +++ b/src/coreclr/tools/aot/ObjWriter/build.cmd @@ -13,11 +13,16 @@ git apply "%~dp0llvm.patch" || exit /b 1 :: Copy ObjWriter files robocopy /mir "%~dp0\" tools\ObjWriter -if %ErrorLevel% geq 8 exit /b %ErrorLevel% +if %ErrorLevel% geq 8 exit /b 1 :: Configure and build if not exist build mkdir build cd build || exit /b 1 -cmake ../ -DCMAKE_BUILD_TYPE=Release -DLLVM_OPTIMIZED_TABLEGEN=1 -DHAVE_POSIX_SPAWN=0 -DLLVM_ENABLE_PIC=1 -DLLVM_BUILD_TESTS=0 -DLLVM_ENABLE_DOXYGEN=0 -DLLVM_INCLUDE_DOCS=0 -DLLVM_INCLUDE_TESTS=0 -DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64" -DCMAKE_INSTALL_PREFIX=install || exit /b 1 -cmake --build . -j 10 --config Release --target install || exit /b 1 +:: Set CMakePath by evaluating the output from set-cmake-path.ps1 +call "%2src\coreclr\setup_vs_tools.cmd" || exit /b 1 +for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%2eng\native\set-cmake-path.ps1"""') do %%a +echo Using CMake at "%CMakePath%" + +"%CMakePath%" ../ -DCMAKE_BUILD_TYPE=Release -DLLVM_OPTIMIZED_TABLEGEN=1 -DHAVE_POSIX_SPAWN=0 -DLLVM_ENABLE_PIC=1 -DLLVM_BUILD_TESTS=0 -DLLVM_ENABLE_DOXYGEN=0 -DLLVM_INCLUDE_DOCS=0 -DLLVM_INCLUDE_TESTS=0 -DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64" -DCMAKE_INSTALL_PREFIX=install || exit /b 1 +"%CMakePath%" --build . -j 10 --config Release --target install || exit /b 1 diff --git a/src/coreclr/tools/aot/ObjWriter/build.sh b/src/coreclr/tools/aot/ObjWriter/build.sh old mode 100644 new mode 100755 index 5f4c45160086..515585751900 --- a/src/coreclr/tools/aot/ObjWriter/build.sh +++ b/src/coreclr/tools/aot/ObjWriter/build.sh @@ -9,7 +9,7 @@ if [ ! -d llvm ]; then fi # Clean the tree and apply the patch -cd llvm && git restore . || exit 1 +cd llvm && git checkout -- . || exit 1 git apply "$ScriptPath/llvm.patch" || exit 1 # Add ObjWriter files diff --git a/src/coreclr/tools/aot/ObjWriter/objwriter.cpp b/src/coreclr/tools/aot/ObjWriter/objwriter.cpp index bd00b7bd1a39..d5406d5cf2c6 100644 --- a/src/coreclr/tools/aot/ObjWriter/objwriter.cpp +++ b/src/coreclr/tools/aot/ObjWriter/objwriter.cpp @@ -50,7 +50,7 @@ #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/Win64EH.h" #include "llvm/Target/TargetMachine.h" -#include "..\..\..\lib\Target\AArch64\MCTargetDesc\AArch64MCExpr.h" +#include "../../../lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h" using namespace llvm; using namespace llvm::codeview; diff --git a/src/coreclr/tools/aot/ObjWriter/objwriter.proj b/src/coreclr/tools/aot/ObjWriter/objwriter.proj index 43c948710e0f..172de14b0991 100644 --- a/src/coreclr/tools/aot/ObjWriter/objwriter.proj +++ b/src/coreclr/tools/aot/ObjWriter/objwriter.proj @@ -8,7 +8,7 @@ -