Skip to content

Commit

Permalink
Support building a mono-based .NET Runtime on x64 (#68424)
Browse files Browse the repository at this point in the history
We now have some architectures (eg, s390x and ppc64le) that produce a .NET runtime that looks and feels like any other .NET runtime, except it's using Mono instead of CoreCLR under the hood.

However, it's only possible to produce this Mono-based .NET runtime on s390x/ppc64le. That makes it hard to test this set up on other architectures. Issues that affect the mono build on all architectures - such as #66594 become harder to fix and verify because of this unnecessary architecture requirement.

Fix that by adding a flag to the top-level build.sh (and also to the msbuild projects) to make it possible to produce a .NET runtime with Mono on any platform.

The default configuration is unchanged: we still produced CoreCLR-based .NET runtime on x64 and a Mono-based runtime on s390x/ppc64le.

Fixes: #62440
  • Loading branch information
omajid authored May 3, 2023
1 parent e15f073 commit fc22ee9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion eng/SourceBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<InnerBuildArgs>$(InnerBuildArgs) /p:AdditionalRuntimeIdentifierParent=$(BaseOS)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(OfficialBuildId)' != ''">$(InnerBuildArgs) /p:OfficialBuildId=$(OfficialBuildId)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(ContinuousIntegrationBuild)' != ''">$(InnerBuildArgs) /p:ContinuousIntegrationBuild=$(ContinuousIntegrationBuild)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(SourceBuildUseMonoRuntime)' == 'true'">$(InnerBuildArgs) /p:PrimaryRuntimeFlavor=Mono /p:RuntimeFlavor=Mono</InnerBuildArgs>
<InnerBuildArgs Condition="'$(SourceBuildUseMonoRuntime)' == 'true'">$(InnerBuildArgs) --usemonoruntime</InnerBuildArgs>
</PropertyGroup>
</Target>

Expand Down
8 changes: 6 additions & 2 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
platforms (like s390x) where only Mono is supported. The primary runtime
flavor is used to decide when to build the hosts and installers. -->
<PropertyGroup>
<PrimaryRuntimeFlavor>CoreCLR</PrimaryRuntimeFlavor>
<PrimaryRuntimeFlavor Condition="'$(TargetArchitecture)' == 's390x' or '$(TargetArchitecture)' == 'ppc64le' or '$(TargetArchitecture)' == 'armv6' or '$(TargetsLinuxBionic)' == 'true'">Mono</PrimaryRuntimeFlavor>
<DefaultPrimaryRuntimeFlavor>CoreCLR</DefaultPrimaryRuntimeFlavor>
<DefaultPrimaryRuntimeFlavor Condition="'$(TargetArchitecture)' == 'armv6'">Mono</DefaultPrimaryRuntimeFlavor>
<DefaultPrimaryRuntimeFlavor Condition="'$(TargetArchitecture)' == 'ppc64le'">Mono</DefaultPrimaryRuntimeFlavor>
<DefaultPrimaryRuntimeFlavor Condition="'$(TargetArchitecture)' == 's390x'">Mono</DefaultPrimaryRuntimeFlavor>
<DefaultPrimaryRuntimeFlavor Condition="'$(TargetsLinuxBionic)' == 'true'">Mono</DefaultPrimaryRuntimeFlavor>
<PrimaryRuntimeFlavor Condition="'$(PrimaryRuntimeFlavor)' == ''">$(DefaultPrimaryRuntimeFlavor)</PrimaryRuntimeFlavor>
</PropertyGroup>

<PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Param(
[ValidateSet("Debug","Release")][string][Alias('lc')]$librariesConfiguration,
[ValidateSet("CoreCLR","Mono")][string][Alias('rf')]$runtimeFlavor,
[ValidateSet("Debug","Release","Checked")][string][Alias('hc')]$hostConfiguration,
[switch]$usemonoruntime = $false,
[switch]$ninja,
[switch]$msbuild,
[string]$cmakeargs,
Expand Down Expand Up @@ -51,6 +52,7 @@ function Get-Help() {
Write-Host " -subset (-s) Build a subset, print available subsets with -subset help."
Write-Host " '-subset' can be omitted if the subset is given as the first argument."
Write-Host " [Default: Builds the entire repo.]"
Write-Host " -usemonoruntime Product a .NET runtime with Mono as the underlying runtime."
Write-Host " -verbosity (-v) MSBuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]."
Write-Host " [Default: Minimal]"
Write-Host " -vs Open the solution with Visual Studio using the locally acquired SDK."
Expand Down Expand Up @@ -251,6 +253,7 @@ foreach ($argument in $PSBoundParameters.Keys)
{
"runtimeConfiguration" { $arguments += " /p:RuntimeConfiguration=$((Get-Culture).TextInfo.ToTitleCase($($PSBoundParameters[$argument])))" }
"runtimeFlavor" { $arguments += " /p:RuntimeFlavor=$($PSBoundParameters[$argument].ToLowerInvariant())" }
"usemonoruntime" { $arguments += " /p:PrimaryRuntimeFlavor=Mono" }
"librariesConfiguration" { $arguments += " /p:LibrariesConfiguration=$((Get-Culture).TextInfo.ToTitleCase($($PSBoundParameters[$argument])))" }
"hostConfiguration" { $arguments += " /p:HostConfiguration=$((Get-Culture).TextInfo.ToTitleCase($($PSBoundParameters[$argument])))" }
"framework" { $arguments += " /p:BuildTargetFramework=$($PSBoundParameters[$argument].ToLowerInvariant())" }
Expand Down
6 changes: 6 additions & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ usage()
echo " --subset (-s) Build a subset, print available subsets with -subset help."
echo " '--subset' can be omitted if the subset is given as the first argument."
echo " [Default: Builds the entire repo.]"
echo " --usemonoruntime Product a .NET runtime with Mono as the underlying runtime."
echo " --verbosity (-v) MSBuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]."
echo " [Default: Minimal]"
echo ""
Expand Down Expand Up @@ -369,6 +370,11 @@ while [[ $# > 0 ]]; do
shift 2
;;

-usemonoruntime)
arguments="$arguments /p:PrimaryRuntimeFlavor=Mono"
shift 1
;;

-librariesconfiguration|-lc)
if [ -z ${2+x} ]; then
echo "No libraries configuration supplied. See help (--help) for supported libraries configurations." 1>&2
Expand Down

0 comments on commit fc22ee9

Please sign in to comment.