Enable builds of mono VM with LLVM JIT
authorJo Shields <directhex@apebox.org>
Mon, 10 Feb 2020 19:42:44 +0000 (14:42 -0500)
committerGitHub <noreply@github.com>
Mon, 10 Feb 2020 19:42:44 +0000 (14:42 -0500)
The meta-package for LLVM dependencies will be done as a follow up

eng/Version.Details.xml
eng/Versions.props
eng/pipelines/mono/templates/build-job.yml
eng/pipelines/mono/templates/xplat-pipeline-job.yml
eng/pipelines/runtime.yml
src/mono/llvm/Makefile.am
src/mono/llvm/build_llvm_config.sh [new file with mode: 0755]
src/mono/llvm/llvm-init.proj [new file with mode: 0644]
src/mono/mono.proj

index 4c297a0..413207f 100644 (file)
       <Uri>https://github.com/dotnet/runtime-assets</Uri>
       <Sha>572e952eae1d4fc6e83300031c5f7c401014ff34</Sha>
     </Dependency>
+    <Dependency Name="runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="6.0.1-alpha.1.20078.4">
+      <Uri>https://github.com/dotnet/llvm-project</Uri>
+      <Sha>adeaa08e7bbc9aba5d67cb16c2b348be12deb000</Sha>
+    </Dependency>
+    <Dependency Name="runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools" Version="6.0.1-alpha.1.20078.4">
+      <Uri>https://github.com/dotnet/llvm-project</Uri>
+      <Sha>adeaa08e7bbc9aba5d67cb16c2b348be12deb000</Sha>
+    </Dependency>
+    <Dependency Name="runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="6.0.1-alpha.1.20078.4">
+      <Uri>https://github.com/dotnet/llvm-project</Uri>
+      <Sha>adeaa08e7bbc9aba5d67cb16c2b348be12deb000</Sha>
+    </Dependency>
+    <Dependency Name="runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools" Version="6.0.1-alpha.1.20078.4">
+      <Uri>https://github.com/dotnet/llvm-project</Uri>
+      <Sha>adeaa08e7bbc9aba5d67cb16c2b348be12deb000</Sha>
+    </Dependency>
+    <Dependency Name="runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="6.0.1-alpha.1.20078.4">
+      <Uri>https://github.com/dotnet/llvm-project</Uri>
+      <Sha>adeaa08e7bbc9aba5d67cb16c2b348be12deb000</Sha>
+    </Dependency>
+    <Dependency Name="runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools" Version="6.0.1-alpha.1.20078.4">
+      <Uri>https://github.com/dotnet/llvm-project</Uri>
+      <Sha>adeaa08e7bbc9aba5d67cb16c2b348be12deb000</Sha>
+    </Dependency>
   </ToolsetDependencies>
 </Dependencies>
index 143f1f2..c8a4975 100644 (file)
     <MicrosoftPrivateIntellisenseVersion>3.0.0-preview9-190909-1</MicrosoftPrivateIntellisenseVersion>
     <!-- ILLink -->
     <ILLinkTasksVersion>0.1.6-prerelease.19567.1</ILLinkTasksVersion>
+    <!-- Mono LLVM -->
+    <runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>6.0.1-alpha.1.20078.4</runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>
+    <runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion>6.0.1-alpha.1.20078.4</runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion>
+    <runtimewinx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>6.0.1-alpha.1.20078.4</runtimewinx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>
+    <runtimewinx64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion>6.0.1-alpha.1.20078.4</runtimewinx64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion>
+    <runtimeosx1012x64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>6.0.1-alpha.1.20078.4</runtimeosx1012x64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>
+    <runtimeosx1012x64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion>6.0.1-alpha.1.20078.4</runtimeosx1012x64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion>
   </PropertyGroup>
   <!-- Package names -->
   <PropertyGroup>
index 2b4f9c5..ea80704 100644 (file)
@@ -9,6 +9,7 @@ parameters:
   variables: {}
   pool: ''
   condition: true
+  llvm: false
 
 ### Product build
 jobs:
@@ -21,11 +22,19 @@ jobs:
     helixType: 'build/product/'
     enableMicrobuild: true
     pool: ${{ parameters.pool }}
+    llvm: ${{ parameters.llvm }}
     condition: ${{ parameters.condition }}
 
     # Compute job name from template parameters
-    name: ${{ format('mono_product_build_{0}{1}_{2}_{3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.buildConfig) }}
-    displayName: ${{ format('Mono Product Build {0}{1} {2} {3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.buildConfig) }}
+    ${{ if ne(parameters.llvm, true) }}:
+      name: ${{ format('mono_product_build_{0}{1}_{2}_{3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.buildConfig) }}
+      displayName: ${{ format('Mono Product Build {0}{1} {2} {3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.buildConfig) }}
+
+    # if LLVM enabled, set a variable we can consume
+    ${{ if eq(parameters.llvm, true) }}:
+      name: ${{ format('mono_llvm_product_build_{0}{1}_{2}_{3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.buildConfig) }}
+      displayName: ${{ format('Mono LLVM Product Build {0}{1} {2} {3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.buildConfig) }}
+
 
     # Run all steps in the container.
     # Note that the containers are defined in platform-matrix.yml
@@ -58,10 +67,10 @@ jobs:
 
     # Build
     - ${{ if ne(parameters.osGroup, 'Windows_NT') }}:
-      - script: ./mono$(scriptExt) -configuration $(buildConfig) -arch $(archType) -ci
+      - script: ./mono$(scriptExt) -configuration $(buildConfig) -arch $(archType) -ci /p:MonoEnableLLVM=${{ parameters.llvm }}
         displayName: Build product
     - ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
-      - script: mono$(scriptExt) -configuration $(buildConfig) -arch $(archType) -ci
+      - script: mono$(scriptExt) -configuration $(buildConfig) -arch $(archType) -ci /p:MonoEnableLLVM=${{ parameters.llvm }}
         displayName: Build product
 
     # Publish product output directory for consumption by tests.
@@ -80,6 +89,9 @@ jobs:
       displayName: Publish Logs
       inputs:
         pathtoPublish: $(Build.SourcesDirectory)/artifacts/log
-        artifactName: 'BuildLogs_Mono_$(osGroup)$(osSubgroup)_$(archType)_$(buildConfig)'
+        ${{ if ne(parameters.llvm, true) }}:
+          artifactName: 'BuildLogs_Mono_$(osGroup)$(osSubgroup)_$(archType)_$(buildConfig)'
+        ${{ if eq(parameters.llvm, true) }}:
+          artifactName: 'BuildLogs_Mono_LLVM_$(osGroup)$(osSubgroup)_$(archType)_$(buildConfig)'
       continueOnError: true
       condition: always()
index 954cbdb..a0d6584 100644 (file)
@@ -9,6 +9,7 @@ parameters:
   liveLibrariesBuildConfig: ''
   strategy: ''
   pool: ''
+  llvm: false
 
   # arcade-specific parameters
   condition: true
@@ -33,6 +34,7 @@ jobs:
     container: ${{ parameters.container }}
     strategy: ${{ parameters.strategy }}
     pool: ${{ parameters.pool }}
+    llvm: ${{ parameters.llvm }}
 
     # arcade-specific parameters
     condition: and(succeeded(), ${{ parameters.condition }})
@@ -45,7 +47,10 @@ jobs:
 
     variables:
     - name: buildProductArtifactName
-      value: 'MonoProduct_$(osGroup)$(osSubgroup)_$(archType)_$(buildConfig)'
+      ${{ if ne(parameters.llvm, true) }}:
+        value: 'MonoProduct_$(osGroup)$(osSubgroup)_$(archType)_$(buildConfig)'
+      ${{ if eq(parameters.llvm, true) }}:
+        value: 'MonoProduct_LLVM_$(osGroup)$(osSubgroup)_$(archType)_$(buildConfig)'
 
     - name: buildProductRootFolderPath
       value: '$(Build.SourcesDirectory)/artifacts/bin/mono/$(osGroup).$(archType).$(buildConfigUpper)'
index 117601b..d795d01 100644 (file)
@@ -253,6 +253,62 @@ jobs:
           eq(variables['isFullMatrix'], true))
 
 #
+# Build Mono LLVM debug
+# Only when libraries or mono changed
+#
+- template: /eng/pipelines/common/platform-matrix.yml
+  parameters:
+    jobTemplate: /eng/pipelines/mono/templates/build-job.yml
+    runtimeFlavor: mono
+    buildConfig: debug
+    platforms:
+    # - OSX_x64
+    - Linux_x64
+    # - Linux_arm
+    # - Linux_arm64
+    # - Linux_musl_x64
+    # - Linux_musl_arm64
+    # - Windows_NT_x64
+    # - Windows_NT_x86
+    # - Windows_NT_arm
+    # - Windows_NT_arm64
+    jobParameters:
+      llvm: true
+      condition: >-
+        or(
+          eq(dependencies.checkout.outputs['SetPathVars_libraries.containsChange'], true),
+          eq(dependencies.checkout.outputs['SetPathVars_mono.containsChange'], true),
+          eq(variables['isFullMatrix'], true))
+
+#
+# Build Mono LLVM release
+# Only when libraries or mono changed
+#
+- template: /eng/pipelines/common/platform-matrix.yml
+  parameters:
+    jobTemplate: /eng/pipelines/mono/templates/build-job.yml
+    runtimeFlavor: mono
+    buildConfig: release
+    platforms:
+    # - OSX_x64
+    - Linux_x64
+    # - Linux_arm
+    # - Linux_arm64
+    # - Linux_musl_x64
+    # - Linux_musl_arm64
+    # - Windows_NT_x64
+    # - Windows_NT_x86
+    # - Windows_NT_arm
+    # - Windows_NT_arm64
+    jobParameters:
+      llvm: true
+      condition: >-
+        or(
+          eq(dependencies.checkout.outputs['SetPathVars_libraries.containsChange'], true),
+          eq(dependencies.checkout.outputs['SetPathVars_mono.containsChange'], true),
+          eq(variables['isFullMatrix'], true))
+
+#
 # Build libraries using live CoreLib
 # These set of libraries are built always no matter what changed
 # The reason for that is because Corelib and Installer needs it and
index 982a79b..1664965 100644 (file)
@@ -1,2 +1,51 @@
-# temporary Makefile until we can fully move netcore mono to new repo
-all:
+if ENABLE_LLVM
+
+if HOST_WIN32
+llvm_config=llvm-config.exe
+else
+llvm_config=llvm-config
+endif
+
+if HAVE_STATIC_ZLIB
+llvm_extra_libs = $(STATIC_ZLIB_PATH)
+else
+if HAVE_SYS_ZLIB
+llvm_extra_libs=-lz
+else
+llvm_extra_libs=
+endif
+endif
+
+if INTERNAL_LLVM_ASSERTS
+ENABLE_ASSERTS=On
+else
+ENABLE_ASSERTS=Off
+endif
+
+all-local: llvm_config.mk
+
+clean-local: clean-llvm-config
+
+$(mono_build_root)/llvm/llvm_config.mk: $(top_srcdir)/llvm/Makefile.am
+       $(top_srcdir)/llvm/build_llvm_config.sh "$(EXTERNAL_LLVM_CONFIG)" "$(LLVM_CODEGEN_LIBS)" "$(llvm_extra_libs)" | tee $@
+
+llvm_config.mk: $(mono_build_root)/llvm/llvm_config.mk
+
+clean-llvm-config:
+       - rm -rf llvm_config.mk
+
+else
+all-local: 
+
+clean-local: 
+endif
+
+# Override this so we don't try to re-copy llvm when we install mono
+install:
+
+if TARGET_WASM
+LLVM_TARGET=wasm32
+else
+LLVM_TARGET=
+endif
+
diff --git a/src/mono/llvm/build_llvm_config.sh b/src/mono/llvm/build_llvm_config.sh
new file mode 100755 (executable)
index 0000000..7880d84
--- /dev/null
@@ -0,0 +1,172 @@
+#!/bin/bash
+
+llvm_config=$1
+llvm_codegen_libs="$2"
+llvm_extra_libs="${@:3}"
+
+use_llvm_config=1
+llvm_host_win32=0
+llvm_host_win32_wsl=0
+llvm_host_win32_cygwin=0
+
+function win32_format_path {
+       local formatted_path=$1
+       if  [[ $llvm_host_win32_wsl = 1 ]] && [[ $1 != "/mnt/"* ]]; then
+               # if path is not starting with /mnt under WSL it could be a windows path, convert using wslpath.
+               formatted_path="$(wslpath -a "$1")"
+       elif [[ $llvm_host_win32_cygwin = 1 ]] && [[ $1 != "/cygdrive/"* ]]; then
+               # if path is not starting with /cygdrive under CygWin it could be a windows path, convert using cygpath.
+               formatted_path="$(cygpath -a "$1")"
+       fi
+       echo "$formatted_path"
+}
+
+if [[ $llvm_config = *".exe" ]]; then
+       llvm_host_win32=1
+       # llvm-config is a windows binary. Check if we are running CygWin or WSL since then we might still be able to run llvm-config.exe
+       host_uname="$(uname -a)"
+       case "$host_uname" in
+               *Microsoft*)
+                       use_llvm_config=1
+                       llvm_host_win32_wsl=1
+                       ;;
+               CYGWIN*)
+                       use_llvm_config=1
+                       llvm_host_win32_cygwin=1
+                       ;;
+               *)
+                       use_llvm_config=0
+       esac
+fi
+
+if [[ $llvm_host_win32 = 1 ]]; then
+       llvm_config=$(win32_format_path "$llvm_config")
+fi
+
+if [[ $use_llvm_config = 1 ]]; then
+       llvm_api_version=`$llvm_config --mono-api-version` || "0"
+       with_llvm=`$llvm_config --prefix`
+       llvm_config_cflags=`$llvm_config --cflags`
+       llvm_system=`$llvm_config --system-libs`
+       llvm_core_components=`$llvm_config --libs analysis core bitwriter`
+       if [[ $llvm_api_version -lt 600 ]]; then
+               llvm_old_jit=`$llvm_config --libs mcjit jit 2>>/dev/null`
+       else
+               llvm_old_jit=`$llvm_config --libs mcjit 2>>/dev/null`
+       fi
+       llvm_new_jit=`$llvm_config --libs orcjit 2>>/dev/null`
+
+       if [[ ! -z $llvm_codegen_libs ]]; then
+               llvm_extra=`$llvm_config --libs $llvm_codegen_libs`
+       fi
+
+       # When building for Windows subsystem using WSL or CygWin the path returned from llvm-config.exe
+       # could be a Windows style path, make sure to format it into a path usable for WSL/CygWin.
+       if [[ $llvm_host_win32 = 1 ]]; then
+               with_llvm=$(win32_format_path "$with_llvm")
+       fi
+fi
+
+# When cross compiling for Windows on system not capable of running Windows binaries, llvm-config.exe can't be used to query for
+# LLVM parameters. In that scenario we will need to fallback to default values.
+if [[ $llvm_host_win32 = 1 ]] && [[ $use_llvm_config = 0 ]]; then
+       # Assume we have llvm-config sitting in llvm-install-root/bin directory, get llvm-install-root directory.
+       with_llvm="$(dirname $llvm_config)"
+       with_llvm="$(dirname $with_llvm)"
+       llvm_config_path=$with_llvm/include/llvm/Config/llvm-config.h
+
+       # llvm-config.exe --mono-api-version
+       llvm_api_version=`awk '/MONO_API_VERSION/ { print $3 }' $llvm_config_path`
+
+       # llvm-config.exe --cflags, returned information currently not used.
+       llvm_config_cflags=
+
+       # llvm-config.exe --system-libs
+       if [[ $llvm_api_version -lt 600 ]]; then
+               llvm_system="-limagehlp -lpsapi -lshell32"
+       else
+               llvm_system="-lpsapi -lshell32 -lole32 -luuid -ladvapi32"
+       fi
+
+       # llvm-config.exe --libs analysis core bitwriter
+       if [[ $llvm_api_version -lt 600 ]]; then
+               llvm_core_components="-lLLVMBitWriter -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport"
+       else
+               llvm_core_components="-lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle"
+       fi
+
+       # llvm-config.exe --libs mcjit jit
+       if [[ $llvm_api_version -lt 600 ]]; then
+               llvm_old_jit="-lLLVMJIT -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMMCJIT -lLLVMTarget -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMExecutionEngine -lLLVMMC -lLLVMCore -lLLVMSupport"
+       else
+               # Current build of LLVM 60 for cross Windows builds doesn't support LLVM JIT.
+               llvm_old_jit=
+       fi
+
+       # LLVM 36 doesn't support new JIT and LLVM 60 is build without LLVM JIT support for cross Windows builds.
+       llvm_new_jit=
+
+       # Check codegen libs and add needed libraries.
+       case "$llvm_codegen_libs" in
+               *x86codegen*)
+                       # llvm-config.exe --libs x86codegen
+                       if [[ $llvm_api_version -lt 600 ]]; then
+                               llvm_extra="-lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMObject -lLLVMBitReader -lLLVMMCDisassembler -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport"
+                       else
+                               llvm_extra="-lLLVMX86CodeGen -lLLVMGlobalISel -lLLVMX86Desc -lLLVMX86Info -lLLVMMCDisassembler -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle"
+                       fi
+                       ;;
+               *armcodegen*)
+                       # llvm-config.exe --libs armcodegen
+                       if [[ $llvm_api_version -lt 600 ]]; then
+                               llvm_extra="-lLLVMARMCodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMARMDesc -lLLVMMCDisassembler -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMMC -lLLVMSupport"
+                       else
+                               llvm_extra="-lLLVMARMCodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMARMDesc -lLLVMMCDisassembler -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMARMUtils -lLLVMMC -lLLVMSupport -lLLVMDemangle"
+                       fi
+                       ;;
+               *aarch64codegen*)
+                       # llvm-config.exe --libs aarch64codegen
+                       if [[ $llvm_api_version -lt 600 ]]; then
+                               llvm_extra="-lLLVMAArch64CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -lLLVMSupport"
+                       else
+                               llvm_extra="-lLLVMAArch64CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -lLLVMSupport -lLLVMDemangle"
+                       fi
+                       ;;
+               *)
+                       llvm_extra=$llvm_codegen_libs
+       esac
+fi
+
+if [[ $llvm_config_cflags = *"stdlib=libc++"* ]]; then
+       llvm_libc_c="-stdlib=libc++"
+       # llvm_libc_link="-lc++"
+else
+       llvm_libc_c=""
+       # llvm_libc_link="-lstdc++"
+fi
+
+if [[ $llvm_host_win32 = 1 ]]; then
+       host_cxxflag_additions="-std=gnu++11"
+       host_cflag_additions="-DNDEBUG"
+else
+       host_cxxflag_additions="-std=c++11"
+       host_cflag_additions=""
+fi
+
+if [[ ! -z $llvm_extra_libs ]]; then
+       llvm_extra="$llvm_extra $llvm_extra_libs"
+fi
+
+# llvm-config --clfags adds warning and optimization flags we don't want
+cflags_additions="-I$with_llvm/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DLLVM_API_VERSION=$llvm_api_version $llvm_libc_c $host_cflag_additions"
+
+cxxflag_additions="-fno-rtti -fexceptions $host_cxxflag_additions"
+
+ldflags="-L$with_llvm/lib"
+
+llvm_lib_components="$llvm_core_components $llvm_old_jit $llvm_new_jit $llvm_extra"
+
+echo "LLVM_CFLAGS_INTERNAL=$cflags_additions"
+echo "LLVM_CXXFLAGS_INTERNAL=$cflags_additions $cxxflag_additions"
+echo "LLVM_LDFLAGS_INTERNAL=$ldflags"
+echo "LLVM_LIBS_INTERNAL=$llvm_lib_components $ldflags $llvm_system $llvm_libc_link"
diff --git a/src/mono/llvm/llvm-init.proj b/src/mono/llvm/llvm-init.proj
new file mode 100644 (file)
index 0000000..4a6027a
--- /dev/null
@@ -0,0 +1,27 @@
+<Project Sdk="Microsoft.Build.NoTargets">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp5.0</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Condition="'$(OSGroup)' == 'Linux'" Include="runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="$(runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion)" />
+    <PackageReference Condition="'$(OSGroup)' == 'Linux'" Include="runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools" Version="$(runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion)" />
+    <PackageReference Condition="'$(OSGroup)' == 'Windows_NT'" Include="runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="$(runtimewinx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion)" />
+    <PackageReference Condition="'$(OSGroup)' == 'Windows_NT'" Include="runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools" Version="$(runtimewinx64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion)" />
+    <PackageReference Condition="'$(OSGroup)' == 'OSX'" Include="runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="$(runtimeosx1012x64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion)" />
+    <PackageReference Condition="'$(OSGroup)' == 'OSX'" Include="runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools" Version="$(runtimeosx1012x64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion)" />
+  </ItemGroup>
+
+  <Target Name="CopyLLVMToTree" AfterTargets="Restore">
+    <ItemGroup>
+      <LLVMFiles Include="$(NuGetPackageRoot)\runtime.$(NETCoreSdkRuntimeIdentifier).microsoft.netcore.runtime.mono.llvm.sdk\$(runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion)\tools\$(NETCoreSdkRuntimeIdentifier)\**" />
+      <LLVMFiles Include="$(NuGetPackageRoot)\runtime.$(NETCoreSdkRuntimeIdentifier).microsoft.netcore.runtime.mono.llvm.tools\$(runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion)\tools\$(NETCoreSdkRuntimeIdentifier)\**" />
+    </ItemGroup>
+
+    <Copy SourceFiles="@(LLVMFiles)" DestinationFolder="$(MonoLLVMDir)\%(RecursiveDir)">
+      <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
+    </Copy>
+  </Target>
+
+</Project>
index 16e1006..c64c531 100644 (file)
@@ -4,7 +4,8 @@
 
   <PropertyGroup>
     <MonoObjDir>$(ArtifactsObjDir)mono/$(PlatformConfigPathPart)/</MonoObjDir>
-    <MonoEnableLLVM Condition=" '$(MonoEnableLLVM)' == '' ">false</MonoEnableLLVM>
+    <MonoEnableLLVM Condition="'$(MonoEnableLLVM)' == ''">false</MonoEnableLLVM>
+    <MonoLLVMDir Condition="'$(MonoEnableLLVM)' == 'true'">$(MonoObjDir)llvm</MonoLLVMDir>
     <DotNetExec Condition="'$(OS)' == 'Windows_NT'">dotnet.exe</DotNetExec>
     <DotNetExec Condition="'$(DotNetExec)' == ''">dotnet</DotNetExec>
     <LocalDotnetDir>..\..\.dotnet</LocalDotnetDir>
@@ -32,7 +33,7 @@
         <_MonoExtraCXXFLAGS>-O2 -g</_MonoExtraCXXFLAGS>
     </PropertyGroup>
     <PropertyGroup>
-        <_MonoConfigureParams Condition="$(MonoEnableLLVM) == true">$(_MonoConfigureParams) --enable--llvm </_MonoConfigureParams>
+        <_MonoConfigureParams Condition="'$(MonoEnableLLVM)' == 'true'">$(_MonoConfigureParams) --enable--llvm --with-llvm=$(MonoLLVMDir) </_MonoConfigureParams>
         <_MonoConfigureParams>$(_MonoConfigureParams) --enable-maintainer-mode --enable-compile-warnings --with-core=only CFLAGS="$(_MonoExtraCFLAGS)" CXXFLAGS="$(_MonoExtraCXXFLAGS)"</_MonoConfigureParams>
     </PropertyGroup>
 
@@ -88,6 +89,7 @@
 
   <Target Name="Restore">
     <MSBuild Projects="$(MonoProjectRoot)netcore\nuget\packages.builds" Targets="Restore" />
+    <MSBuild Condition="'$(MonoEnableLLVM)' == 'true'" Projects="$(MonoProjectRoot)llvm\llvm-init.proj" Targets="Restore" Properties="MonoObjDir=$(MonoObjDir);MonoLLVMDir=$(MonoLLVMDir)" />
   </Target>
 
   <Target Name="Pack">