From fc22ee95596fdaa85ffa1cacbcbde91d3836a1f5 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Wed, 3 May 2023 09:05:49 -0400 Subject: [PATCH] Support building a mono-based .NET Runtime on x64 (#68424) 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 --- eng/SourceBuild.props | 2 +- eng/Subsets.props | 8 ++++++-- eng/build.ps1 | 3 +++ eng/build.sh | 6 ++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/eng/SourceBuild.props b/eng/SourceBuild.props index bbf4b6996cea33..5e12f4af83cc37 100644 --- a/eng/SourceBuild.props +++ b/eng/SourceBuild.props @@ -39,7 +39,7 @@ $(InnerBuildArgs) /p:AdditionalRuntimeIdentifierParent=$(BaseOS) $(InnerBuildArgs) /p:OfficialBuildId=$(OfficialBuildId) $(InnerBuildArgs) /p:ContinuousIntegrationBuild=$(ContinuousIntegrationBuild) - $(InnerBuildArgs) /p:PrimaryRuntimeFlavor=Mono /p:RuntimeFlavor=Mono + $(InnerBuildArgs) --usemonoruntime diff --git a/eng/Subsets.props b/eng/Subsets.props index ef9935e2407dc9..f1af6a47bfddcd 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -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. --> - CoreCLR - Mono + CoreCLR + Mono + Mono + Mono + Mono + $(DefaultPrimaryRuntimeFlavor) diff --git a/eng/build.ps1 b/eng/build.ps1 index 99f0864317f39a..fc2712fcafe512 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -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, @@ -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." @@ -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())" } diff --git a/eng/build.sh b/eng/build.sh index 14855d30b0f1c6..469fd9d06714b2 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -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 "" @@ -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