Skip to content

Commit 5e6de70

Browse files
authored
CoreCLR runtime tests + Mono LLVM AOT on arm64 Linux (#41751)
This change: - Adds new options to mono.proj: - MonoAOTEnableLLVM, which enables (or disables) building a Mono AOT cross compiler with LLVM; - MonoAOTLLVMDir, which specifies the path to a copy of LLVM suitable for building a Mono AOT cross compiler, and is optional; and - BuildMonoAOTCrossCompilerOnly, which allows building a Mono AOT cross compiler without building an associated full Mono runtime. - Changes offsets-tool.py's user interface slightly; '--include-prefix' is renamed to '--prefix' and may be specified multiple times. While this latter feature isn't necessary to build a Mono cross compiler today, because we don't use distribution-supplied cross-compilation headers on CI, it does make it easier to experiment with the offsets tool using arbitrary header layouts. For example, Debian's arm64 cross-compilation packages scatter useful header files across `/usr/lib/gcc-cross/aarch64-linux-gnu` and `/usr/aarch64-linux-gnu`. - Updates the docker image used for arm64 cross-compilation to a newer revision that includes libclang (see also dotnet/dotnet-buildtools-prereqs-docker#375). - Adds some tests that currently fail to compile with Mono LLVM AOT to issues.targets. - Adds a Linux_arm64 LLVM AOT job to CI. Nothing particularly fancy is done to build the Mono LLVM AOT cross compiler; it is built as a step in the same job that also sends Linux_arm64 tests to Helix.
1 parent c436158 commit 5e6de70

File tree

15 files changed

+151
-43
lines changed

15 files changed

+151
-43
lines changed

docs/workflow/building/coreclr/linux-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This table of images might often become stale as we change our images as our req
5353
| Alpine | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.9-WithNode-0fc54a3-20190918214015` | - | -clang9 |
5454
| CentOS 7 (build for RHEL 7) | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:centos-7-359e48e-20200313130914` | - | -clang9 |
5555
| Ubuntu 16.04 | arm32 (armhf) | `mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-20200413125008-09ec757` | `/crossrootfs/arm` | -clang9 |
56-
| Ubuntu 16.04 | arm64 (arm64v8) | `mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-20200413125008-cfdd435` | `/crossrootfs/arm64` | -clang9 |
56+
| Ubuntu 16.04 | arm64 (arm64v8) | `mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-20201022204150-b2c2436` | `/crossrootfs/arm64` | -clang9 |
5757
| Alpine | arm64 (arm64v8) | `mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-alpine-20200413125008-406629a` | `/crossrootfs/arm64` | -clang5.0 |
5858

5959
Environment

eng/Subsets.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<DefaultCoreClrSubsets>clr.runtime+clr.jit+clr.alljits+linuxdac+clr.corelib+clr.nativecorelib+clr.tools+clr.packages</DefaultCoreClrSubsets>
5858

5959
<DefaultMonoSubsets Condition="'$(MonoEnableLLVM)' == 'true' and '$(MonoLLVMDir)' == ''">mono.llvm+</DefaultMonoSubsets>
60+
<DefaultMonoSubsets Condition="'$(MonoAOTEnableLLVM)' == 'true' and '$(MonoAOTLLVMDir)' == ''">mono.llvm+</DefaultMonoSubsets>
6061
<DefaultMonoSubsets Condition="'$(TargetOS)' == 'Browser'">$(DefaultMonoSubsets)mono.wasmruntime+</DefaultMonoSubsets>
6162
<DefaultMonoSubsets>$(DefaultMonoSubsets)mono.runtime+mono.corelib+mono.packages</DefaultMonoSubsets>
6263

eng/pipelines/common/platform-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
targetRid: linux-arm64
6565
platform: Linux_arm64
6666
container:
67-
image: ubuntu-16.04-cross-arm64-20200413125008-cfdd435
67+
image: ubuntu-16.04-cross-arm64-20201022204150-b2c2436
6868
registry: mcr
6969
jobParameters:
7070
runtimeFlavor: ${{ parameters.runtimeFlavor }}

eng/pipelines/common/templates/runtimes/run-test-job.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ jobs:
223223
artifactName: '$(coreClrProductArtifactName)'
224224
displayName: 'CoreCLR product download for Mono'
225225

226-
227226
# Download and unzip the Microsoft.NET.Sdk.IL package needed for traversing
228227
# ilproj test projects during copynativeonly.
229228
- template: /eng/pipelines/common/download-artifact-step.yml
@@ -263,6 +262,20 @@ jobs:
263262
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) generatelayoutonly $(runtimeFlavorArgs) $(crossgenArg) $(buildConfig) $(archType) $(crossArg) $(priorityArg) $(librariesOverrideArg)
264263
displayName: Generate CORE_ROOT
265264

265+
# Build a Mono LLVM AOT cross-compiler for non-amd64 targets (in this case, just arm64)
266+
- ${{ if and(eq(parameters.runtimeFlavor, 'mono'), eq(parameters.runtimeVariant, 'llvmaot')) }}:
267+
- ${{ if eq(parameters.archType, 'arm64') }}:
268+
- script: ./build.sh
269+
-subset mono
270+
-c $(buildConfigUpper)
271+
-arch $(archType)
272+
/p:BuildMonoAotCrossCompiler=true
273+
/p:BuildMonoAotCrossCompilerOnly=true
274+
/p:MonoLibClang="/usr/lib/llvm-9/lib/libclang-9.so.1"
275+
/p:MonoAOTEnableLLVM=true
276+
/p:MonoAOTLLVMUseCxx11Abi=true
277+
displayName: "Build Mono LLVM AOT cross compiler"
278+
266279

267280
# Overwrite coreclr runtime binaries with mono ones
268281
- ${{ if eq(parameters.runtimeFlavor, 'mono') }}:
@@ -274,8 +287,14 @@ jobs:
274287
displayName: "Patch dotnet with mono"
275288

276289
- ${{ if and(eq(parameters.runtimeFlavor, 'mono'), eq(parameters.runtimeVariant, 'llvmaot')) }}:
277-
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) mono_aot $(buildConfig)
278-
displayName: "LLVM AOT compile CoreCLR tests"
290+
- ${{ if eq(parameters.archType, 'x64') }}:
291+
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) mono_aot $(buildConfig) $(archType)
292+
displayName: "LLVM AOT compile CoreCLR tests"
293+
- ${{ if eq(parameters.archType, 'arm64') }}:
294+
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) mono_aot $(buildConfig) $(archType) cross
295+
displayName: "LLVM AOT cross-compile CoreCLR tests"
296+
env:
297+
__MonoToolPrefix: aarch64-linux-gnu-
279298

280299
# Send tests to Helix
281300
- template: /eng/pipelines/common/templates/runtimes/send-to-helix-step.yml

eng/pipelines/mono/templates/build-job.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,15 @@ jobs:
7474
value: wasm
7575
- name: osOverride
7676
value: '-os Browser'
77+
- ${{ if and(eq(parameters.osGroup, 'Linux'), not(eq(parameters.archType, 'x64'))) }}:
78+
name: llvmCxxAbi
79+
value: /p:MonoLLVMUseCxx11Abi=true
7780
- ${{ if eq(parameters.runtimeVariant, 'llvmjit') }}:
7881
- name: llvmParameter
79-
value: /p:MonoEnableLLVM=true /p:MonoBundleLLVMOptimizer=false
82+
value: /p:MonoEnableLLVM=true /p:MonoBundleLLVMOptimizer=false $(llvmCxxAbi)
8083
- ${{ if eq(parameters.runtimeVariant, 'llvmaot') }}:
8184
- name: llvmParameter
82-
value: /p:MonoEnableLLVM=true /p:MonoBundleLLVMOptimizer=true
85+
value: /p:MonoEnableLLVM=true /p:MonoBundleLLVMOptimizer=true $(llvmCxxAbi)
8386
- ${{ parameters.variables }}
8487

8588
steps:
@@ -96,7 +99,7 @@ jobs:
9699
- script: $(Build.SourcesDirectory)\eng\common\init-tools-native.cmd -InstallDirectory $(Build.SourcesDirectory)\native-tools -Force
97100
displayName: Install native dependencies
98101

99-
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
102+
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
100103
- script: |
101104
du -sh $(Build.SourcesDirectory)/*
102105
df -h
@@ -110,7 +113,7 @@ jobs:
110113
- script: build$(scriptExt) -subset mono -c $(buildConfig) -arch $(archType) $(osOverride) -ci $(officialBuildIdArg) $(llvmParameter)
111114
displayName: Build product
112115

113-
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
116+
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
114117
- script: |
115118
du -sh $(Build.SourcesDirectory)/*
116119
df -h

eng/pipelines/runtime.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ jobs:
585585
buildConfig: release
586586
platforms:
587587
- Linux_x64
588+
- Linux_arm64
588589
jobParameters:
589590
runtimeVariant: llvmaot
590591
condition: >-
@@ -853,6 +854,7 @@ jobs:
853854
runtimeFlavor: mono
854855
platforms:
855856
- Linux_x64
857+
- Linux_arm64
856858
helixQueueGroup: pr
857859
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
858860
jobParameters:

src/mono/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ if(NOT AOT_TARGET_TRIPLE STREQUAL "")
148148
elseif(AOT_TARGET_TRIPLE STREQUAL "wasm32-unknown-none")
149149
set(TARGET_SYSTEM_NAME "Emscripten")
150150
set(TARGET_ARCH "wasm")
151+
elseif(AOT_TARGET_TRIPLE STREQUAL "aarch64-linux-gnu")
152+
set(TARGET_SYSTEM_NAME "Linux")
153+
set(TARGET_ARCH "arm64")
151154
else()
152155
message(FATAL_ERROR "AOT target '${AOT_TARGET_TRIPLE}' not supported.")
153156
endif()

src/mono/Directory.Build.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<SkipImportArcadeSdkFromRoot>true</SkipImportArcadeSdkFromRoot>
44
</PropertyGroup>
55
<Import Project="..\..\Directory.Build.props" />
6-
6+
77
<!-- Set default Platform -->
88
<PropertyGroup>
99
<HostArch>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant)</HostArch>
@@ -101,7 +101,8 @@
101101

102102
<PropertyGroup>
103103
<MonoObjDir>$(ArtifactsObjDir)mono/$(PlatformConfigPathPart)/</MonoObjDir>
104-
<MonoLLVMDir Condition="('$(MonoEnableLLVM)' == 'true' or '$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'Browser') and '$(MonoLLVMDir)' == ''">$(MonoObjDir)llvm</MonoLLVMDir>
104+
<MonoLLVMDir Condition="'$(MonoLLVMDir)' == ''">$(MonoObjDir)llvm</MonoLLVMDir>
105+
<MonoAOTLLVMDir Condition="'$(MonoAOTLLVMDir)' == ''">$(MonoObjDir)cross/llvm</MonoAOTLLVMDir>
105106
</PropertyGroup>
106107

107108
<!-- Paths for Mobile App Projects -->

src/mono/llvm/llvm-init.proj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,28 @@
2525
<ItemGroup>
2626
<PackageReference Include="runtime.$(MonoLLVMHostOS)-$(MonoLLVMTargetArchitecture).Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="$(MonoLLVMSDKVersion)"/>
2727
<PackageReference Include="runtime.$(MonoLLVMHostOS)-$(MonoLLVMTargetArchitecture).Microsoft.NETCore.Runtime.Mono.LLVM.Tools" Version="$(MonoLLVMToolsVersion)"/>
28+
29+
<PackageReference Include="runtime.$(MonoLLVMHostOS)-$(HostArch).Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="$(MonoLLVMSDKVersion)"/>
30+
<PackageReference Include="runtime.$(MonoLLVMHostOS)-$(HostArch).Microsoft.NETCore.Runtime.Mono.LLVM.Tools" Version="$(MonoLLVMToolsVersion)"/>
2831
</ItemGroup>
2932

3033
<Target Name="CopyLLVMToTree" AfterTargets="Build">
3134
<ItemGroup>
3235
<LLVMFiles Include="$(NuGetPackageRoot)\runtime.$(MonoLLVMHostOS)-$(MonoLLVMTargetArchitecture).microsoft.netcore.runtime.mono.llvm.sdk\$(MonoLLVMSDKVersion)\tools\$(MonoLLVMHostOS)-$(MonoLLVMTargetArchitecture)\**" />
3336
<LLVMFiles Include="$(NuGetPackageRoot)\runtime.$(MonoLLVMHostOS)-$(MonoLLVMTargetArchitecture).microsoft.netcore.runtime.mono.llvm.tools\$(MonoLLVMSDKVersion)\tools\$(MonoLLVMHostOS)-$(MonoLLVMTargetArchitecture)\**" />
3437
</ItemGroup>
38+
<ItemGroup>
39+
<AOTLLVMFiles Include="$(NuGetPackageRoot)\runtime.$(MonoLLVMHostOS)-$(HostArch).microsoft.netcore.runtime.mono.llvm.sdk\$(MonoLLVMSDKVersion)\tools\$(MonoLLVMHostOS)-$(HostArch)\**" />
40+
<AOTLLVMFiles Include="$(NuGetPackageRoot)\runtime.$(MonoLLVMHostOS)-$(HostArch).microsoft.netcore.runtime.mono.llvm.tools\$(MonoLLVMSDKVersion)\tools\$(MonoLLVMHostOS)-$(HostArch)\**" />
41+
</ItemGroup>
3542

3643
<Copy SourceFiles="@(LLVMFiles)" DestinationFolder="$(MonoLLVMDir)\%(RecursiveDir)">
3744
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
3845
</Copy>
46+
47+
<Copy SourceFiles="@(AOTLLVMFiles)" DestinationFolder="$(MonoAOTLLVMDir)\%(RecursiveDir)">
48+
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
49+
</Copy>
3950
</Target>
4051

4152
</Project>

0 commit comments

Comments
 (0)