From b3431cd90b38ac7c19c8edc13adeb12d585cee85 Mon Sep 17 00:00:00 2001 From: Jo Shields Date: Fri, 10 Jul 2020 13:37:37 -0400 Subject: [PATCH] Produce arm64-native Mono LLVM runtime packs (#38562) Produce arm64-native Mono LLVM runtime packs (i.e. for running the SDK on ARM64, not publishing to ARM64 from x64) --- eng/Version.Details.xml | 8 +++++ eng/Versions.props | 2 ++ eng/pipelines/common/global-build-job.yml | 8 ++++- eng/pipelines/runtime-official.yml | 2 +- eng/pipelines/runtime.yml | 2 ++ src/mono/llvm/build_llvm_config.sh | 55 +++++++++++++++++++++++++++++++ src/mono/llvm/llvm-init.proj | 14 +++++--- src/mono/mono.proj | 9 +++-- 8 files changed, 92 insertions(+), 8 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 94bac49..46f4d5a 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -122,6 +122,14 @@ https://github.com/dotnet/icu + + https://github.com/dotnet/llvm-project + 266c9f5b5c1e94333e01ca77fa74d76563969842 + + + https://github.com/dotnet/llvm-project + 266c9f5b5c1e94333e01ca77fa74d76563969842 + https://github.com/dotnet/llvm-project 266c9f5b5c1e94333e01ca77fa74d76563969842 diff --git a/eng/Versions.props b/eng/Versions.props index aa56ba0..0aa4eb4 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -120,6 +120,8 @@ 5.0.0-preview.8.20359.5 + 9.0.1-alpha.1.20356.1 + 9.0.1-alpha.1.20356.1 9.0.1-alpha.1.20356.1 9.0.1-alpha.1.20356.1 9.0.1-alpha.1.20356.1 diff --git a/eng/pipelines/common/global-build-job.yml b/eng/pipelines/common/global-build-job.yml index d55570b..8f02954 100644 --- a/eng/pipelines/common/global-build-job.yml +++ b/eng/pipelines/common/global-build-job.yml @@ -42,6 +42,12 @@ jobs: - name: _crossBuildPropertyArg value: /p:CrossBuild=${{ ne(parameters.crossrootfsDir, '') }} + - name: _cxx11Parameter + ${{ if and(eq(parameters.osGroup, 'Linux'), eq(parameters.archType, 'arm64')) }}: + value: /p:MonoLLVMUseCxx11Abi=true + ${{ if and(eq(parameters.osGroup, 'Linux'), not(eq(parameters.archType, 'arm64'))) }}: + value: /p:MonoLLVMUseCxx11Abi=false + - name: _officialBuildParameter ${{ if eq(parameters.isOfficialBuild, true) }}: value: /p:OfficialBuildId=$(Build.BuildNumber) @@ -66,7 +72,7 @@ jobs: displayName: Disk Usage before Build # Build - - script: $(Build.SourcesDirectory)$(dir)build$(scriptExt) -ci -arch ${{ parameters.archType }} $(_osParameter) ${{ parameters.buildArgs }} $(_officialBuildParameter) $(_crossBuildPropertyArg) + - script: $(Build.SourcesDirectory)$(dir)build$(scriptExt) -ci -arch ${{ parameters.archType }} $(_osParameter) ${{ parameters.buildArgs }} $(_officialBuildParameter) $(_crossBuildPropertyArg) $(_cxx11Parameter) displayName: Build product - ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}: diff --git a/eng/pipelines/runtime-official.yml b/eng/pipelines/runtime-official.yml index 0874ab6..3d335e1 100644 --- a/eng/pipelines/runtime-official.yml +++ b/eng/pipelines/runtime-official.yml @@ -108,7 +108,7 @@ stages: - OSX_x64 - Linux_x64 # - Linux_arm - # - Linux_arm64 + - Linux_arm64 # - Linux_musl_x64 # - Linux_musl_arm64 # - Windows_NT_x64 diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index d86dd42..32d7dc0 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -356,6 +356,7 @@ jobs: runtimeFlavor: mono platforms: - Linux_x64 + - Linux_arm64 jobParameters: testGroup: innerloop nameSuffix: AllSubsets_Mono_LLVMJIT @@ -378,6 +379,7 @@ jobs: runtimeFlavor: mono platforms: - Linux_x64 + - Linux_arm64 jobParameters: testGroup: innerloop nameSuffix: AllSubsets_Mono_LLVMAOT diff --git a/src/mono/llvm/build_llvm_config.sh b/src/mono/llvm/build_llvm_config.sh index 7880d84..293de69 100755 --- a/src/mono/llvm/build_llvm_config.sh +++ b/src/mono/llvm/build_llvm_config.sh @@ -39,6 +39,16 @@ if [[ $llvm_config = *".exe" ]]; then esac fi +local_osname="$(uname -s)" +if [ "x$local_osname" == "xLinux" ]; then + local_arch="$(file /bin/bash | cut -f2 -d',')" + llvm_config_arch="$(file $llvm_config | cut -f2 -d',')" + if [ "x$llvm_config_arch" != "x$local_arch" ]; then + use_llvm_config=0 + linux_cross_llvm=1 + fi +fi + if [[ $llvm_host_win32 = 1 ]]; then llvm_config=$(win32_format_path "$llvm_config") fi @@ -67,6 +77,51 @@ if [[ $use_llvm_config = 1 ]]; then fi fi +# If building for one architecture, but running on a different architecture, we cannot execute that arch's llvm-config +# e.g. building an ARM64 build from x64. +if [[ $linux_cross_llvm = 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 --mono-api-version + llvm_api_version=`awk '/MONO_API_VERSION/ { print $3 }' $llvm_config_path` + + # llvm-config --cflags, returned information currently not used. + llvm_config_cflags= + + # llvm-config --system-libs + llvm_system="-lz -lrt -ldl -lpthread -lm" + + # llvm-config --libs analysis core bitwriter + llvm_core_components="-lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMRemarks -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle" + + # llvm-config --libs mcjit + llvm_old_jit="-lLLVMMCJIT -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMProfileData -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMBitstreamReader -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCore -lLLVMRemarks -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle" + + # llvm-config --libs orcjit + llvm_new_jit="-lLLVMOrcJIT -lLLVMTransformUtils -lLLVMJITLink -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMProfileData -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMBitstreamReader -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCore -lLLVMRemarks -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle" + + # Check codegen libs and add needed libraries. + case "$llvm_codegen_libs" in + *x86codegen*) + # llvm-config --libs x86codegen + llvm_extra="-lLLVMX86CodeGen -lLLVMGlobalISel -lLLVMX86Desc -lLLVMX86Utils -lLLVMX86Info -lLLVMMCDisassembler -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMRemarks -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle" + ;; + *armcodegen*) + # llvm-config --libs armcodegen + llvm_extra="-lLLVMARMCodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMRemarks -lLLVMARMDesc -lLLVMMCDisassembler -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBinaryFormat -lLLVMARMUtils -lLLVMARMInfo -lLLVMSupport -lLLVMDemangle" + ;; + *aarch64codegen*) + # llvm-config --libs aarch64codegen + llvm_extra="-lLLVMAArch64CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMRemarks -lLLVMAArch64Desc -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBinaryFormat -lLLVMAArch64Utils -lLLVMAArch64Info -lLLVMSupport -lLLVMDemangle" + ;; + *) + llvm_extra=$llvm_codegen_libs + esac +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 diff --git a/src/mono/llvm/llvm-init.proj b/src/mono/llvm/llvm-init.proj index 52227cc..3286a3b 100644 --- a/src/mono/llvm/llvm-init.proj +++ b/src/mono/llvm/llvm-init.proj @@ -16,15 +16,21 @@ $(runtimeosx1012x64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion) + + + $(TargetArchitecture) + $(HostArch) + + - - + + - - + + diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 4fef8515..6a7027e 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -84,11 +84,16 @@ <_MonoCXXFLAGS Include="-g" /> - - + + <_MonoCXXFLAGS Include="-D_GLIBCXX_USE_CXX11_ABI=0" /> + + + <_MonoCXXFLAGS Include="-D_GLIBCXX_USE_CXX11_ABI=1" /> + + <_MonoConfigureParams Condition="'$(Platform)' == 'arm64'" Include="--host=aarch64-apple-darwin10" /> -- 2.7.4