Skip to content

Commit

Permalink
[mono] Fix output directory for cross compilers if OutputRID is overr…
Browse files Browse the repository at this point in the history
…idden (#109932)

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 preexisting MonoAotCrossDir property.

Also fix marking DotNetBuildMonoCrossAOT=true as a ShortStack build.
  • Loading branch information
akoeplinger authored Nov 19, 2024
1 parent 6218e39 commit 6accd39
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions eng/DotNetBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<ShortStack Condition="'$(TargetOS)' == 'maccatalyst'">true</ShortStack>
<ShortStack Condition="'$(TargetOS)' == 'android'">true</ShortStack>
<ShortStack Condition="'$(TargetOS)' == 'linux-bionic'">true</ShortStack>
<ShortStack Condition="'$(DotNetBuildMonoCrossAOT)' == 'true'">true</ShortStack>
</PropertyGroup>

<Target Name="GetRuntimeSourceBuildCommandConfiguration"
Expand Down
16 changes: 8 additions & 8 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -1094,16 +1094,16 @@ JS_ENGINES = [NODE_JS]
<Destination>$(RuntimeBinDir)$(MonoStaticLibFileName)</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Include="$(_MonoAotCrossFilePath)" Condition="Exists($(_MonoAotCrossFilePath))">
<Destination>$(RuntimeBinDir)cross\$(OutputRID)\$(MonoAotCrossName)$(ExeSuffix)</Destination>
<Destination>$(MonoAotCrossDir)$(MonoAotCrossName)$(ExeSuffix)</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Include="$(_MonoAotCrossFilePath).dbg" Condition="Exists('$(_MonoAotCrossFilePath).dbg')">
<Destination>$(RuntimeBinDir)cross\$(OutputRID)\$(MonoAotCrossName).dbg</Destination>
<Destination>$(MonoAotCrossDir)$(MonoAotCrossName).dbg</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Include="$(_MonoAotCrossFilePath).dwarf" Condition="Exists('$(_MonoAotCrossFilePath).dwarf')">
<Destination>$(RuntimeBinDir)cross\$(OutputRID)\$(MonoAotCrossName).dwarf</Destination>
<Destination>$(MonoAotCrossDir)$(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>$(MonoAotCrossDir)$(MonoAotCrossName).pdb</Destination>
</_MonoRuntimeArtifacts>
<!-- copy the mono runtime component shared or static libraries -->
<_MonoRuntimeArtifacts Include="@(_MonoRuntimeComponentsStaticFilePath)">
Expand All @@ -1119,10 +1119,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>$(MonoAotCrossDir)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>$(MonoAotCrossDir)libc++abi.so.1</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="'$(MonoBundleLLVMOptimizer)' == 'true'" Include="$(MonoLLVMDir)\$(_MonoLLVMHostArchitecture)\bin\llc$(ExeSuffix)">
<Destination>$(RuntimeBinDir)\llc$(ExeSuffix)</Destination>
Expand All @@ -1131,10 +1131,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>$(MonoAotCrossDir)llc$(ExeSuffix)</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="'$(MonoAOTBundleLLVMOptimizer)' == 'true'" Include="$(MonoLLVMDir)\$(_MonoLLVMHostArchitecture)\bin\opt$(ExeSuffix)">
<Destination>$(RuntimeBinDir)cross\$(OutputRID)\opt$(ExeSuffix)</Destination>
<Destination>$(MonoAotCrossDir)opt$(ExeSuffix)</Destination>
</_MonoRuntimeArtifacts>
<_MonoIncludeArtifacts Include="$(MonoObjDir)out\include\**" />
<_MonoRuntimeArtifacts Condition="'$(MonoComponentsStatic)' != 'true' and Exists('$(MonoObjDir)out\lib\Mono.release.framework')" Include="@(_MonoRuntimeComponentsSharedFilePath)">
Expand Down
7 changes: 5 additions & 2 deletions src/mono/monoaotcross.proj
Original file line number Diff line number Diff line change
Expand Up @@ -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())\**" />
</ItemGroup>

<Error Condition="'@(_MonoAOTCrossFiles)' == '' and '$(MonoGenerateOffsetsOSGroups)' == ''" 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())">
Expand Down

0 comments on commit 6accd39

Please sign in to comment.