Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VMR] Enable building Mono Cross AOT verticals #44924

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions eng/pipelines/templates/stages/vmr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,64 @@ stages:
targetArchitecture: arm64
targetRid: ${{ variables.linuxMuslArm64Rid }}

- template: ../jobs/vmr-build.yml
parameters:
buildName: AzureLinux_x64_Cross_ShortStack_Alpine_Mono_CrossAOT
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
pool: ${{ parameters.pool_Linux }}
container: ${{ variables.azurelinuxX64AlpineCrossContainer }}
crossRootFs: '/crossrootfs/x64'
targetOS: linux-musl
targetArchitecture: x64
targetRid: ${{ variables.linuxMuslX64Rid }}
extraProperties: /p:DotNetBuildMonoCrossAOT=true
runTests: false

- template: ../jobs/vmr-build.yml
parameters:
buildName: AzureLinux_x64_Cross_ShortStack_Alpine_Mono_CrossAOT
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: arm64
pool: ${{ parameters.pool_Linux }}
container: ${{ variables.azurelinuxArm64AlpineCrossContainer }}
crossRootFs: '/crossrootfs/arm64'
targetOS: linux-musl
targetArchitecture: arm64
targetRid: ${{ variables.linuxMuslX64Rid }}
extraProperties: /p:DotNetBuildMonoCrossAOT=true
runTests: false

- template: ../jobs/vmr-build.yml
parameters:
buildName: AzureLinux_x64_Cross_ShortStack_Mono_CrossAOT
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
pool: ${{ parameters.pool_Linux_Shortstack }}
container: ${{ variables.azurelinuxX64CrossContainer }}
crossRootFs: '/crossrootfs/x64'
targetOS: linux
targetArchitecture: x64
extraProperties: /p:DotNetBuildMonoCrossAOT=true
runTests: false

- template: ../jobs/vmr-build.yml
parameters:
buildName: AzureLinux_x64_Cross_ShortStack_Mono_CrossAOT
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: arm64
pool: ${{ parameters.pool_Linux_Shortstack }}
container: ${{ variables.azurelinuxArm64CrossContainer }}
crossRootFs: '/crossrootfs/arm64'
targetOS: linux
targetArchitecture: arm64
extraProperties: /p:DotNetBuildMonoCrossAOT=true
runTests: false

- template: ../jobs/vmr-build.yml
parameters:
buildName: AzureLinux_x64_Cross_ShortStack_Mono_LLVMAOT
Expand Down Expand Up @@ -993,6 +1051,30 @@ stages:
targetOS: osx
targetArchitecture: arm64

- template: ../jobs/vmr-build.yml
parameters:
buildName: OSX_ShortStack_Mono_CrossAOT
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
pool: ${{ parameters.pool_Mac }}
targetOS: osx
targetArchitecture: x64
extraProperties: /p:DotNetBuildMonoCrossAOT=true
runTests: false

- template: ../jobs/vmr-build.yml
parameters:
buildName: OSX_ShortStack_Mono_CrossAOT
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: arm64
pool: ${{ parameters.pool_Mac }}
targetOS: osx
targetArchitecture: arm64
extraProperties: /p:DotNetBuildMonoCrossAOT=true
runTests: false

- template: ../jobs/vmr-build.yml
parameters:
buildName: OSX_ShortStack_Mono_LLVMJIT
Expand Down Expand Up @@ -1051,6 +1133,30 @@ stages:
targetOS: windows
targetArchitecture: x64

- template: ../jobs/vmr-build.yml
parameters:
buildName: Windows_ShortStack_Mono_CrossAOT
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
pool: ${{ parameters.pool_Windows }}
targetOS: windows
targetArchitecture: x64
extraProperties: /p:DotNetBuildMonoCrossAOT=true
runTests: false

- template: ../jobs/vmr-build.yml
parameters:
buildName: Windows_ShortStack_Mono_CrossAOT
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: arm64
pool: ${{ parameters.pool_Windows }}
targetOS: windows
targetArchitecture: arm64
extraProperties: /p:DotNetBuildMonoCrossAOT=true
runTests: false

- template: ../jobs/vmr-build.yml
parameters:
buildName: Windows
Expand Down
4 changes: 3 additions & 1 deletion src/SourceBuild/content/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<HostOS Condition="'$(HostOS)' == ''">$(TargetOS)</HostOS>
</PropertyGroup>

<!-- This is a list of cases where we aren't producing a whole SDK, just a runtime. This list should be kept in sync with https://github.com/dotnet/runtime/blob/main/eng/SourceBuild.props#L26 -->
<!-- This is a list of cases where we aren't producing a whole SDK, just a runtime. This list should be kept in sync with https://github.com/dotnet/runtime/blob/main/eng/DotNetBuild.props#L26 -->
<PropertyGroup Label="ShortStacks">
<ShortStack Condition="'$(TargetOS)' == 'wasi'">true</ShortStack>
<ShortStack Condition="'$(TargetOS)' == 'browser'">true</ShortStack>
Expand All @@ -34,6 +34,8 @@
<ShortStack Condition="'$(TargetOS)' == 'osx' and '$(DotNetBuildRuntimeNativeAOTRuntimePack)' == 'true'">true</ShortStack>
<!-- Mono LLVM builds are short -->
<ShortStack Condition="'$(MonoEnableLLVM)' == 'true' or '$(MonoAOTEnableLLVM)' == 'true'">true</ShortStack>
<!-- Mono AOT cross compiler builds are short -->
<ShortStack Condition="'$(DotNetBuildMonoCrossAOT)' == 'true'">true</ShortStack>
<!-- Short stack builds stop at runtime, not the whole SDK -->
<RootRepo Condition="'$(ShortStack)' == 'true'">runtime</RootRepo>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/SourceBuild/content/repo-projects/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<BuildArgs Condition="'$(DotNetBuildMonoEnableLLVM)' != ''">$(BuildArgs) /p:DotNetBuildMonoEnableLLVM=$(DotNetBuildMonoEnableLLVM)</BuildArgs>
<BuildArgs Condition="'$(DotNetBuildMonoAOTEnableLLVM)' != ''">$(BuildArgs) /p:DotNetBuildMonoAOTEnableLLVM=$(DotNetBuildMonoAOTEnableLLVM)</BuildArgs>
<BuildArgs Condition="'$(DotNetBuildMonoBundleLLVMOptimizer)' != ''">$(BuildArgs) /p:DotNetBuildMonoBundleLLVMOptimizer=$(DotNetBuildMonoBundleLLVMOptimizer)</BuildArgs>
<BuildArgs Condition="'$(DotNetBuildMonoCrossAOT)' != ''">$(BuildArgs) /p:DotNetBuildMonoCrossAOT=$(DotNetBuildMonoCrossAOT)</BuildArgs>
<BuildArgs Condition="'$(PgoInstrument)' == 'true'">$(BuildArgs) $(FlagParameterPrefix)pgoinstrument</BuildArgs>
<BuildArgs Condition="'$(UseSystemLibs)' != ''">$(BuildArgs) /p:UseSystemLibs=$(UseSystemLibs)</BuildArgs>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= <[email protected]>
Date: Mon, 18 Nov 2024 18:50:05 +0100
Subject: [PATCH] [mono] Fix output directory for cross compilers if OutputRID
is overridden

This happens e.g. in the VMR where OutputRID is set globally. We assumed in monoaotcross.proj that the inner mono cross compiler runtime build would put files into a path that matches the target RID but we were using OutputRID in the inner build.

Instead use the AotHostOS and AotHostArchitecture properties which are more correct.
---
src/mono/mono.proj | 17 +++++++++--------
src/mono/monoaotcross.proj | 9 ++++++---
2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/mono/mono.proj b/src/mono/mono.proj
index 56eb36acbc7..5bb54cf7415 100644
--- a/src/mono/mono.proj
+++ b/src/mono/mono.proj
@@ -1067,6 +1067,7 @@ JS_ENGINES = [NODE_JS]
</PropertyGroup>
<PropertyGroup Condition="'$(BuildMonoAOTCrossCompiler)' == 'true'">
<_MonoAotCrossFilePath>$(MonoObjCrossDir)out\bin\$(MonoAotCrossName)$(ExeSuffix)</_MonoAotCrossFilePath>
+ <_MonoAotCrossBinPath>$(RuntimeBinDir)cross\$(AotHostOS).$(AotHostArchitecture)\</_MonoAotCrossBinPath>
</PropertyGroup>
<PropertyGroup>
<_MonoLLVMHostArchitecture>$(AotHostArchitecture)</_MonoLLVMHostArchitecture>
@@ -1094,16 +1095,16 @@ JS_ENGINES = [NODE_JS]
<Destination>$(RuntimeBinDir)$(MonoStaticLibFileName)</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Include="$(_MonoAotCrossFilePath)" Condition="Exists($(_MonoAotCrossFilePath))">
- <Destination>$(RuntimeBinDir)cross\$(OutputRID)\$(MonoAotCrossName)$(ExeSuffix)</Destination>
+ <Destination>$(_MonoAotCrossBinPath)$(MonoAotCrossName)$(ExeSuffix)</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Include="$(_MonoAotCrossFilePath).dbg" Condition="Exists('$(_MonoAotCrossFilePath).dbg')">
- <Destination>$(RuntimeBinDir)cross\$(OutputRID)\$(MonoAotCrossName).dbg</Destination>
+ <Destination>$(_MonoAotCrossBinPath)$(MonoAotCrossName).dbg</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Include="$(_MonoAotCrossFilePath).dwarf" Condition="Exists('$(_MonoAotCrossFilePath).dwarf')">
- <Destination>$(RuntimeBinDir)cross\$(OutputRID)\$(MonoAotCrossName).dwarf</Destination>
+ <Destination>$(_MonoAotCrossBinPath)$(MonoAotCrossName).dwarf</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Include="$(MonoObjCrossDir)out\bin\PDB\$(MonoAotCrossName).pdb" Condition="Exists('$(MonoObjCrossDir)out\bin\PDB\$(MonoAotCrossName).pdb')">
- <Destination>$(RuntimeBinDir)cross\$(OutputRID)\$(MonoAotCrossName).pdb</Destination>
+ <Destination>$(_MonoAotCrossBinPath)$(MonoAotCrossName).pdb</Destination>
</_MonoRuntimeArtifacts>
<!-- copy the mono runtime component shared or static libraries -->
<_MonoRuntimeArtifacts Include="@(_MonoRuntimeComponentsStaticFilePath)">
@@ -1119,10 +1120,10 @@ JS_ENGINES = [NODE_JS]
<Destination>$(RuntimeBinDir)libc++abi.so.1</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="'$(HostOS)' == 'Linux' and ((('$(MonoAOTBundleLLVMOptimizer)' == 'true' or '$(MonoAOTEnableLLVM)' == 'true') and '$(MonoUseLibCxx)' == 'true') or '$(TargetArchitecture)' == 'wasm')" Include="$(MonoLLVMDir)\$(_MonoLLVMHostArchitecture)\lib\libc++.so.1">
- <Destination>$(RuntimeBinDir)cross\$(OutputRID)\libc++.so.1</Destination>
+ <Destination>$(_MonoAotCrossBinPath)libc++.so.1</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="'$(HostOS)' == 'Linux' and ((('$(MonoAOTBundleLLVMOptimizer)' == 'true' or '$(MonoAOTEnableLLVM)' == 'true') and '$(MonoUseLibCxx)' == 'true') or '$(TargetArchitecture)' == 'wasm')" Include="$(MonoLLVMDir)\$(_MonoLLVMHostArchitecture)\lib\libc++abi.so.1">
- <Destination>$(RuntimeBinDir)cross\$(OutputRID)\libc++abi.so.1</Destination>
+ <Destination>$(_MonoAotCrossBinPath)libc++abi.so.1</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="'$(MonoBundleLLVMOptimizer)' == 'true'" Include="$(MonoLLVMDir)\$(_MonoLLVMHostArchitecture)\bin\llc$(ExeSuffix)">
<Destination>$(RuntimeBinDir)\llc$(ExeSuffix)</Destination>
@@ -1131,10 +1132,10 @@ JS_ENGINES = [NODE_JS]
<Destination>$(RuntimeBinDir)\opt$(ExeSuffix)</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="'$(MonoAOTBundleLLVMOptimizer)' == 'true'" Include="$(MonoLLVMDir)\$(_MonoLLVMHostArchitecture)\bin\llc$(ExeSuffix)">
- <Destination>$(RuntimeBinDir)cross\$(OutputRID)\llc$(ExeSuffix)</Destination>
+ <Destination>$(_MonoAotCrossBinPath)llc$(ExeSuffix)</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="'$(MonoAOTBundleLLVMOptimizer)' == 'true'" Include="$(MonoLLVMDir)\$(_MonoLLVMHostArchitecture)\bin\opt$(ExeSuffix)">
- <Destination>$(RuntimeBinDir)cross\$(OutputRID)\opt$(ExeSuffix)</Destination>
+ <Destination>$(_MonoAotCrossBinPath)opt$(ExeSuffix)</Destination>
</_MonoRuntimeArtifacts>
<_MonoIncludeArtifacts Include="$(MonoObjDir)out\include\**" />
<_MonoRuntimeArtifacts Condition="'$(MonoComponentsStatic)' != 'true' and Exists('$(MonoObjDir)out\lib\Mono.release.framework')" Include="@(_MonoRuntimeComponentsSharedFilePath)">
diff --git a/src/mono/monoaotcross.proj b/src/mono/monoaotcross.proj
index c747e87f763..51595d4867a 100644
--- a/src/mono/monoaotcross.proj
+++ b/src/mono/monoaotcross.proj
@@ -43,20 +43,23 @@
<MonoAotTargetArchitecture>$(MonoAotTargetRid.Substring($([MSBuild]::Add(1, $(MonoAotTargetRid.LastIndexOf('-'))))))</MonoAotTargetArchitecture>
<MonoAotHostOS>$(TargetOS)</MonoAotHostOS>
<MonoAotHostOS Condition="'$(TargetsLinuxMusl)' == 'true'">linux-musl</MonoAotHostOS>
+ <MonoAotHostArchitecture>$(TargetArchitecture)</MonoAotHostArchitecture>
</PropertyGroup>

<MSBuild Targets="Build"
Projects="$(MSBuildThisFileDirectory)llvm\llvm-init.proj"
- Properties="TargetArchitecture=$(MonoAotTargetArchitecture);TargetOS=$(MonoAotTargetOS);AotHostArchitecture=$(TargetArchitecture)" />
+ Properties="TargetArchitecture=$(MonoAotTargetArchitecture);TargetOS=$(MonoAotTargetOS);AotHostOS=$(MonoAotHostOS);AotHostArchitecture=$(MonoAotHostArchitecture)" />

<MSBuild Targets="BuildMono"
Projects="$(MSBuildThisFileDirectory)mono.proj"
- Properties="AotHostOS=$(MonoAotHostOS);AotHostArchitecture=$(TargetArchitecture);BuildMonoAOTCrossCompilerOnly=true;TargetArchitecture=$(MonoAotTargetArchitecture);TargetOS=$(MonoAotTargetOS)" />
+ Properties="AotHostOS=$(MonoAotHostOS);AotHostArchitecture=$(MonoAotHostArchitecture);BuildMonoAOTCrossCompilerOnly=true;TargetArchitecture=$(MonoAotTargetArchitecture);TargetOS=$(MonoAotTargetOS)" />

<ItemGroup>
- <_MonoAOTCrossFiles Include="$(ArtifactsBinDir)mono\$(MonoAotTargetOS).$(MonoAotTargetArchitecture).$(Configuration)\cross\$(MonoAotTargetRid.ToLower())\**" />
+ <_MonoAOTCrossFiles Include="$(ArtifactsBinDir)mono\$(MonoAotTargetOS).$(MonoAotTargetArchitecture).$(Configuration)\cross\$(MonoAotHostOS).$(MonoAotHostArchitecture)\**" />
</ItemGroup>

+ <Error Condition="'@(_MonoAOTCrossFiles)' == ''" Text="No AOT cross files found for $(MonoAotTargetRid)" />
+
<Message Text="Copying @(_MonoAOTCrossFiles) to $(RealRuntimeBinDir)cross\$(TargetOS)-$(TargetArchitecture.ToLower())\$(MonoAotTargetRid.ToLower())" Importance="High" />

<Copy SourceFiles="@(_MonoAOTCrossFiles)" DestinationFolder="$(RealRuntimeBinDir)cross\$(TargetOS)-$(TargetArchitecture.ToLower())\$(MonoAotTargetRid.ToLower())">
Loading