diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 39de114253e9ae..ef0e39d60526c4 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -158,5 +158,29 @@ https://github.com/dotnet/runtime-assets 572e952eae1d4fc6e83300031c5f7c401014ff34 + + https://github.com/dotnet/llvm-project + adeaa08e7bbc9aba5d67cb16c2b348be12deb000 + + + https://github.com/dotnet/llvm-project + adeaa08e7bbc9aba5d67cb16c2b348be12deb000 + + + https://github.com/dotnet/llvm-project + adeaa08e7bbc9aba5d67cb16c2b348be12deb000 + + + https://github.com/dotnet/llvm-project + adeaa08e7bbc9aba5d67cb16c2b348be12deb000 + + + https://github.com/dotnet/llvm-project + adeaa08e7bbc9aba5d67cb16c2b348be12deb000 + + + https://github.com/dotnet/llvm-project + adeaa08e7bbc9aba5d67cb16c2b348be12deb000 + diff --git a/eng/Versions.props b/eng/Versions.props index 131c3ff9ab7b26..6c234420347f1d 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -123,6 +123,13 @@ 3.0.0-preview9-190909-1 0.1.6-prerelease.19567.1 + + 6.0.1-alpha.1.20078.4 + 6.0.1-alpha.1.20078.4 + 6.0.1-alpha.1.20078.4 + 6.0.1-alpha.1.20078.4 + 6.0.1-alpha.1.20078.4 + 6.0.1-alpha.1.20078.4 diff --git a/eng/pipelines/mono/templates/build-job.yml b/eng/pipelines/mono/templates/build-job.yml index 2b4f9c519d5518..ea80704904421b 100644 --- a/eng/pipelines/mono/templates/build-job.yml +++ b/eng/pipelines/mono/templates/build-job.yml @@ -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() diff --git a/eng/pipelines/mono/templates/xplat-pipeline-job.yml b/eng/pipelines/mono/templates/xplat-pipeline-job.yml index 954cbdb20889d0..a0d65845203929 100644 --- a/eng/pipelines/mono/templates/xplat-pipeline-job.yml +++ b/eng/pipelines/mono/templates/xplat-pipeline-job.yml @@ -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)' diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index 117601b565a8fa..d795d01c6014fc 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -252,6 +252,62 @@ jobs: eq(dependencies.checkout.outputs['SetPathVars_mono.containsChange'], true), 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 diff --git a/src/mono/llvm/Makefile.am b/src/mono/llvm/Makefile.am index 982a79bcc586cc..1664965c5a2d7e 100644 --- a/src/mono/llvm/Makefile.am +++ b/src/mono/llvm/Makefile.am @@ -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 index 00000000000000..7880d84e680b1a --- /dev/null +++ b/src/mono/llvm/build_llvm_config.sh @@ -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 index 00000000000000..4a6027a322eb82 --- /dev/null +++ b/src/mono/llvm/llvm-init.proj @@ -0,0 +1,27 @@ + + + + netcoreapp5.0 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 16e1006f4745cf..c64c531bc4fe2b 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -4,7 +4,8 @@ $(ArtifactsObjDir)mono/$(PlatformConfigPathPart)/ - false + false + $(MonoObjDir)llvm dotnet.exe dotnet ..\..\.dotnet @@ -32,7 +33,7 @@ <_MonoExtraCXXFLAGS>-O2 -g - <_MonoConfigureParams Condition="$(MonoEnableLLVM) == true">$(_MonoConfigureParams) --enable--llvm + <_MonoConfigureParams Condition="'$(MonoEnableLLVM)' == 'true'">$(_MonoConfigureParams) --enable--llvm --with-llvm=$(MonoLLVMDir) <_MonoConfigureParams>$(_MonoConfigureParams) --enable-maintainer-mode --enable-compile-warnings --with-core=only CFLAGS="$(_MonoExtraCFLAGS)" CXXFLAGS="$(_MonoExtraCXXFLAGS)" @@ -88,6 +89,7 @@ +