diff --git a/Directory.Build.targets b/Directory.Build.targets index a1589f9f5d566..f16e04d9b4e27 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -8,7 +8,8 @@ false - + + diff --git a/docs/workflow/building/coreclr/linux-instructions.md b/docs/workflow/building/coreclr/linux-instructions.md index a1c847d4d90df..bbc0a78f69c1b 100644 --- a/docs/workflow/building/coreclr/linux-instructions.md +++ b/docs/workflow/building/coreclr/linux-instructions.md @@ -124,10 +124,10 @@ To ensure that your system can allocate enough file-handles for the libraries bu Build the Runtime and System.Private.CoreLib ============================================= -To build the runtime on Linux, run build.sh from the root of the runtime repository: +To build the runtime on Linux, run build.sh to build the CoreCLR subset category of the runtime: ``` -./src/coreclr/build.sh +./build.sh -subsetCategory coreclr ``` After the build is completed, there should some files placed in `runtime/artifacts/bin/coreclr/Linux.x64.Debug`. The ones we are most interested in are: diff --git a/docs/workflow/building/coreclr/osx-instructions.md b/docs/workflow/building/coreclr/osx-instructions.md index a540e004894fd..9be2f9c90b389 100644 --- a/docs/workflow/building/coreclr/osx-instructions.md +++ b/docs/workflow/building/coreclr/osx-instructions.md @@ -40,13 +40,13 @@ brew install icu4c brew link --force icu4c ``` -Build the Runtime and Microsoft Core Library +Build the Runtime and System.Private.CoreLib ============================================ -To Build CoreCLR, run build.sh from the root of the coreclr repo. +To Build CoreCLR, run build.sh to build the CoreCLR subset category of the runtime: -```sh -./src/coreclr/build.sh +``` +./build.sh -subsetCategory coreclr ``` After the build has completed, there should some files placed in `artifacts/bin/coreclr/OSX.x64.Debug`. The ones we are interested in are: @@ -75,4 +75,4 @@ an environment variable to the Core_Root folder. ```sh export CORE_ROOT=/path/to/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root $CORE_ROOT/corerun hello_world.dll -``` \ No newline at end of file +``` diff --git a/eng/Subsets.props b/eng/Subsets.props index a7a3072d7234f..1d36a0c1d3923 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -61,16 +61,19 @@ corehost-managed-depproj-pkgproj-bundle-installers-test all - all + runtime-linuxdac-corelib-nativecorelib-tools-packages all <_subsetCategory Condition="'$(SubsetCategory)' != ''">$(SubsetCategory.ToLowerInvariant()) <_subsetCategory Condition="'$(SubsetCategory)' == ''">$(DefaultSubsetCategories) <_subset Condition="'$(Subset)' != ''">$(Subset.ToLowerInvariant()) <_subset Condition="'$(Subset)' == '' and $(_subsetCategory.Contains('installer'))">$(DefaultInstallerSubsets) - <_subset Condition="'$(Subset)' == '' and $(_subsetCategory.Contains('libraries'))">$(_subset)$(DefaultLibrariesSubsets) - <_subset Condition="'$(Subset)' == '' and $(_subsetCategory.Contains('coreclr'))">$(_subset)$(DefaultCoreClrSubsets) - <_subset Condition="'$(Subset)' == '' and $(_subsetCategory.Contains('mono'))">$(_subset)$(DefaultMonoSubsets) + <_subset Condition="'$(Subset)' == '' and $(_subsetCategory.Contains('libraries'))">$(_subset)-$(DefaultLibrariesSubsets) + <_subset Condition="'$(Subset)' == '' and $(_subsetCategory.Contains('coreclr'))">$(_subset)-$(DefaultCoreClrSubsets) + <_subset Condition="'$(Subset)' == '' and $(_subsetCategory.Contains('mono'))">$(_subset)-$(DefaultMonoSubsets) + + + <_subset>-$(_subset)- @@ -81,7 +84,13 @@ - + + + + + + + @@ -98,7 +107,7 @@ - + @@ -106,6 +115,18 @@ Configuration=$(CoreCLRConfiguration) + + Configuration=$(CoreCLRConfiguration) + + + Configuration=$(CoreCLRConfiguration) + + + Configuration=$(CoreCLRConfiguration) + + + Configuration=$(CoreCLRConfiguration) + @@ -121,58 +142,90 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + diff --git a/eng/build.ps1 b/eng/build.ps1 index c91295f2fa5b2..80508f9f5d535 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -11,7 +11,7 @@ Param( [switch]$allconfigurations, [switch]$coverage, [string]$testscope, - [string]$arch, + [string]$arch = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant(), [string]$subsetCategory, [string]$subset, [ValidateSet("Debug","Release","Checked")][string]$runtimeConfiguration, @@ -146,11 +146,13 @@ foreach ($argument in $PSBoundParameters.Keys) "framework" { $arguments += " /p:BuildTargetFramework=$($PSBoundParameters[$argument].ToLowerInvariant())" } "os" { $arguments += " /p:OSGroup=$($PSBoundParameters[$argument])" } "allconfigurations" { $arguments += " /p:BuildAllConfigurations=true" } - "arch" { $arguments += " /p:ArchGroup=$($PSBoundParameters[$argument]) /p:TargetArchitecture=$($PSBoundParameters[$argument])" } + "arch" { $arch = $PSBoundParameters[$argument]; $arguments += " /p:ArchGroup=$arch /p:TargetArchitecture=$arch" } "properties" { $arguments += " " + $properties } default { $arguments += " /p:$argument=$($PSBoundParameters[$argument])" } } } +$env:__DistroRid="win-$arch" + Invoke-Expression "& `"$PSScriptRoot/common/build.ps1`" $arguments" exit $lastExitCode diff --git a/eng/build.sh b/eng/build.sh index cf8eb87a466a5..4fb3b168b146a 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -60,6 +60,25 @@ usage() echo "Arguments can also be passed in with a single hyphen." } +initDistroRid() +{ + source $scriptroot/native/init-distro-rid.sh + + local passedRootfsDir="" + local buildOs="$1" + local buildArch="$2" + local isCrossBuild="$3" + # For RID calculation purposes, say we are always a portable build + # All of our packages that use the distro rid (CoreCLR packages) are portable. + local isPortableBuild=1 + + # Only pass ROOTFS_DIR if __DoCrossArchBuild is specified. + if (( isCrossBuild == 1 )); then + passedRootfsDir=${ROOTFS_DIR} + fi + initDistroRidGlobal ${buildOs} ${buildArch} ${isPortableBuild} ${passedRootfsDir} +} + arguments='' cmakeargs='' extraargs='' @@ -67,6 +86,9 @@ build=false buildtests=false subsetCategory='' checkedPossibleDirectoryToBuild=false +crossBuild=0 + +source $scriptroot/native/init-os-and-arch.sh # Check if an action is passed in declare -a actions=("r" "restore" "b" "build" "buildtests" "rebuild" "t" "test" "pack" "sign" "publish" "clean") @@ -89,6 +111,7 @@ while [[ $# > 0 ]]; do shift 2 ;; -arch) + arch=$2 arguments="$arguments /p:ArchGroup=$2 /p:TargetArchitecture=$2" shift 2 ;; @@ -103,6 +126,7 @@ while [[ $# > 0 ]]; do shift 2 ;; -os) + os=$2 arguments="$arguments /p:OSGroup=$2" shift 2 ;; @@ -141,6 +165,7 @@ while [[ $# > 0 ]]; do shift 2 ;; -cross) + crossBuild=1 arguments="$arguments /p:CrossBuild=True" shift 1 ;; @@ -187,6 +212,8 @@ if [ ${#actInt[@]} -eq 0 ]; then arguments="-restore -build $arguments" fi +initDistroRid $os $arch $crossBuild + # URL-encode space (%20) to avoid quoting issues until the msbuild call in /eng/common/tools.sh. # In *proj files (XML docs), URL-encoded string are rendered in their decoded form. cmakeargs="${cmakeargs// /%20}" diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 8707e3b6d7042..24562375bd75d 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -193,92 +193,12 @@ usage() exit 1 } -# Use uname to determine what the CPU is. -CPUName=$(uname -p) +source "$__RepoRootDir/eng/native/init-os-and-arch.sh" -# Some Linux platforms report unknown for platform, but the arch for machine. -if [[ "$CPUName" == "unknown" ]]; then - CPUName=$(uname -m) -fi - -case "$CPUName" in - aarch64) - __BuildArch=arm64 - __HostArch=arm64 - ;; - - amd64) - __BuildArch=x64 - __HostArch=x64 - ;; - - armv7l) - if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then - __BuildArch=armel - __HostArch=armel - else - __BuildArch=arm - __HostArch=arm - fi - ;; - - i686) - echo "Unsupported CPU $CPUName detected, build might not succeed!" - __BuildArch=x86 - __HostArch=x86 - ;; - - x86_64) - __BuildArch=x64 - __HostArch=x64 - ;; - - *) - echo "Unknown CPU $CPUName detected, configuring as if for x64" - __BuildArch=x64 - __HostArch=x64 - ;; -esac - -# Use uname to determine what the OS is. -OSName=$(uname -s) -case "$OSName" in - Darwin) - __BuildOS=OSX - __HostOS=OSX - ;; - - FreeBSD) - __BuildOS=FreeBSD - __HostOS=FreeBSD - ;; - - Linux) - __BuildOS=Linux - __HostOS=Linux - ;; - - NetBSD) - __BuildOS=NetBSD - __HostOS=NetBSD - ;; - - OpenBSD) - __BuildOS=OpenBSD - __HostOS=OpenBSD - ;; - - SunOS) - __BuildOS=SunOS - __HostOS=SunOS - ;; - - *) - echo "Unsupported OS $OSName detected, configuring as if for Linux" - __BuildOS=Linux - __HostOS=Linux - ;; -esac +__BuildArch=$arch +__HostArch=$arch +__BuildOS=$os +__HostOS=$os __msbuildonunsupportedplatform=0 diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 7029af814b162..df813691776f7 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -40,6 +40,7 @@ initNonPortableDistroRid() local buildArch="$2" local isPortable="$3" local rootfsDir="$4" + local nonPortableBuildID="" if [ "$buildOs" = "Linux" ]; then if [ -e "${rootfsDir}/etc/os-release" ]; then @@ -115,7 +116,10 @@ initDistroRidGlobal() local buildOs="$1" local buildArch="$2" local isPortable="$3" - local rootfsDir="$4" + local rootfsDir="" + if [ "$#" -ge 4 ]; then + rootfsDir="$4" + fi if [ -n "${rootfsDir}" ]; then # We may have a cross build. Check for the existance of the rootfsDir @@ -134,6 +138,11 @@ initDistroRidGlobal() initNonPortableDistroRid "${buildOs}" "${buildArch}" "${isPortable}" "${rootfsDir}" + if [ "$buildArch" = "wasm" ]; then + __DistroRid=WebAssembly-wasm + export __DistroRid + fi + if [ -z "${__DistroRid}" ]; then # The non-portable build rid was not set. Set the portable rid. diff --git a/eng/native/init-os-and-arch.sh b/eng/native/init-os-and-arch.sh new file mode 100644 index 0000000000000..0f633064bb794 --- /dev/null +++ b/eng/native/init-os-and-arch.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# Use uname to determine what the OS is. +OSName=$(uname -s) +case "$OSName" in +FreeBSD|Linux|NetBSD|OpenBSD|SunOS) + os=$OSName ;; +Darwin) + os=OSX ;; +*) + echo "Unsupported OS $OSName detected, configuring as if for Linux" + os=Linux ;; +esac + +# Use uname to determine what the CPU is. +CPUName=$(uname -p) + +# Some Linux platforms report unknown for platform, but the arch for machine. +if [[ "$CPUName" == "unknown" ]]; then + CPUName=$(uname -m) +fi + +case "$CPUName" in + aarch64) + arch=arm64 + ;; + + amd64|x86_64) + arch=x64 + ;; + + armv7l) + if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then + __BuildArch=armel + __HostArch=armel + else + __BuildArch=arm + __HostArch=arm + fi + ;; + + i[3-6]86) + echo "Unsupported CPU $CPUName detected, build might not succeed!" + arch=x86 + ;; + + *) + echo "Unknown CPU $CPUName detected, configuring as if for x64" + arch=x64 + ;; +esac diff --git a/eng/pipelines/coreclr/templates/build-job.yml b/eng/pipelines/coreclr/templates/build-job.yml index a85e51b09e3f5..6cda0e1ab314a 100644 --- a/eng/pipelines/coreclr/templates/build-job.yml +++ b/eng/pipelines/coreclr/templates/build-job.yml @@ -85,7 +85,7 @@ jobs: value: '' - ${{ if and(eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], 'PullRequest')) }}: - name: officialBuildIdArg - value: '-officialbuildid=$(Build.BuildNumber)' + value: '/p:OfficialBuildId=$(Build.BuildNumber)' - name: enforcePgoArg value: '' # The EnforcePGO script is only supported on Windows and is not supported on arm or arm64. @@ -118,13 +118,21 @@ jobs: parameters: installDotnet: true - # Build + # Build CoreCLR Runtime - ${{ if ne(parameters.osGroup, 'Windows_NT') }}: - - script: $(coreClrRepoRootDir)build$(scriptExt) $(buildConfig) $(archType) $(crossArg) -ci -skipnuget $(clangArg) $(stripSymbolsArg) $(officialBuildIdArg) - displayName: Build product + - script: $(coreClrRepoRootDir)build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) -ci $(clangArg) $(stripSymbolsArg) $(officialBuildIdArg) + displayName: Build CoreCLR Runtime - ${{ if eq(parameters.osGroup, 'Windows_NT') }}: - - script: set __TestIntermediateDir=int&&$(coreClrRepoRootDir)build$(scriptExt) $(buildConfig) $(archType) -ci -skiptests -skipbuildpackages $(officialBuildIdArg) $(enforcePgoArg) - displayName: Build product + - script: set __TestIntermediateDir=int&&$(coreClrRepoRootDir)build-runtime$(scriptExt) $(buildConfig) $(archType) -ci $(enforcePgoArg) $(officialBuildIdArg) + displayName: Build CoreCLR Runtime + + - ${{ if and(eq(parameters.osGroup, 'Windows_NT'), ne(parameters.archType, 'x86')) }}: + - script: set __TestIntermediateDir=int&&$(coreClrRepoRootDir)build-runtime$(scriptExt) $(buildConfig) $(archType) -ci -linuxdac $(officialBuildIdArg) + displayName: Build Cross OS Linux DAC for Windows + + # Build CoreCLR Managed Components + - script: $(Build.SourcesDirectory)$(dir)build$(scriptExt) -subsetCategory coreclr -subset corelib-nativecorelib-tools-packages $(crossArg) -arch $(archType) -c $(buildConfig) $(officialBuildIdArg) -ci + displayName: Build managed product components and packages # Build native test components - script: $(coreClrRepoRootDir)build-test$(scriptExt) skipmanaged $(buildConfig) $(archType) $(crossArg) $(priorityArg) $(clangArg) skipgeneratelayout @@ -173,10 +181,6 @@ jobs: KeyVaultName: EngKeyVault SecretsFilter: 'dotnetfeed-storage-access-key-1,microsoft-symbol-server-pat,symweb-symbol-server-pat' - # Build packages - - script: $(coreClrRepoRootDir)build-packages$(scriptExt) -BuildArch=$(archType) -BuildType=$(_BuildConfig) $(crossArg) $(officialBuildIdArg) -ci --configuration $(_BuildConfig) - displayName: Build packages - # Save packages using the prepare-signed-artifacts format. - ${{ if eq(parameters.isOfficialBuild, true) }}: - template: /eng/pipelines/common/upload-unsigned-artifacts-step.yml diff --git a/eng/pipelines/coreclr/templates/xplat-job.yml b/eng/pipelines/coreclr/templates/xplat-job.yml index e463ddc7752f7..7d83a052f8c29 100644 --- a/eng/pipelines/coreclr/templates/xplat-job.yml +++ b/eng/pipelines/coreclr/templates/xplat-job.yml @@ -108,7 +108,7 @@ jobs: - ${{ if ne(parameters.crossrootfsDir, '') }}: - name: crossArg - value: 'cross' + value: '-cross' - ${{ if eq(parameters.crossrootfsDir, '') }}: - name: crossArg value: '' diff --git a/eng/python.targets b/eng/python.targets new file mode 100644 index 0000000000000..fcc0ce8ad2fe2 --- /dev/null +++ b/eng/python.targets @@ -0,0 +1,32 @@ + + + + <_PythonLocationScript>-c "import sys; sys.stdout.write(sys.executable)" + + + + + + "$(PYTHON)" + + + + + + + + "$(PYTHON)" + + + + diff --git a/eng/run-test.sh b/eng/run-test.sh index b39786cfe3b85..abd1d920b1615 100644 --- a/eng/run-test.sh +++ b/eng/run-test.sh @@ -67,58 +67,10 @@ ProjectRoot="$(dirname "$(dirname "$(realpath ${BASH_SOURCE[0]})")")" # Location parameters # OS/Configuration defaults Configuration="Debug" -OSName=$(uname -s) -case $OSName in - FreeBSD) - OS=FreeBSD - ;; - - NetBSD) - OS=NetBSD - ;; - - Linux) - OS=Linux - ;; - - *) - echo "Unsupported OS $OSName detected, configuring as if for Linux" - OS=Linux - ;; -esac - -# Use uname to determine what the CPU is. -CPUName=$(uname -p) -# Some Linux platforms report unknown for platform, but the arch for machine. -if [ "$CPUName" == "unknown" ]; then - CPUName=$(uname -m) -fi +source $ProjectRoot/eng/native/init-os-and-arch.sh -case $CPUName in - i686) - echo "Unsupported CPU $CPUName detected, test might not succeed!" - __Arch=x86 - ;; - - x86_64) - __Arch=x64 - ;; - - armv7l) - __Arch=armel - ;; - - aarch64) - __Arch=arm64 - ;; - amd64) - __Arch=x64 - ;; - *) - echo "Unknown CPU $CPUName detected, configuring as if for x64" - __Arch=x64 - ;; -esac +OS=$os +__Arch=$arch # Misc defaults TestSelection=".*" diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index d51dc5ed3cb71..f0baa256590ff 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -196,5 +196,3 @@ endif (CLR_CMAKE_HOST_UNIX) # Add Product Directory #------------------------------ add_subdirectory(src) - -include(definitionsconsistencycheck.cmake) diff --git a/src/coreclr/build-packages.cmd b/src/coreclr/build-packages.cmd deleted file mode 100644 index b13ce5b0f831f..0000000000000 --- a/src/coreclr/build-packages.cmd +++ /dev/null @@ -1,61 +0,0 @@ -@if not defined _echo @echo off -setlocal EnableDelayedExpansion - -set "__ProjectDir=%~dp0" -set "__RepoRootDir=%~dp0..\..\" - -set "__args=%*" -set processedArgs= -set unprocessedArgs= -set __MSBuildArgs= - -:Arg_Loop -if "%1" == "" goto ArgsDone -if /I [%1] == [/?] goto Usage -if /I [%1] == [/help] goto Usage - -REM CMD eats "=" on the argument list. -REM TODO: remove all -Property=Value type arguments here once we get rid of them in buildpipeline. -if /i "%1" == "-BuildArch" (set processedArgs=!processedArgs! %1=%2&set __MSBuildArgs=!__MSBuildArgs! /p:__BuildArch=%2&shift&shift&goto Arg_Loop) -if /i "%1" == "-BuildType" (set processedArgs=!processedArgs! %1=%2&set __MSBuildArgs=!__MSBuildArgs! /p:__BuildType=%2&shift&shift&goto Arg_Loop) -if /i "%1" == "-OfficialBuildId" (set processedArgs=!processedArgs! %1=%2&set __MSBuildArgs=!__MSBuildArgs! /p:OfficialBuildId=%2&shift&shift&goto Arg_Loop) -if /i "%1" == "--" (set processedArgs=!processedArgs! %1&shift) - -REM handle any unprocessed arguments, assumed to go only after the processed arguments above -if [!processedArgs!]==[] ( - set unprocessedArgs=%__args% -) else ( - set unprocessedArgs=%__args% - for %%t in (!processedArgs!) do ( - REM strip out already-processed arguments from unprocessedArgs - set unprocessedArgs=!unprocessedArgs:*%%t=! - ) -) - -:ArgsDone - -set logFile=%__RepoRootDir%artifacts\log\build-packages.binlog -powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__RepoRootDir%eng\common\build.ps1"^ - -r -b -projects %__ProjectDir%src\.nuget\packages.builds^ - -verbosity minimal /bl:%logFile% /nodeReuse:false^ - /p:__BuildOS=Windows_NT^ - /p:PortableBuild=true /p:FilterToOSGroup=Windows_NT^ - %__MSBuildArgs% %unprocessedArgs% - -if NOT [!ERRORLEVEL!]==[0] ( - echo ERROR: An error occurred while building packages. See log for more details: - echo %logFile% - exit /b !ERRORLEVEL! -) - -echo Done Building Packages. -exit /b - -:Usage -echo. -echo Builds the NuGet packages from the binaries that were built in the Build product binaries step. -echo The following properties are required to define build architecture -echo -BuildArch=[architecture] -BuildType=[configuration] -echo Architecture can be x64, x86, arm, or arm64 -echo Configuration can be Release, Debug, or Checked -exit /b diff --git a/src/coreclr/build-packages.sh b/src/coreclr/build-packages.sh deleted file mode 100755 index e717e3e5d4819..0000000000000 --- a/src/coreclr/build-packages.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env bash - -usage() -{ - echo "Builds the NuGet packages from the binaries that were built in the Build product binaries step." - echo "Usage: build-packages -BuildArch -BuildType" - echo "BuildArch can be x64, x86, arm, arm64 (default is x64)" - echo "BuildType can be release, checked, debug (default is debug)" - echo - exit 1 -} - -initDistroRid() -{ - source $__RepoRootDir/eng/native/init-distro-rid.sh - - local passedRootfsDir="" - - # Only pass ROOTFS_DIR if __DoCrossArchBuild is specified. - if (( __CrossBuild == 1 )); then - passedRootfsDir=${ROOTFS_DIR} - fi - - initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__IsPortableBuild} ${passedRootfsDir} -} - -__ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -__RepoRootDir=${__ProjectRoot}/../.. - -__IsPortableBuild=1 -__CrossBuild=0 - -# Use uname to determine what the OS is. -OSName=$(uname -s) -case $OSName in - Linux) - __BuildOS=Linux - __HostOS=Linux - ;; - - Darwin) - __BuildOS=OSX - __HostOS=OSX - ;; - - FreeBSD) - __BuildOS=FreeBSD - __HostOS=FreeBSD - ;; - - OpenBSD) - __BuildOS=OpenBSD - __HostOS=OpenBSD - ;; - - NetBSD) - __BuildOS=NetBSD - __HostOS=NetBSD - ;; - - SunOS) - __BuildOS=SunOS - __HostOS=SunOS - ;; - - *) - echo "Unsupported OS $OSName detected, configuring as if for Linux" - __BuildOS=Linux - __HostOS=Linux - ;; -esac - -buildArgs= -unprocessedBuildArgs= - -# TODO: get rid of argument processing entirely once we remove the -# uses of -Arg=Value style in buildpipeline. -while :; do - if [ $# -le 0 ]; then - break - fi - - case "$1" in - -\?|-h|--help) - usage - exit 1 - ;; - -BuildArch=*) - __BuildArch=$(echo $1| cut -d'=' -f 2) - buildArgs="$buildArgs /p:__BuildArch=$__BuildArch" - ;; - -BuildType=*) - __Type=$(echo $1| cut -d'=' -f 2) - buildArgs="$buildArgs /p:__BuildType=$__Type" - ;; - -OfficialBuildId=*|-officialbuildid=*) - __Id=$(echo $1| cut -d'=' -f 2) - buildArgs="$buildArgs /p:OfficialBuildId=$__Id" - ;; - cross) - __CrossBuild=1 - ;; - -portablebuild=false) - buildArgs="$buildArgs /p:PortableBuild=false" - __IsPortableBuild=0 - ;; - --) - ;; - *) - unprocessedBuildArgs="$unprocessedBuildArgs $1" - esac - shift -done - -initDistroRid - -if [ "${__DistroRid}" = "linux-musl-arm64" ]; then - # ArchGroup is generally determined from parsing {}-{}; however, linux-musl-arm64 - # will break this logic. To work around this, pass ArchGroup explicitely. - - export ArchGroup=arm64 - - # Currently the decision tree in src/.nuget/dirs.props will incorrectly - # reparse the already calculated __DistroRid. For linux-musl-arm64 use - # the hack/hook to specifically bypass this logic. - export OutputRID=${__DistroRid} -fi - -logFile=$__RepoRootDir/artifacts/log/build-packages.binlog -$__RepoRootDir/eng/common/build.sh -r -b -projects $__ProjectRoot/src/.nuget/packages.builds \ - -verbosity minimal -bl:$logFile \ - /p:__BuildOS=$__BuildOS \ - /p:PortableBuild=true /p:__DistroRid=$__DistroRid \ - $buildArgs $unprocessedBuildArgs -if [ $? -ne 0 ] -then - echo "ERROR: An error occurred while building packages; See log for more details:" - echo " $logFile" - exit 1 -fi - -echo "Done building packages." -exit 0 diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd new file mode 100644 index 0000000000000..df0a4f681a72e --- /dev/null +++ b/src/coreclr/build-runtime.cmd @@ -0,0 +1,702 @@ +@if not defined _echo @echo off +setlocal EnableDelayedExpansion EnableExtensions + +:: Define a prefix for most output progress messages that come from this script. That makes +:: it easier to see where these are coming from. Note that there is a trailing space here. +set "__MsgPrefix=BUILD: " + +echo %__MsgPrefix%Starting Build at %TIME% + +set __ThisScriptFull="%~f0" +set __ThisScriptDir="%~dp0" + +call "%__ThisScriptDir%"\setup_vs_tools.cmd +if NOT '%ERRORLEVEL%' == '0' goto ExitWithError + +if defined VS160COMNTOOLS ( + set "__VSToolsRoot=%VS160COMNTOOLS%" + set "__VCToolsRoot=%VS160COMNTOOLS%\..\..\VC\Auxiliary\Build" + set __VSVersion=vs2019 +) else if defined VS150COMNTOOLS ( + set "__VSToolsRoot=%VS150COMNTOOLS%" + set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build" + set __VSVersion=vs2017 +) + +:: Note that the msbuild project files (specifically, dir.proj) will use the following variables, if set: +:: __BuildArch -- default: x64 +:: __BuildType -- default: Debug +:: __BuildOS -- default: Windows_NT +:: __ProjectDir -- default: directory of the dir.props file +:: __RepoRootDir -- default: directory two levels above the dir.props file +:: __SourceDir -- default: %__ProjectDir%\src\ +:: __RootBinDir -- default: %__RepoRootDir%\artifacts\ +:: __BinDir -- default: %__RootBinDir%\%__BuildOS%.%__BuildArch.%__BuildType%\ +:: __IntermediatesDir +:: __PackagesBinDir -- default: %__BinDir%\.nuget +:: +:: Thus, these variables are not simply internal to this script! + +:: Set the default arguments for build +set __BuildArch=x64 +set __BuildType=Debug +set __BuildOS=Windows_NT + +:: Set the various build properties here so that CMake and MSBuild can pick them up +set "__ProjectDir=%~dp0" +:: remove trailing slash +if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%" +set "__RepoRootDir=%__ProjectDir%\..\.." + +set "__ProjectFilesDir=%__ProjectDir%" +set "__SourceDir=%__ProjectDir%\src" +set "__RootBinDir=%__RepoRootDir%\artifacts" +set "__LogsDir=%__RootBinDir%\log\!__BuildType!" +set "__MsbuildDebugLogsDir=%__LogsDir%\MsbuildDebugLogs" + +set __BuildAll= + +set __BuildArchX64=0 +set __BuildArchX86=0 +set __BuildArchArm=0 +set __BuildArchArm64=0 + +set __BuildTypeDebug=0 +set __BuildTypeChecked=0 +set __BuildTypeRelease=0 + +set __PgoInstrument=0 +set __PgoOptimize=1 +set __EnforcePgo=0 +set __IbcTuning= + +REM __PassThroughArgs is a set of things that will be passed through to nested calls to build.cmd +REM when using "all". +set __PassThroughArgs= + +REM __UnprocessedBuildArgs are args that we pass to msbuild (e.g. /p:__BuildArch=x64) +set "__args= %*" +set processedArgs= +set __UnprocessedBuildArgs= +set __CommonMSBuildArgs= + +set __BuildNative=1 +set __BuildCrossArchNative=0 +set __SkipCrossArchNative=0 +set __RestoreOptData=1 +set __CrossArch= +set __PgoOptDataPath= + +@REM CMD has a nasty habit of eating "=" on the argument list, so passing: +@REM -priority=1 +@REM appears to CMD parsing as "-priority 1". Handle -priority specially to avoid problems, +@REM and allow the "-priority=1" syntax. +set __Priority= + +:Arg_Loop +if "%1" == "" goto ArgsDone + +if /i "%1" == "/?" goto Usage +if /i "%1" == "-?" goto Usage +if /i "%1" == "/h" goto Usage +if /i "%1" == "-h" goto Usage +if /i "%1" == "/help" goto Usage +if /i "%1" == "-help" goto Usage +if /i "%1" == "--help" goto Usage + +if /i "%1" == "-all" (set __BuildAll=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-x64" (set __BuildArchX64=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-x86" (set __BuildArchX86=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-arm" (set __BuildArchArm=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-arm64" (set __BuildArchArm64=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +if /i "%1" == "-debug" (set __BuildTypeDebug=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-checked" (set __BuildTypeChecked=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-release" (set __BuildTypeRelease=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +if /i "%1" == "-ci" (set __ArcadeScriptArgs="-ci"&set __ErrMsgPrefix=##vso[task.logissue type=error]&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +REM TODO these are deprecated remove them eventually +REM don't add more, use the - syntax instead +if /i "%1" == "all" (set __BuildAll=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "x64" (set __BuildArchX64=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "x86" (set __BuildArchX86=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "arm" (set __BuildArchArm=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "arm64" (set __BuildArchArm64=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +if /i "%1" == "debug" (set __BuildTypeDebug=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "checked" (set __BuildTypeChecked=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "release" (set __BuildTypeRelease=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +if /i "%1" == "-priority" (set __Priority=%2&shift&set processedArgs=!processedArgs! %1=%2&shift&goto Arg_Loop) + +REM Explicitly block -Rebuild. +if /i "%1" == "Rebuild" ( + echo "ERROR: 'Rebuild' is not supported. Please remove it." + goto Usage +) +if /i "%1" == "-Rebuild" ( + echo "ERROR: 'Rebuild' is not supported. Please remove it." + goto Usage +) + + +REM All arguments after this point will be passed through directly to build.cmd on nested invocations +REM using the "all" argument, and must be added to the __PassThroughArgs variable. +if [!__PassThroughArgs!]==[] ( + set __PassThroughArgs=%1 +) else ( + set __PassThroughArgs=%__PassThroughArgs% %1 +) + +if /i "%1" == "-alpinedac" (set __BuildNative=0&set __BuildCrossArchNative=1&set __CrossArch=x64&set __BuildOS=alpine&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-linuxdac" (set __BuildNative=0&set __BuildCrossArchNative=1&set __CrossArch=x64&set __BuildOS=Linux&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +if /i "%1" == "-configureonly" (set __ConfigureOnly=1&set __BuildNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-skipconfigure" (set __SkipConfigure=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-skipnative" (set __BuildNative=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-skipcrossarchnative" (set __SkipCrossArchNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-skiprestoreoptdata" (set __RestoreOptData=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-usenmakemakefiles" (set __NMakeMakefiles=1&set __ConfigureOnly=1&set __BuildNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-pgoinstrument" (set __PgoInstrument=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-enforcepgo" (set __EnforcePgo=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-nopgooptimize" (set __PgoOptimize=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +REM TODO these are deprecated remove them eventually +REM don't add more, use the - syntax instead +if /i "%1" == "configureonly" (set __ConfigureOnly=1&set __BuildNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "skipconfigure" (set __SkipConfigure=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "skipnative" (set __BuildNative=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "skipcrossarchnative" (set __SkipCrossArchNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "skiprestoreoptdata" (set __RestoreOptData=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "usenmakemakefiles" (set __NMakeMakefiles=1&set __ConfigureOnly=1&set __BuildNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "pgoinstrument" (set __PgoInstrument=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "nopgooptimize" (set __PgoOptimize=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "enforcepgo" (set __EnforcePgo=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +REM TODO remove this once it's no longer used in buildpipeline +if /i "%1" == "--" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +if [!processedArgs!]==[] ( + set __UnprocessedBuildArgs=%__args% +) else ( + set __UnprocessedBuildArgs=%__args% + for %%t in (!processedArgs!) do ( + set __UnprocessedBuildArgs=!__UnprocessedBuildArgs:*%%t=! + ) +) + +:ArgsDone + +@REM Special handling for -priority=N argument. +if defined __Priority ( + if defined __PassThroughArgs ( + set __PassThroughArgs=%__PassThroughArgs% -priority=%__Priority% + ) else ( + set __PassThroughArgs=-priority=%__Priority% + ) +) + +if defined __BuildAll goto BuildAll + +set /A __TotalSpecifiedBuildArch=__BuildArchX64 + __BuildArchX86 + __BuildArchArm + __BuildArchArm64 +if %__TotalSpecifiedBuildArch% GTR 1 ( + echo Error: more than one build architecture specified, but "all" not specified. + goto Usage +) + +if %__BuildArchX64%==1 set __BuildArch=x64 +if %__BuildArchX86%==1 set __BuildArch=x86 +if %__BuildArchArm%==1 ( + set __BuildArch=arm + set __CrossArch=x86 +) +if %__BuildArchArm64%==1 ( + set __BuildArch=arm64 + set __CrossArch=x64 +) + +set /A __TotalSpecifiedBuildType=__BuildTypeDebug + __BuildTypeChecked + __BuildTypeRelease +if %__TotalSpecifiedBuildType% GTR 1 ( + echo Error: more than one build type specified, but "all" not specified. + goto Usage +) + +if %__BuildTypeDebug%==1 set __BuildType=Debug +if %__BuildTypeChecked%==1 set __BuildType=Checked +if %__BuildTypeRelease%==1 set __BuildType=Release + +set __CommonMSBuildArgs=/p:__BuildOS=%__BuildOS% /p:__BuildType=%__BuildType% /p:__BuildArch=%__BuildArch% + +if %__EnforcePgo%==1 ( + if %__BuildArchArm%==1 ( + echo NOTICE: enforcepgo does nothing on arm architecture + set __EnforcePgo=0 + ) + if %__BuildArchArm64%==1 ( + echo NOTICE: enforcepgo does nothing on arm64 architecture + set __EnforcePgo=0 + ) +) + +REM Determine if this is a cross-arch build. Only do cross-arch build if we're also building native. + +if %__SkipCrossArchNative% EQU 0 ( + if %__BuildNative% EQU 1 ( + if /i "%__BuildArch%"=="arm64" ( + set __BuildCrossArchNative=1 + ) + if /i "%__BuildArch%"=="arm" ( + set __BuildCrossArchNative=1 + ) + ) +) + +REM Set the remaining variables based upon the determined build configuration + +if %__PgoOptimize%==0 ( + set __RestoreOptData=0 +) + +set "__BinDir=%__RootBinDir%\bin\coreclr\%__BuildOS%.%__BuildArch%.%__BuildType%" +set "__IntermediatesDir=%__RootBinDir%\obj\coreclr\%__BuildOS%.%__BuildArch%.%__BuildType%" +set "__ArtifactsIntermediatesDir=%__RepoRootDir%\artifacts\obj\coreclr\" +if "%__NMakeMakefiles%"=="1" (set "__IntermediatesDir=%__RootBinDir%\nmakeobj\%__BuildOS%.%__BuildArch%.%__BuildType%") +set "__PackagesBinDir=%__BinDir%\.nuget" +set "__CrossComponentBinDir=%__BinDir%" +set "__CrossCompIntermediatesDir=%__IntermediatesDir%\crossgen" + + +if NOT "%__CrossArch%" == "" set __CrossComponentBinDir=%__CrossComponentBinDir%\%__CrossArch% + +REM Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash +set "__CMakeBinDir=%__BinDir%" +set "__CMakeBinDir=%__CMakeBinDir:\=/%" + +if not exist "%__BinDir%" md "%__BinDir%" +if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%" +if not exist "%__LogsDir%" md "%__LogsDir%" +if not exist "%__MsbuildDebugLogsDir%" md "%__MsbuildDebugLogsDir%" + +if not exist "%__RootBinDir%\Directory.Build.props" copy %__ProjectDir%\EmptyProps.props %__RootBinDir%\Directory.Build.props +if not exist "%__RootBinDir%\Directory.Build.targets" copy %__ProjectDir%\EmptyProps.props %__RootBinDir%\Directory.Build.targets + +REM Set up the directory for MSBuild debug logs. +set MSBUILDDEBUGPATH=%__MsbuildDebugLogsDir% + +echo %__MsgPrefix%Commencing CoreCLR product build + +REM Set the remaining variables based upon the determined build configuration + +echo %__MsgPrefix%Checking prerequisites + +set __CMakeNeeded=1 +if %__BuildNative%==0 if %__BuildCrossArchNative%==0 set __CMakeNeeded=0 +if %__CMakeNeeded%==1 ( + REM Eval the output from set-cmake-path.ps1 + for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__SourceDir%\pal\tools\set-cmake-path.ps1"""') do %%a + echo %__MsgPrefix%Using CMake from !CMakePath! +) + +REM NumberOfCores is an WMI property providing number of physical cores on machine +REM processor(s). It is used to set optimal level of CL parallelism during native build step +if not defined NumberOfCores ( + REM Determine number of physical processor cores available on machine + set TotalNumberOfCores=0 + for /f "tokens=*" %%I in ( + 'wmic cpu get NumberOfCores /value ^| find "=" 2^>NUL' + ) do set %%I & set /a TotalNumberOfCores=TotalNumberOfCores+NumberOfCores + set NumberOfCores=!TotalNumberOfCores! +) +echo %__MsgPrefix%Number of processor cores %NumberOfCores% + +REM ========================================================================================= +REM === +REM === Start the build steps +REM === +REM ========================================================================================= + +@if defined _echo @echo on + +echo %__MsgPrefix%Generating native version headers +set "__BinLog=%__LogsDir%\GenerateVersionHeaders_%__BuildOS%__%__BuildArch%__%__BuildType%.binlog" +powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__RepoRootDir%\eng\common\msbuild.ps1" /clp:nosummary %__ArcadeScriptArgs%^ + %__RepoRootDir%\eng\empty.csproj /p:NativeVersionFile="%__RootBinDir%\obj\coreclr\_version.h"^ + /t:GenerateNativeVersionFile /restore^ + %__CommonMSBuildArgs% %__UnprocessedBuildArgs% /bl:!__BinLog! +if not !errorlevel! == 0 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: Failed to generate version headers. + set __exitCode=!errorlevel! + goto ExitWithCode +) + +REM ========================================================================================= +REM === +REM === Restore optimization profile data +REM === +REM ========================================================================================= + +set OptDataProjectFilePath=%__ProjectDir%\src\.nuget\optdata\optdata.csproj +if %__RestoreOptData% EQU 1 ( + echo %__MsgPrefix%Restoring the OptimizationData Package + set "__BinLog=%__LogsDir%\OptRestore_%__BuildOS%__%__BuildArch%__%__BuildType%.binlog" + powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__RepoRootDir%\eng\common\msbuild.ps1" /clp:nosummary %__ArcadeScriptArgs%^ + %OptDataProjectFilePath% /t:Restore^ + %__CommonMSBuildArgs% %__UnprocessedBuildArgs%^ + /nodereuse:false /bl:!__BinLog! + if not !errorlevel! == 0 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: Failed to restore the optimization data package. + set __exitCode=!errorlevel! + goto ExitWithCode + ) +) +set __PgoOptDataPath= +if %__PgoOptimize% EQU 1 ( + set PgoDataPackagePathOutputFile="%__IntermediatesDir%\optdatapath.txt" + set "__BinLog=%__LogsDir%\PgoVersionRead_%__BuildOS%__%__BuildArch%__%__BuildType%.binlog" + + REM Parse the optdata package versions out of msbuild so that we can pass them on to CMake + powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__RepoRootDir%\eng\common\msbuild.ps1" /clp:nosummary %__ArcadeScriptArgs%^ + "%OptDataProjectFilePath%" /t:DumpPgoDataPackagePath %__CommonMSBuildArgs% /p:PgoDataPackagePathOutputFile="!PgoDataPackagePathOutputFile!"^ + /bl:!__BinLog! + + if not !errorlevel! == 0 ( + echo %__ErrMsgPrefix%Failed to get PGO data package path. + set __exitCode=!errorlevel! + goto ExitWithCode + ) + if not exist "!PgoDataPackagePathOutputFile!" ( + echo %__ErrMsgPrefix%Failed to get PGO data package path. + goto ExitWithError + ) + + set /p __PgoOptDataPath=<"!PgoDataPackagePathOutputFile!" +) + +REM ========================================================================================= +REM === +REM === Locate Python +REM === +REM ========================================================================================= + +set __IntermediatesIncDir=%__IntermediatesDir%\src\inc +set __IntermediatesEventingDir=%__ArtifactsIntermediatesDir%\Eventing\%__BuildArch%\%__BuildType% + +REM Find python and set it to the variable PYTHON +set _C=-c "import sys; sys.stdout.write(sys.executable)" +(py -3 %_C% || py -2 %_C% || python3 %_C% || python2 %_C% || python %_C%) > %TEMP%\pythonlocation.txt 2> NUL +set _C= +set /p PYTHON=<%TEMP%\pythonlocation.txt + +if NOT DEFINED PYTHON ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: Could not find a python installation + goto ExitWithError +) + +REM ========================================================================================= +REM === +REM === Build Cross-Architecture Native Components (if applicable) +REM === +REM ========================================================================================= + +if %__BuildCrossArchNative% EQU 1 ( + REM Scope environment changes start { + setlocal + + echo %__MsgPrefix%Commencing build of cross architecture native components for %__BuildOS%.%__BuildArch%.%__BuildType% + + REM Set the environment for the cross-arch native build + set __VCBuildArch=x86_amd64 + if /i "%__CrossArch%" == "x86" ( set __VCBuildArch=x86 ) + + echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! + call "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! + @if defined _echo @echo on + + if not exist "%__CrossCompIntermediatesDir%" md "%__CrossCompIntermediatesDir%" + if defined __SkipConfigure goto SkipConfigureCrossBuild + + set __CMakeBinDir=%__CrossComponentBinDir% + set "__CMakeBinDir=!__CMakeBinDir:\=/!" + set __ExtraCmakeArgs="-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__BuildOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" "-DCMAKE_SYSTEM_VERSION=10.0" "-DCLR_ENG_NATIVE_DIR=%__RepoRootDir%/eng/native" "-DCLR_REPO_ROOT_DIR=%__RepoRootDir%" + call "%__SourceDir%\pal\tools\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossCompIntermediatesDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs! + + if not !errorlevel! == 0 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate native component build project! + goto ExitWithError + ) + @if defined _echo @echo on + +:SkipConfigureCrossBuild + if not exist "%__CrossCompIntermediatesDir%\CMakeCache.txt" ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: unable to find generated native component build project! + goto ExitWithError + ) + + if defined __ConfigureOnly goto SkipCrossCompBuild + + set __BuildLogRootName=Cross + set "__BuildLog=%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.log" + set "__BuildWrn=%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn" + set "__BuildErr=%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.err" + set "__BinLog=%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.binlog" + set "__MsbuildLog=/flp:Verbosity=normal;LogFile=!__BuildLog!" + set "__MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn!" + set "__MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr!" + set "__MsbuildBinLog=/bl:!__BinLog!" + set "__Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! !__MsbuildBinLog!" + + REM We pass the /m flag directly to MSBuild so that we can get both MSBuild and CL parallelism, which is fastest for our builds. + "%CMakePath%" --build %__CrossCompIntermediatesDir% --target install --config %__BuildType% -- /nologo /m !__Logging! + + if not !errorlevel! == 0 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: cross-arch components build failed. + set __exitCode=!errorlevel! + goto ExitWithCode + ) + +:SkipCrossCompBuild + REM } Scope environment changes end + endlocal +) + +REM ========================================================================================= +REM === +REM === Build the CLR VM +REM === +REM ========================================================================================= + +if %__BuildNative% EQU 1 ( + REM Scope environment changes start { + setlocal + + echo %__MsgPrefix%Commencing build of native components for %__BuildOS%.%__BuildArch%.%__BuildType% + + REM Set the environment for the native build + set __VCBuildArch=x86_amd64 + if /i "%__BuildArch%" == "x86" ( set __VCBuildArch=x86 ) + if /i "%__BuildArch%" == "arm" ( + set __VCBuildArch=x86_arm + set ___CrossBuildDefine="-DCLR_CMAKE_CROSS_ARCH=1" "-DCLR_CMAKE_CROSS_HOST_ARCH=%__CrossArch%" + ) + if /i "%__BuildArch%" == "arm64" ( + set __VCBuildArch=x86_arm64 + set ___CrossBuildDefine="-DCLR_CMAKE_CROSS_ARCH=1" "-DCLR_CMAKE_CROSS_HOST_ARCH=%__CrossArch%" + ) + + echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! + call "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! + @if defined _echo @echo on + + if not defined VSINSTALLDIR ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: VSINSTALLDIR variable not defined. + goto ExitWithError + ) + if not exist "!VSINSTALLDIR!DIA SDK" goto NoDIA + + if defined __SkipConfigure goto SkipConfigure + + echo %__MsgPrefix%Regenerating the Visual Studio solution + + set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0" !___CrossBuildDefine! "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" "-DCLR_ENG_NATIVE_DIR=%__RepoRootDir%/eng/native" + call "%__SourceDir%\pal\tools\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs! + if not !errorlevel! == 0 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate native component build project! + goto ExitWithError + ) + + @if defined _echo @echo on + +:SkipConfigure + if not exist "%__IntermediatesDir%\CMakeCache.txt" ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: unable to find generated native component build project! + goto ExitWithError + ) + + if defined __ConfigureOnly goto SkipNativeBuild + + set __BuildLogRootName=CoreCLR + set "__BuildLog=%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.log" + set "__BuildWrn=%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn" + set "__BuildErr=%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.err" + set "__BinLog=%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.binlog" + set "__MsbuildLog=/flp:Verbosity=normal;LogFile=!__BuildLog!" + set "__MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn!" + set "__MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr!" + set "__MsbuildBinLog=/bl:!__BinLog!" + set "__Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! !__MsbuildBinLog!" + + REM We pass the /m flag directly to MSBuild so that we can get both MSBuild and CL parallelism, which is fastest for our builds. + "%CMakePath%" --build %__IntermediatesDir% --target install --config %__BuildType% -- /nologo /m !__Logging! + + if not !errorlevel! == 0 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: native component build failed. + set __exitCode=!errorlevel! + goto ExitWithCode + ) + + if not "%__BuildArch%" == "arm64" ( + mkdir "%__BinDir%\Redist\ucrt\DLLs\%__BuildArch%" + copy /Y "%UniversalCRTSDKDIR%Redist\ucrt\DLLs\%__BuildArch%\*.dll" "%__BinDir%\Redist\ucrt\DLLs\%__BuildArch%" + if not !errorlevel! == 0 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: Failed to copy the CRT to the output. + set __exitCode=!errorlevel! + goto ExitWithCode + ) + ) + + if %__EnforcePgo% EQU 1 ( + "%PYTHON%" "%__ProjectDir%\src\scripts\pgocheck.py" "%__BinDir%\coreclr.dll" "%__BinDir%\clrjit.dll" + ) + +:SkipNativeBuild + REM } Scope environment changes end + endlocal +) + +REM ========================================================================================= +REM === +REM === All builds complete! +REM === +REM ========================================================================================= + +echo %__MsgPrefix%Build succeeded. Finished at %TIME% +echo %__MsgPrefix%Product binaries are available at !__BinDir! +exit /b 0 + +REM ========================================================================================= +REM === +REM === Handle the "all" case. +REM === +REM ========================================================================================= + +:BuildAll + +set __BuildArchList= + +set /A __TotalSpecifiedBuildArch=__BuildArchX64 + __BuildArchX86 + __BuildArchArm + __BuildArchArm64 +if %__TotalSpecifiedBuildArch% EQU 0 ( + REM Nothing specified means we want to build all architectures. + set __BuildArchList=x64 x86 arm arm64 +) + +REM Otherwise, add all the specified architectures to the list. + +if %__BuildArchX64%==1 set __BuildArchList=%__BuildArchList% x64 +if %__BuildArchX86%==1 set __BuildArchList=%__BuildArchList% x86 +if %__BuildArchArm%==1 set __BuildArchList=%__BuildArchList% arm +if %__BuildArchArm64%==1 set __BuildArchList=%__BuildArchList% arm64 + +set __BuildTypeList= + +set /A __TotalSpecifiedBuildType=__BuildTypeDebug + __BuildTypeChecked + __BuildTypeRelease +if %__TotalSpecifiedBuildType% EQU 0 ( + REM Nothing specified means we want to build all build types. + set __BuildTypeList=Debug Checked Release +) + +if %__BuildTypeDebug%==1 set __BuildTypeList=%__BuildTypeList% Debug +if %__BuildTypeChecked%==1 set __BuildTypeList=%__BuildTypeList% Checked +if %__BuildTypeRelease%==1 set __BuildTypeList=%__BuildTypeList% Release + +REM Create a temporary file to collect build results. We always build all flavors specified, and +REM report a summary of the results at the end. + +set __AllBuildSuccess=true +set __BuildResultFile=%TEMP%\build-all-summary-%RANDOM%.txt +if exist %__BuildResultFile% del /f /q %__BuildResultFile% + +for %%i in (%__BuildArchList%) do ( + for %%j in (%__BuildTypeList%) do ( + call :BuildOne %%i %%j + ) +) + +if %__AllBuildSuccess%==true ( + echo %__MsgPrefix%All builds succeeded! + exit /b 0 +) else ( + echo %__MsgPrefix%Builds failed: + type %__BuildResultFile% + del /f /q %__BuildResultFile% + goto ExitWithError +) + +REM This code is unreachable, but leaving it nonetheless, just in case things change. +exit /b 99 + +:BuildOne +set __BuildArch=%1 +set __BuildType=%2 +set __NextCmd=call %__ThisScriptFull% %__BuildArch% %__BuildType% %__PassThroughArgs% +echo %__MsgPrefix%Invoking: %__NextCmd% +%__NextCmd% +if not !errorlevel! == 0 ( + echo %__MsgPrefix% %__BuildArch% %__BuildType% %__PassThroughArgs% >> %__BuildResultFile% + set __AllBuildSuccess=false +) +exit /b 0 + +REM ========================================================================================= +REM === +REM === Helper routines +REM === +REM ========================================================================================= + + +REM ========================================================================================= +REM === These two routines are intended for the exit code to propagate to the parent process +REM === Like MSBuild or Powershell. If we directly exit /b 1 from within a if statement in +REM === any of the routines, the exit code is not propagated. +REM ========================================================================================= +:ExitWithError +exit /b 1 + +:ExitWithCode +exit /b !__exitCode! + +:Usage +echo. +echo Build the CoreCLR repo. +echo. +echo Usage: +echo build-runtime.cmd [option1] [option2] +echo or: +echo build-runtime.cmd all [option1] [option2] +echo. +echo All arguments are optional. The options are: +echo. +echo.-? -h -help --help: view this message. +echo -all: Builds all configurations and platforms. +echo Build architecture: one of -x64, -x86, -arm, -arm64 ^(default: -x64^). +echo Build type: one of -Debug, -Checked, -Release ^(default: -Debug^). +echo -nopgooptimize: do not use profile guided optimizations. +echo -enforcepgo: verify after the build that PGO was used for key DLLs, and fail the build if not +echo -pgoinstrument: generate instrumented code for profile guided optimization enabled binaries. +echo -configureonly: skip all builds; only run CMake ^(default: CMake and builds are run^) +echo -skipconfigure: skip CMake ^(default: CMake is run^) +echo -skipnative: skip building native components ^(default: native components are built^). +echo -skipcrossarchnative: skip building cross-architecture native components ^(default: components are built^). +echo -skiprestoreoptdata: skip restoring optimization data used by profile-based optimizations. +echo -priority=^ : specify a set of test that will be built and run, with priority N. +echo portable : build for portable RID. +echo. +echo If "all" is specified, then all build architectures and types are built. If, in addition, +echo one or more build architectures or types is specified, then only those build architectures +echo and types are built. +echo. +echo For example: +echo build -all +echo -- builds all architectures, and all build types per architecture +echo build -all -x86 +echo -- builds all build types for x86 +echo build -all -x64 -x86 -Checked -Release +echo -- builds x64 and x86 architectures, Checked and Release build types for each +exit /b 1 + +:NoDIA +echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^ +Did you install all the requirements for building on Windows, including the "Desktop Development with C++" workload? ^ +Please see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/windows-requirements.md ^ +Another possibility is that you have a parallel installation of Visual Studio and the DIA SDK is there. In this case it ^ +may help to copy its "DIA SDK" folder into "%VSINSTALLDIR%" manually, then try again. +exit /b 1 diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh new file mode 100755 index 0000000000000..149b1944fa97c --- /dev/null +++ b/src/coreclr/build-runtime.sh @@ -0,0 +1,256 @@ +#!/usr/bin/env bash + +# resolve python-version to use +if [[ -z "$PYTHON" ]]; then + if ! PYTHON=$(command -v python3 || command -v python2 || command -v python || command -v py) + then + echo "Unable to locate build-dependency python!" 1>&2 + exit 1 + fi +fi +# validate python-dependency +# useful in case of explicitly set option. +if ! command -v "$PYTHON" > /dev/null +then + echo "Unable to locate build-dependency python ($PYTHON)!" 1>&2 + exit 1 +fi + +export PYTHON + +usage_list+=("-nopgooptimize: do not use profile guided optimizations.") +usage_list+=("-pgoinstrument: generate instrumented code for profile guided optimization enabled binaries.") +usage_list+=("-skipcrossarchnative: Skip building cross-architecture native binaries.") +usage_list+=("-skiprestoreoptdata: skip restoring optimization data.") +usage_list+=("-staticanalyzer: skip native image generation.") + +setup_dirs_local() +{ + setup_dirs + + mkdir -p "$__LogsDir" + mkdir -p "$__MsbuildDebugLogsDir" + + if [[ "$__CrossBuild" == 1 ]]; then + mkdir -p "$__CrossComponentBinDir" + fi +} + +restore_optdata() +{ + local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj" + if [[ "$__SkipRestoreOptData" == 0 && "$__IsMSBuildOnNETCoreSupported" == 1 ]]; then + echo "Restoring the OptimizationData package" + "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs \ + $OptDataProjectFilePath /t:Restore /m \ + $__CommonMSBuildArgs $__UnprocessedBuildArgs \ + /nodereuse:false + local exit_code="$?" + if [[ "$exit_code" != 0 ]]; then + echo "${__ErrMsgPrefix}Failed to restore the optimization data package." + exit "$exit_code" + fi + fi + + if [[ "$__PgoOptimize" == 1 && "$__IsMSBuildOnNETCoreSupported" == 1 ]]; then + # Parse the optdata package versions out of msbuild so that we can pass them on to CMake + + local PgoDataPackagePathOutputFile="${__IntermediatesDir}/optdatapath.txt" + + # Writes into ${PgoDataPackagePathOutputFile} + "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs $OptDataProjectFilePath /t:DumpPgoDataPackagePath ${__CommonMSBuildArgs} /p:PgoDataPackagePathOutputFile=${PgoDataPackagePathOutputFile} > /dev/null 2>&1 + local exit_code="$?" + if [[ "$exit_code" != 0 || ! -f "${PgoDataPackagePathOutputFile}" ]]; then + echo "${__ErrMsgPrefix}Failed to get PGO data package path." + exit "$exit_code" + fi + + __PgoOptDataPath=$(<"${PgoDataPackagePathOutputFile}") + fi +} + +build_cross_architecture_components() +{ + local intermediatesForBuild="$__IntermediatesDir/Host$__CrossArch/crossgen" + local crossArchBinDir="$__BinDir/$__CrossArch" + + mkdir -p "$intermediatesForBuild" + mkdir -p "$crossArchBinDir" + + __SkipCrossArchBuild=1 + # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair + if [[ ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") && ("$__CrossArch" == "x86" || "$__CrossArch" == "x64") ]]; then + __SkipCrossArchBuild=0 + elif [[ "$__BuildArch" == "arm64" && "$__CrossArch" == "x64" ]]; then + __SkipCrossArchBuild=0 + else + # not supported + return + fi + + __CMakeBinDir="$crossArchBinDir" + CROSSCOMPILE=0 + export __CMakeBinDir CROSSCOMPILE + + __CMakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__BuildArch -DCLR_CROSS_COMPONENTS_BUILD=1 $__CMakeArgs" + build_native "$__CrossArch" "$__ProjectRoot" "$__ProjectRoot" "$intermediatesForBuild" "cross-architecture components" + + CROSSCOMPILE=1 + export CROSSCOMPILE +} + +handle_arguments_local() { + case "$1" in + + ignorewarnings|-ignorewarnings) + __IgnoreWarnings=1 + __CMakeArgs="-DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF $__CMakeArgs" + ;; + + nopgooptimize|-nopgooptimize) + __PgoOptimize=0 + __SkipRestoreOptData=1 + ;; + + pgoinstrument|-pgoinstrument) + __PgoInstrument=1 + ;; + + skipcrossarchnative|-skipcrossarchnative) + __SkipCrossArchNative=1 + ;; + + staticanalyzer|-staticanalyzer) + __StaticAnalyzer=1 + ;; + + *) + __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1" + ;; + esac +} + +echo "Commencing CoreCLR Repo build" + +# Argument types supported by this script: +# +# Build architecture - valid values are: x64, ARM. +# Build Type - valid values are: Debug, Checked, Release +# +# Set the default arguments for build + +# Obtain the location of the bash script to figure out where the root of the repo is. +__ProjectRoot="$(cd "$(dirname "$0")"; pwd -P)" +__RepoRootDir="$(cd "$__ProjectRoot"/../..; pwd -P)" + +__BuildArch= +__BuildType=Debug +__CodeCoverage=0 +__IgnoreWarnings=0 + +# Set the various build properties here so that CMake and MSBuild can pick them up +__Compiler=clang +__CompilerMajorVersion= +__CompilerMinorVersion= +__CommonMSBuildArgs= +__ConfigureOnly=0 +__CrossBuild=0 +__DistroRid="" +__PgoInstrument=0 +__PgoOptDataPath="" +__PgoOptimize=1 +__PortableBuild=1 +__ProjectDir="$__ProjectRoot" +__RootBinDir="$__RepoRootDir/artifacts" +__SignTypeArg="" +__SkipConfigure=0 +__SkipNative=0 +__SkipCrossArchNative=0 +__SkipGenerateVersion=0 +__SkipManaged=0 +__SkipRestore="" +__SkipRestoreOptData=0 +__SourceDir="$__ProjectDir/src" +__StaticAnalyzer=0 +__UnprocessedBuildArgs= +__UseNinja=0 +__VerboseBuild=0 +__ValidateCrossArg=1 +__CMakeArgs="" + +source "$__ProjectRoot"/_build-commons.sh + +if [[ "${__BuildArch}" != "${__HostArch}" ]]; then + __CrossBuild=1 +fi + +# Set dependent variables +__LogsDir="$__RootBinDir/log" +__MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs" + +# Set the remaining variables based upon the determined build configuration +__BinDir="$__RootBinDir/bin/coreclr/$__BuildOS.$__BuildArch.$__BuildType" +__IntermediatesDir="$__RootBinDir/obj/coreclr/$__BuildOS.$__BuildArch.$__BuildType" +__ArtifactsIntermediatesDir="$__RepoRootDir/artifacts/obj/coreclr" +export __IntermediatesDir __ArtifactsIntermediatesDir +__CrossComponentBinDir="$__BinDir" + +__CrossArch="$__HostArch" +if [[ "$__CrossBuild" == 1 ]]; then + __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch" +fi + +# CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set. +# This is needed by CLI to function. +if [[ -z "$HOME" ]]; then + if [[ ! -d "$__ProjectDir/temp_home" ]]; then + mkdir temp_home + fi + HOME="$__ProjectDir"/temp_home + export HOME + echo "HOME not defined; setting it to $HOME" +fi + +# Specify path to be set for CMAKE_INSTALL_PREFIX. +# This is where all built CoreClr libraries will copied to. +__CMakeBinDir="$__BinDir" +export __CMakeBinDir + +# Make the directories necessary for build if they don't exist +setup_dirs_local + +# Set up the directory for MSBuild debug logs. +MSBUILDDEBUGPATH="${__MsbuildDebugLogsDir}" +export MSBUILDDEBUGPATH + +# Check prereqs. +check_prereqs + +# Restore the package containing profile counts for profile-guided optimizations +restore_optdata + +# Build the coreclr (native) components. +__CMakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize -DCLR_REPO_ROOT_DIR=\"$__RepoRootDir\" $__CMakeArgs" + +if [[ "$__SkipConfigure" == 0 && "$__CodeCoverage" == 1 ]]; then + __CMakeArgs="-DCLR_CMAKE_ENABLE_CODE_COVERAGE=1 $__CMakeArgs" +fi + +if [[ "$__SkipNative" == 1 ]]; then + echo "Skipping CoreCLR component build." +else + build_native "$__BuildArch" "$__ProjectRoot" "$__ProjectRoot" "$__IntermediatesDir" "CoreCLR component" + + # Build cross-architecture components + if [[ "$__SkipCrossArchNative" != 1 ]]; then + if [[ "$__CrossBuild" == 1 ]]; then + build_cross_architecture_components + fi + fi +fi + +# Build complete + +echo "Repo successfully built." +echo "Product binaries are available at $__BinDir" +exit 0 diff --git a/src/coreclr/build.cmd b/src/coreclr/build.cmd index 7147b08c3b7d3..08fa1f84d216e 100644 --- a/src/coreclr/build.cmd +++ b/src/coreclr/build.cmd @@ -6,6 +6,8 @@ setlocal EnableDelayedExpansion EnableExtensions set "__MsgPrefix=BUILD: " echo %__MsgPrefix%Starting Build at %TIME% +echo %__MsgPrefix%WARNING: This build script is deprecated and will be deleted soon. Use the root build script to build CoreCLR. If you want to build the CoreCLR runtime without using MSBuild, use the build-native.cmd script. +echo %__MsgPrefix%See https://github.com/dotnet/runtime/issues/32991 for more information. set __ThisScriptFull="%~f0" set __ThisScriptDir="%~dp0" @@ -907,6 +909,11 @@ if not !errorlevel! == 0 ( echo %__MsgPrefix% %__BuildArch% %__BuildType% %__PassThroughArgs% >> %__BuildResultFile% set __AllBuildSuccess=false ) + + +echo %__MsgPrefix%WARNING: This build script is deprecated and will be deleted soon. Use the root build script to build CoreCLR. If you want to build the CoreCLR runtime without using MSBuild, use the build-native.cmd script. +echo %__MsgPrefix%See https://github.com/dotnet/runtime/issues/32991 for more information. + exit /b 0 REM ========================================================================================= @@ -922,9 +929,13 @@ REM === Like MSBuild or Powershell. If we directly exit /b 1 from within a if st REM === any of the routines, the exit code is not propagated. REM ========================================================================================= :ExitWithError +echo %__MsgPrefix%WARNING: This build script is deprecated and will be deleted soon. Use the root build script to build CoreCLR. If you want to build the CoreCLR runtime without using MSBuild, use the build-native.cmd script. +echo %__MsgPrefix%See https://github.com/dotnet/runtime/issues/32991 for more information. exit /b 1 :ExitWithCode +echo %__MsgPrefix%WARNING: This build script is deprecated and will be deleted soon. Use the root build script to build CoreCLR. If you want to build the CoreCLR runtime without using MSBuild, use the build-native.cmd script. +echo %__MsgPrefix%See https://github.com/dotnet/runtime/issues/32991 for more information. exit /b !__exitCode! :BuildCrossOSDac diff --git a/src/coreclr/build.sh b/src/coreclr/build.sh index b28b6089b1e81..97ed1a15f6f09 100755 --- a/src/coreclr/build.sh +++ b/src/coreclr/build.sh @@ -391,6 +391,8 @@ handle_arguments_local() { } echo "Commencing CoreCLR Repo build" +echo "WARNING: This build script is deprecated and will be deleted soon. Use the root build script to build CoreCLR. If you want to build the CoreCLR runtime without using MSBuild, use the build-native.sh script." +echo "See https://github.com/dotnet/runtime/issues/32991 for more information." # Argument types supported by this script: # @@ -546,4 +548,6 @@ fi echo "Repo successfully built." echo "Product binaries are available at $__BinDir" +echo "WARNING: This build script is deprecated and will be deleted soon. Use the root build script to build CoreCLR. If you want to build the CoreCLR runtime without using MSBuild, use the build-native.sh script." +echo "See https://github.com/dotnet/runtime/issues/32991 for more information." exit 0 diff --git a/src/coreclr/crossgen-corelib.cmd b/src/coreclr/crossgen-corelib.cmd new file mode 100644 index 0000000000000..7cd05c3e8e00f --- /dev/null +++ b/src/coreclr/crossgen-corelib.cmd @@ -0,0 +1,267 @@ +@if not defined _echo @echo off +setlocal EnableDelayedExpansion EnableExtensions + +:: Define a prefix for most output progress messages that come from this script. That makes +:: it easier to see where these are coming from. Note that there is a trailing space here. +set "__MsgPrefix=CROSSGEN-CORELIB: " + +echo %__MsgPrefix%Starting Build at %TIME% + +set __ThisScriptFull="%~f0" +set __ThisScriptDir="%~dp0" + +:: Note that the msbuild project files (specifically, dir.proj) will use the following variables, if set: +:: __BuildArch -- default: x64 +:: __BuildType -- default: Debug +:: __BuildOS -- default: Windows_NT +:: __ProjectDir -- default: directory of the dir.props file +:: __RepoRootDir -- default: directory two levels above the dir.props file +:: __RootBinDir -- default: %__RepoRootDir%\artifacts\ +:: __BinDir -- default: %__RootBinDir%\%__BuildOS%.%__BuildArch.%__BuildType%\ +:: __IntermediatesDir +:: __PackagesBinDir -- default: %__BinDir%\.nuget +:: +:: Thus, these variables are not simply internal to this script! + +:: Set the default arguments for build +set __BuildArch=x64 +set __BuildType=Debug +set __BuildOS=Windows_NT + +set "__ProjectDir=%~dp0" +:: remove trailing slash +if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%" +set "__RepoRootDir=%__ProjectDir%\..\.." + +set "__RootBinDir=%__RepoRootDir%\artifacts" +set "__LogsDir=%__RootBinDir%\log" + +set __BuildArchX64=0 +set __BuildArchX86=0 +set __BuildArchArm=0 +set __BuildArchArm64=0 + +set __BuildTypeDebug=0 +set __BuildTypeChecked=0 +set __BuildTypeRelease=0 + +set __PgoInstrument=0 +set __IbcTuning= + +REM __PassThroughArgs is a set of things that will be passed through to nested calls to build.cmd +REM when using "all". +set __PassThroughArgs= + +set "__args= %*" +set processedArgs= +set __CrossgenAltJit= +set __CrossArch= + +:Arg_Loop +if "%1" == "" goto ArgsDone + +if /i "%1" == "/?" goto Usage +if /i "%1" == "-?" goto Usage +if /i "%1" == "/h" goto Usage +if /i "%1" == "-h" goto Usage +if /i "%1" == "/help" goto Usage +if /i "%1" == "-help" goto Usage +if /i "%1" == "--help" goto Usage + +if /i "%1" == "-x64" (set __BuildArchX64=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-x86" (set __BuildArchX86=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-arm" (set __BuildArchArm=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-arm64" (set __BuildArchArm64=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +if /i "%1" == "-debug" (set __BuildTypeDebug=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-checked" (set __BuildTypeChecked=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-release" (set __BuildTypeRelease=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +if /i "%1" == "-ci" (set __ErrMsgPrefix=##vso[task.logissue type=error]&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +REM All arguments after this point will be passed through directly to build.cmd on nested invocations +REM using the "all" argument, and must be added to the __PassThroughArgs variable. +if [!__PassThroughArgs!]==[] ( + set __PassThroughArgs=%1 +) else ( + set __PassThroughArgs=%__PassThroughArgs% %1 +) +if /i "%1" == "-ibcinstrument" (set __IbcTuning=/Tuning&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-pgoinstrument" (set __PgoInstrument=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-crossgenaltjit" (set __CrossgenAltJit=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) +if /i "%1" == "--" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +:ArgsDone + +set /A __TotalSpecifiedBuildArch=__BuildArchX64 + __BuildArchX86 + __BuildArchArm + __BuildArchArm64 +if %__TotalSpecifiedBuildArch% GTR 1 ( + echo Error: more than one build architecture specified. + goto Usage +) + +if %__BuildArchX64%==1 set __BuildArch=x64 +if %__BuildArchX86%==1 set __BuildArch=x86 +if %__BuildArchArm%==1 ( + set __BuildArch=arm + set __CrossArch=x86 +) +if %__BuildArchArm64%==1 ( + set __BuildArch=arm64 + set __CrossArch=x64 +) + +set /A __TotalSpecifiedBuildType=__BuildTypeDebug + __BuildTypeChecked + __BuildTypeRelease +if %__TotalSpecifiedBuildType% GTR 1 ( + echo Error: more than one build type specified. + goto Usage +) + +if %__BuildTypeDebug%==1 set __BuildType=Debug +if %__BuildTypeChecked%==1 set __BuildType=Checked +if %__BuildTypeRelease%==1 set __BuildType=Release + +set "__BinDir=%__RootBinDir%\bin\coreclr\%__BuildOS%.%__BuildArch%.%__BuildType%" +set "__IntermediatesDir=%__RootBinDir%\obj\coreclr\%__BuildOS%.%__BuildArch%.%__BuildType%" +set "__CrossComponentBinDir=%__BinDir%" + + +if NOT "%__CrossArch%" == "" set __CrossComponentBinDir=%__CrossComponentBinDir%\%__CrossArch% +set "__CrossGenCoreLibLog=%__LogsDir%\CrossgenCoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.log" +set "__CrossgenExe=%__CrossComponentBinDir%\crossgen.exe" + +if not exist "%__BinDir%" md "%__BinDir%" +if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%" +if not exist "%__LogsDir%" md "%__LogsDir%" + + +call "%__ThisScriptDir%"\setup_vs_tools.cmd +if NOT '%ERRORLEVEL%' == '0' goto ExitWithError + +if defined VS160COMNTOOLS ( + set "__VSToolsRoot=%VS160COMNTOOLS%" + set "__VCToolsRoot=%VS160COMNTOOLS%\..\..\VC\Auxiliary\Build" + set __VSVersion=vs2019 +) else if defined VS150COMNTOOLS ( + set "__VSToolsRoot=%VS150COMNTOOLS%" + set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build" + set __VSVersion=vs2017 +) + +REM Need VC native tools environment for the host arch to find Microsoft.DiaSymReader.Native in the Visual Studio install. +set __VCBuildArch=x86_amd64 +if /i "%__BuildArch%" == "x86" ( set __VCBuildArch=x86 ) +if /i "%__BuildArch%" == "arm" ( + set __VCBuildArch=x86_arm +) +if /i "%__BuildArch%" == "arm64" ( + set __VCBuildArch=x86_arm64 +) + +echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! +call "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! +@if defined _echo @echo on + +if not defined VSINSTALLDIR ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: VSINSTALLDIR variable not defined. + goto ExitWithError +) +if not exist "!VSINSTALLDIR!DIA SDK" goto NoDIA + +echo %__MsgPrefix%Generating native image of System.Private.CoreLib for %__BuildOS%.%__BuildArch%.%__BuildType%. Logging to "%__CrossGenCoreLibLog%". +if exist "%__CrossGenCoreLibLog%" del "%__CrossGenCoreLibLog%" + +REM Need VS native tools environment for the **target** arch when running instrumented binaries +if %__PgoInstrument% EQU 1 ( + set __VCExecArch=%__BuildArch% + if /i [%__BuildArch%] == [x64] set __VCExecArch=amd64 + echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCExecArch! + call "%__VCToolsRoot%\vcvarsall.bat" !__VCExecArch! + @if defined _echo @echo on + if NOT !errorlevel! == 0 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: Failed to load native tools environment for !__VCExecArch! + goto ExitWithError + ) + + REM HACK: Workaround for [dotnet/coreclr#13970](https://github.com/dotnet/coreclr/issues/13970) + set __PgoRtPath= + for /f "tokens=*" %%f in ('where pgort*.dll') do ( + if not defined __PgoRtPath set "__PgoRtPath=%%~f" + ) + echo %__MsgPrefix%Copying "!__PgoRtPath!" into "%__BinDir%" + copy /y "!__PgoRtPath!" "%__BinDir%" || ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: copy failed + goto ExitWithError + ) + REM End HACK +) + +if defined __CrossgenAltJit ( + REM Set altjit flags for the crossgen run. + echo %__MsgPrefix%Setting altjit environment variables for %__CrossgenAltJit%. + echo %__MsgPrefix%Setting altjit environment variables for %__CrossgenAltJit%. >> "%__CrossGenCoreLibLog%" + set COMPlus_AltJit=* + set COMPlus_AltJitNgen=* + set COMPlus_AltJitName=%__CrossgenAltJit% + set COMPlus_AltJitAssertOnNYI=1 + set COMPlus_NoGuiOnAssert=1 + set COMPlus_ContinueOnAssert=0 +) + +REM Need diasymreader.dll on your path for /CreatePdb +set PATH=%PATH%;%WinDir%\Microsoft.Net\Framework64\V4.0.30319;%WinDir%\Microsoft.Net\Framework\V4.0.30319 + + for /f "tokens=*" %%f in ('where Microsoft.DiaSymReader.Native.amd64.dll') do ( + echo "%%~f" + ) + +set NEXTCMD="%__CrossgenExe%" /nologo %__IbcTuning% /Platform_Assemblies_Paths "%__BinDir%\IL" /out "%__BinDir%\System.Private.CoreLib.dll" "%__BinDir%\IL\System.Private.CoreLib.dll" +echo %__MsgPrefix%!NEXTCMD! +echo %__MsgPrefix%!NEXTCMD! >> "%__CrossGenCoreLibLog%" +!NEXTCMD! >> "%__CrossGenCoreLibLog%" 2>&1 +if NOT !errorlevel! == 0 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: CrossGen System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog% + REM Put it in the same log, helpful for CI + type %__CrossGenCoreLibLog% + goto ExitWithError +) + +set NEXTCMD="%__CrossgenExe%" /nologo /Platform_Assemblies_Paths "%__BinDir%" /CreatePdb "%__BinDir%\PDB" "%__BinDir%\System.Private.CoreLib.dll" +echo %__MsgPrefix%!NEXTCMD! +echo %__MsgPrefix%!NEXTCMD! >> "%__CrossGenCoreLibLog%" +!NEXTCMD! >> "%__CrossGenCoreLibLog%" 2>&1 +if NOT !errorlevel! == 0 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: CrossGen /CreatePdb System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog% + REM Put it in the same log, helpful for CI + type %__CrossGenCoreLibLog% + goto ExitWithError +) + +REM ========================================================================================= +REM === +REM === All builds complete! +REM === +REM ========================================================================================= + +echo %__MsgPrefix%Crossgenning of System.Private.CoreLib succeeded. Finished at %TIME% +echo %__MsgPrefix%Product binaries are available at !__BinDir! +exit /b 0 + + +REM ========================================================================================= +REM === These two routines are intended for the exit code to propagate to the parent process +REM === Like MSBuild or Powershell. If we directly exit /b 1 from within a if statement in +REM === any of the routines, the exit code is not propagated. +REM ========================================================================================= +:ExitWithError +exit /b 1 + +:ExitWithCode +exit /b !__exitCode! + +:NoDIA +echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^ +Did you install all the requirements for building on Windows, including the "Desktop Development with C++" workload? ^ +Please see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/windows-requirements.md ^ +Another possibility is that you have a parallel installation of Visual Studio and the DIA SDK is there. In this case it ^ +may help to copy its "DIA SDK" folder into "%VSINSTALLDIR%" manually, then try again. +exit /b 1 diff --git a/src/coreclr/crossgen-corelib.proj b/src/coreclr/crossgen-corelib.proj new file mode 100644 index 0000000000000..08e7e52b1201d --- /dev/null +++ b/src/coreclr/crossgen-corelib.proj @@ -0,0 +1,23 @@ + + + + + + + <_CoreClrBuildArg Condition="'$(TargetArchitecture)' != ''" Include="-$(TargetArchitecture)" /> + <_CoreClrBuildArg Include="-$(Configuration.ToLower())" /> + + + + <_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">crossgen-corelib.cmd + <_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">crossgen-corelib.sh + + + + + + + + + + diff --git a/src/coreclr/crossgen-corelib.sh b/src/coreclr/crossgen-corelib.sh new file mode 100755 index 0000000000000..46bed1f6bb38f --- /dev/null +++ b/src/coreclr/crossgen-corelib.sh @@ -0,0 +1,150 @@ +#!/usr/bin/env bash + +usage_list+=("-ibcinstrument: generate IBC-tuning-enabled native images when invoking crossgen.") +usage_list+=("-partialngen: build CoreLib as PartialNGen.") +usage_list+=("-pgoinstrument: generate instrumented code for profile guided optimization enabled binaries.") + +setup_dirs_local() +{ + setup_dirs + + mkdir -p "$__LogsDir" +} + +build_CoreLib_ni() +{ + local __CrossGenExec=$1 + local __CoreLibILDir=$2 + + if [[ "$__PartialNgen" == 1 ]]; then + COMPlus_PartialNGen=1 + export COMPlus_PartialNGen + fi + + if [[ -e "$__CrossGenCoreLibLog" ]]; then + rm "$__CrossGenCoreLibLog" + fi + echo "Generating native image of System.Private.CoreLib.dll for $__BuildOS.$__BuildArch.$__BuildType. Logging to \"$__CrossGenCoreLibLog\"." + echo "$__CrossGenExec /Platform_Assemblies_Paths $__CoreLibILDir $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__CoreLibILDir/System.Private.CoreLib.dll" + "$__CrossGenExec" /nologo /Platform_Assemblies_Paths $__CoreLibILDir $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__CoreLibILDir/System.Private.CoreLib.dll >> $__CrossGenCoreLibLog 2>&1 + local exit_code="$?" + if [[ "$exit_code" != 0 ]]; then + echo "${__ErrMsgPrefix}Failed to generate native image for System.Private.CoreLib. Refer to $__CrossGenCoreLibLog" + exit "$exit_code" + fi + + if [[ "$__BuildOS" == "Linux" ]]; then + echo "Generating symbol file for System.Private.CoreLib.dll" + echo "$__CrossGenExec /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll" + "$__CrossGenExec" /nologo /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll >> $__CrossGenCoreLibLog 2>&1 + local exit_code="$?" + if [[ "$exit_code" != 0 ]]; then + echo "${__ErrMsgPrefix}Failed to generate symbol file for System.Private.CoreLib. Refer to $__CrossGenCoreLibLog" + exit "$exit_code" + fi + fi +} + +handle_arguments_local() { + case "$1" in + + ibcinstrument|-ibcinstrument) + __IbcTuning="/Tuning" + ;; + + partialngen|-partialngen) + __PartialNgen=1 + ;; + + pgoinstrument|-pgoinstrument) + __PgoInstrument=1 + ;; + + *) + __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1" + ;; + esac +} + +echo "Commencing Crossgenning System.Private.CoreLib" + +# Argument types supported by this script: +# +# Build architecture - valid values are: x64, ARM. +# Build Type - valid values are: Debug, Checked, Release +# +# Set the default arguments for build + +# Obtain the location of the bash script to figure out where the root of the repo is. +__ProjectRoot="$(cd "$(dirname "$0")"; pwd -P)" +__RepoRootDir="$(cd "$__ProjectRoot"/../..; pwd -P)" + +__BuildArch= +__BuildType=Debug + +__CrossBuild=0 +__IbcTuning="" +__PartialNgen=0 +__PgoInstrument=0 +__RootBinDir="$__RepoRootDir/artifacts" +__SkipMSCorLib=0 +__SkipRestore="" +__StaticAnalyzer=0 +__UnprocessedBuildArgs= + +source "$__ProjectRoot"/_build-commons.sh + +if [[ "${__BuildArch}" != "${__HostArch}" ]]; then + __CrossBuild=1 +fi + +# Set dependent variables +__LogsDir="$__RootBinDir/log/$__BuildType" + +# Set the remaining variables based upon the determined build configuration +__BinDir="$__RootBinDir/bin/coreclr/$__BuildOS.$__BuildArch.$__BuildType" +__CrossComponentBinDir="$__BinDir" + +__CrossArch="$__HostArch" +if [[ "$__CrossBuild" == 1 ]]; then + __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch" +fi +__CrossGenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$__BuildArch.$__BuildType.log" + +# Crossgen System.Private.CoreLib + +__CoreLibILDir=$__BinDir/IL + +setup_dirs_local + +# The cross build generates a crossgen with the target architecture. +if [[ "$__CrossBuild" == 0 ]]; then + # The architecture of host pc must be same architecture with target. + if [[ "$__HostArch" == "$__BuildArch" ]]; then + build_CoreLib_ni "$__BinDir/crossgen" "$__CoreLibILDir" + elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then + build_CoreLib_ni "$__BinDir/crossgen" "$__CoreLibILDir" + elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then + build_CoreLib_ni "$__BinDir/crossgen" "$__CoreLibILDir" + else + exit 1 + fi +else + if [[ ( "$__CrossArch" == "x86" ) && ( "$__BuildArch" == "arm" ) ]]; then + build_CoreLib_ni "$__CrossComponentBinDir/crossgen" "$__CoreLibILDir" + elif [[ ( "$__CrossArch" == "x64" ) && ( "$__BuildArch" == "arm" ) ]]; then + build_CoreLib_ni "$__CrossComponentBinDir/crossgen" "$__CoreLibILDir" + elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "arm64" ) ]]; then + build_CoreLib_ni "$__CrossComponentBinDir/crossgen" "$__CoreLibILDir" + else + # Crossgen not performed, so treat the IL version as the final version + cp "$__CoreLibILDir"/System.Private.CoreLib.dll "$__BinDir"/System.Private.CoreLib.dll + fi +fi + + +# Build complete + +echo "Native System.Private.CoreLib generated." +echo "Product binaries are available at $__BinDir" +exit 0 diff --git a/src/coreclr/definitionsconsistencycheck.cmake b/src/coreclr/definitionsconsistencycheck.cmake deleted file mode 100644 index 51a70f72096b1..0000000000000 --- a/src/coreclr/definitionsconsistencycheck.cmake +++ /dev/null @@ -1,11 +0,0 @@ -get_directory_property( DirDefs COMPILE_DEFINITIONS ) - -# Reset the definition file -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmake.definitions "") -foreach( d ${DirDefs} ) - if($ENV{VERBOSE}) - message( STATUS "Compiler Definition: " ${d} ) - endif($ENV{VERBOSE}) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cmake.definitions ${d}) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cmake.definitions "\n") -endforeach() diff --git a/src/coreclr/dir.common.props b/src/coreclr/dir.common.props index 90ecca279182f..7185a3c6ce545 100644 --- a/src/coreclr/dir.common.props +++ b/src/coreclr/dir.common.props @@ -11,19 +11,21 @@ $(__BuildArch) - x64 - x64 + $(TargetArchitecture) + x64 + x64 $(__BuildType) - Debug - Debug - Release - Checked + Debug + Debug + Release + Checked $(__BuildOS) - Windows_NT - Linux - OSX + $(OSGroup) + Windows_NT + Linux + OSX <__BuildOS>$(BuildOS) diff --git a/src/coreclr/coreclr.proj b/src/coreclr/runtime.proj similarity index 88% rename from src/coreclr/coreclr.proj rename to src/coreclr/runtime.proj index be752aaabf55d..e36aea3ea2f7b 100644 --- a/src/coreclr/coreclr.proj +++ b/src/coreclr/runtime.proj @@ -4,7 +4,6 @@ - <_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows))" Include="-skiptests" /> <_CoreClrBuildArg Condition="'$(TargetArchitecture)' != ''" Include="-$(TargetArchitecture)" /> <_CoreClrBuildArg Include="$(CMakeArgs)" /> <_CoreClrBuildArg Include="-$(Configuration.ToLower())" /> @@ -13,12 +12,13 @@ <_CoreClrBuildArg Condition="'$(CrossBuild)' == 'true'" Include="-cross" /> <_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and ('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'x64') and '$(Configuration)' == 'Release'" Include="-enforcepgo" /> <_CoreClrBuildArg Condition="!$([MSBuild]::IsOsPlatform(Windows)) and '$(Configuration)' == 'Release'" Include="-stripsymbols" /> - <_CoreClrBuildArg Condition="'$(OfficialBuildId)' != ''" Include="-officialbuildid=$(OfficialBuildId)" /> + <_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(CrossDac)' != ''" Include="-$(CrossDac)dac" /> + <_CoreClrBuildArg Condition="'$(OfficialBuildId)' != ''" Include="/p:OfficialBuildId=$(OfficialBuildId)" /> - <_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">build.cmd - <_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">build.sh + <_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">build-runtime.cmd + <_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">build-runtime.sh diff --git a/src/coreclr/src/.nuget/Directory.Build.props b/src/coreclr/src/.nuget/Directory.Build.props index 75092cad12ddc..adaa4b2e06b73 100644 --- a/src/coreclr/src/.nuget/Directory.Build.props +++ b/src/coreclr/src/.nuget/Directory.Build.props @@ -15,7 +15,7 @@ <_parseDistroRid>$(__DistroRid) <_parseDistroRid Condition="'$(_parseDistroRid)' == '' and '$(__BuildOS)' == 'OSX'">osx.10.12-x64 - <_distroRidIndex>$(_parseDistroRid.IndexOfAny("-")) + <_distroRidIndex>$(_parseDistroRid.LastIndexOfAny("-")) <_archRidIndex>$([MSBuild]::Add($(_distroRidIndex), 1)) $(_parseDistroRid.SubString(0, $(_distroRidIndex))) win10 @@ -108,6 +108,18 @@ linux-$(ArchGroup) + + + $(OSRid)-$(ArchGroup) + + linux-musl-$(ArchGroup) + + + + + $(RuntimeOS)-$(ArchGroup) + + $(RuntimeOS)-$(ArchGroup) diff --git a/src/coreclr/src/Directory.Build.props b/src/coreclr/src/Directory.Build.props index b3b03d3b20cd6..dcaf5f8444372 100644 --- a/src/coreclr/src/Directory.Build.props +++ b/src/coreclr/src/Directory.Build.props @@ -1,4 +1,8 @@ + + <__BuildType>$(Configuration) + + diff --git a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj index 0fcdf4fefaeef..95b19a9ce28fe 100644 --- a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -13,7 +13,7 @@ true - $(BinDir)IL/ + $(BinDir)/IL/ Debug;Release;Checked x64;x86;arm;arm64 @@ -31,7 +31,6 @@ - $(BuildType) $(BuildArch) arm true @@ -320,16 +319,6 @@ - - - - - - src\System\Diagnostics\Eventing\Generated\NativeRuntimeEventSource.cs - @@ -427,24 +416,13 @@ - - true - - - - - - $(IntermediateOutputPath)\cmake.definitions - - - Windows_NT true - + @@ -460,4 +438,36 @@ + + + + + + + src\System\Diagnostics\Eventing\Generated\NativeRuntimeEventSource.cs + + + + + + + + + <_PythonWarningParameter>-Wall + <_PythonWarningParameter Condition="'$(MSBuildTreatWarningsAsErrors)' == 'true'">$(_PythonWarningParameter) -Werror + <_EventingSourceFileDirectory>%(EventingSourceFile.RootDir)%(EventingSourceFile.Directory) + <_EventingSourceFileDirectory Condition="HasTrailingSlash('$(_EventingSourceFileDirectory)')">$(_EventingSourceFileDirectory.TrimEnd('\')) + + + + + + + + + diff --git a/src/coreclr/src/scripts/check-definitions.py b/src/coreclr/src/scripts/check-definitions.py deleted file mode 100644 index 24e75b4ddbe32..0000000000000 --- a/src/coreclr/src/scripts/check-definitions.py +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/env python -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. -# -# check-definitions.py -# This script checks the consistency between compiler definitions -# of the native part of CoreCLR and managed part (mscorlib.dll) of -# CoreCLR -# -# Usage: -# $ ./check-definitions.py Definition_File String_of_Definitions [String_of_Ignored_Definitions] -# -# Definition_File: the filename of a file containing the list of -# compiler definitions of CMAKE, seperated by line. -# (Mandatory) -# String_of_Definitions: the list of managed code compiler -# definitions, seperated by semicolon without spaces. -# (Mandatory) -# String_of_Ignored_Definitions: the list of compiler definitions -# to be suppressed from emitting warnings, seperated by semicolon without spaces. -# (Optional) -# -# (c) 2016 MyungJoo Ham - -from __future__ import print_function - -import sys -import re -import os - -debug = 0 - -# For the native part, return the sorted definition array. -def loadDefinitionFile(filename): - result = [] - - try: - with open(filename, 'r') as f: - for line in f: - line = line.strip() - if line: - result.append(line) - except IOError: - # If cmake was not used, this script won't work, and that's ok - sys.exit(0) - - result = sorted(result) - return result - - -# For the managed part, return the sorted definition array. -def loadDefinitionString(string): - splitted = string.split(';') - result = [] - for line in splitted: - theLine = line.strip() - if (len(theLine) > 0): - result.append(theLine) - - result = sorted(result) - return result - - -def getDiff(arrNative, arrManaged): - result = [[], []] - iF = 0 # From file (native) - nF = len(arrNative) - - iS = 0 # From string (managed) - nS = len(arrManaged) - - while (iS < nS) and (iF < nF): - if (arrNative[iF] == arrManaged[iS]): - if (debug == 1): - print("Both have " + arrNative[iF]) - iF = iF + 1 - iS = iS + 1 - elif (arrNative[iF] == (arrManaged[iS] + "=1")): - if (debug == 1): - print("Both have " + arrNative[iF] + "(=1)") - iF = iF + 1 - iS = iS + 1 - elif (arrNative[iF] < arrManaged[iS]): - if (debug == 1): - print("--- Managed Omitted " + arrNative[iF]) - result[1].append(arrNative[iF]) - iF = iF + 1 - elif (arrNative[iF] > arrManaged[iS]): - if (debug == 1): - print("+++ Managed Added " + arrManaged[iS]) - result[0].append(arrManaged[iS]) - iS = iS + 1 - - if (iS < nS): - while iS < nS: - if (debug == 1): - print("+++ Managed Added " + arrManaged[iS]) - result[0].append(arrManaged[iS]) - iS = iS + 1 - elif (iF < nF): - while iF < nF: - if (debug == 1): - print("--- Managed Omitted " + arrNative[iF]) - result[1].append(arrNative[iF]) - iF = iF + 1 - return result - - -def printPotentiallyCritical(arrDefinitions, referencedFilename, arrIgnore): - content = None - with open(referencedFilename, 'r') as f: - content = f.read() - - for keyword in arrDefinitions: - skip = 0 - - if (keyword[-2:] == "=1"): - key = keyword[:-2] - else: - key = keyword - - if re.search("[^\\w]"+key+"[^\\w]", content): - for ign in arrIgnore: - if key == ign: - skip = 1 - break - if skip == 0: - print(keyword) - -# MAIN SCRIPT -if len(sys.argv) < 3: - print("\nUsage:") - print("$ check-definitions.py [ProjectDir] [Definition file] [String of definitions]") - print(" Definition file contains the list of cmake (native) compiler definitions") - print(" seperated by line.") - print(" String of definitions contains the list of csproj (managed) definitions") - print(" seperated by semicolons.") - sys.exit(-1) - -projectDir = sys.argv[1] -filename = sys.argv[2] -string = sys.argv[3] - -arrayNative = loadDefinitionFile(filename) -arrayManaged = loadDefinitionString(string) -arrayIgnore = [] - -if len(sys.argv) > 4: - arrayIgnore = loadDefinitionString(sys.argv[4]) - -arrays = getDiff(arrayNative, arrayManaged) -# arrays[0] = array of added in managed -# arrays[1] = array of omitted in managed (added in native) - -print("Potentially Dangerous Compiler Definitions in clrdefinitions.cmake (omitted in native build):") -printPotentiallyCritical(arrays[0], os.path.join(projectDir, "clrdefinitions.cmake"), arrayIgnore) - -print("Potentially Dangerous Compiler Definitions in clr.featuredefines.props (omitted in managed build):") -printPotentiallyCritical(arrays[1], os.path.join(projectDir, "clr.featuredefines.props"), arrayIgnore) - -print("Definition Check Completed.") - diff --git a/src/coreclr/src/tools/Directory.Build.props b/src/coreclr/src/tools/Directory.Build.props index a98f9a1a438a0..9f380175d06a7 100644 --- a/src/coreclr/src/tools/Directory.Build.props +++ b/src/coreclr/src/tools/Directory.Build.props @@ -3,4 +3,4 @@ false - \ No newline at end of file + diff --git a/src/coreclr/src/tools/ReadyToRun.SuperIlc/CpaotRunner.cs b/src/coreclr/src/tools/ReadyToRun.SuperIlc/CpaotRunner.cs index b2f22c5af1176..b61bab44d937e 100644 --- a/src/coreclr/src/tools/ReadyToRun.SuperIlc/CpaotRunner.cs +++ b/src/coreclr/src/tools/ReadyToRun.SuperIlc/CpaotRunner.cs @@ -17,9 +17,12 @@ class CpaotRunner : CompilerRunner { public override CompilerIndex Index => CompilerIndex.CPAOT; - protected override string CompilerRelativePath => "crossgen2"; + // Crossgen2 runs on top of corerun. + protected override string CompilerRelativePath => ""; - protected override string CompilerFileName => "crossgen2".AppendOSExeSuffix(); + protected override string CompilerFileName => "corerun".AppendOSExeSuffix(); + + private string Crossgen2Path => Path.Combine(_options.CoreRootDirectory.FullName, "crossgen2", "crossgen2.dll"); private List _resolvedReferences; @@ -31,6 +34,13 @@ public CpaotRunner(BuildOptions options, IEnumerable referencePaths) options.DegreeOfParallelism = 2; } + public override ProcessParameters CompilationProcess(string outputFileName, IEnumerable inputAssemblyFileNames) + { + ProcessParameters processParameters = base.CompilationProcess(outputFileName, inputAssemblyFileNames); + processParameters.Arguments = $"{Crossgen2Path} {processParameters.Arguments}"; + return processParameters; + } + protected override ProcessParameters ExecutionProcess(IEnumerable modules, IEnumerable folders, bool noEtw) { ProcessParameters processParameters = base.ExecutionProcess(modules, folders, noEtw); diff --git a/src/coreclr/src/tools/crossgen2/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj b/src/coreclr/src/tools/crossgen2/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj index 643455201ebbb..39f7780ebfc88 100644 --- a/src/coreclr/src/tools/crossgen2/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj +++ b/src/coreclr/src/tools/crossgen2/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj @@ -6,7 +6,7 @@ netstandard1.3 false x64;x86 - $(BuildArch) + $(ArchGroup) false false - + diff --git a/src/coreclr/src/tools/crossgen2/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj b/src/coreclr/src/tools/crossgen2/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj index b91aed5979a6e..52d5a7509dcc8 100644 --- a/src/coreclr/src/tools/crossgen2/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj +++ b/src/coreclr/src/tools/crossgen2/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj @@ -7,7 +7,7 @@ netstandard1.3 false x64;x86 - $(BuildArch) + $(ArchGroup) false - $(BinDir)/crossgen2 - false + $(BinDir)/crossgen2 false false + linux-x64;linux-musl-x64;win-x64 @@ -42,4 +38,36 @@ 0.3.0-alpha.19525.2 + + + lib + .so + .dylib + + + + .dll + + + + + + + + + + + + + + + diff --git a/src/coreclr/tests/helixpublishwitharcade.proj b/src/coreclr/tests/helixpublishwitharcade.proj index f68924f3b8d31..020c8f130d704 100644 --- a/src/coreclr/tests/helixpublishwitharcade.proj +++ b/src/coreclr/tests/helixpublishwitharcade.proj @@ -161,8 +161,6 @@ - - $(PublishTestResults) false diff --git a/src/coreclr/tests/setup-stress-dependencies.sh b/src/coreclr/tests/setup-stress-dependencies.sh index 8141123fc63dd..c747826732b79 100755 --- a/src/coreclr/tests/setup-stress-dependencies.sh +++ b/src/coreclr/tests/setup-stress-dependencies.sh @@ -31,7 +31,7 @@ function exit_with_error { if [ ! -z "$2" ]; then echo $2 fi - + exit $errorCode } @@ -180,7 +180,7 @@ fi CoreDisToolsPackagePathOutputFile="${scriptDir}/../../../artifacts/obj/coreclr/${__BuildOS}.x64/optdatapath.txt" -bash -c -x "$dotnet msbuild $csprojPath /t:DumpCoreDisToolsPackagePath /p:CoreDisToolsPackagePathOutputFile=\"$CoreDisToolsPackagePathOutputFile\" /p:RuntimeIdentifier=\"$rid\" /bl" +bash -c -x "$dotnet msbuild $csprojPath /t:DumpCoreDisToolsPackagePath /p:CoreDisToolsPackagePathOutputFile=\"$CoreDisToolsPackagePathOutputFile\" /p:RuntimeIdentifier=\"$rid\"" if [ $? -ne 0 ] then exit_with_error 1 "Failed to find the path to CoreDisTools." diff --git a/src/coreclr/tests/src/CLRTest.CrossGen.targets b/src/coreclr/tests/src/CLRTest.CrossGen.targets index d099c9e992524..5c9ba05e7147f 100644 --- a/src/coreclr/tests/src/CLRTest.CrossGen.targets +++ b/src/coreclr/tests/src/CLRTest.CrossGen.targets @@ -11,7 +11,7 @@ This file contains the logic for providing Execution Script generation. WARNING: When setting properties based on their current state (for example: - + + fi + ReleaseLock + fi +fi + ]]> $(BashCLRTestPreCommands);$(CrossgenBashScript) @@ -93,13 +93,12 @@ fi - @@ -152,5 +151,5 @@ if defined RunCrossGen2 ( - - \ No newline at end of file + + diff --git a/src/coreclr/tests/src/readytorun/crossgen2/crossgen2smoke.csproj b/src/coreclr/tests/src/readytorun/crossgen2/crossgen2smoke.csproj index 0116d116df0db..8a98db7f66eeb 100644 --- a/src/coreclr/tests/src/readytorun/crossgen2/crossgen2smoke.csproj +++ b/src/coreclr/tests/src/readytorun/crossgen2/crossgen2smoke.csproj @@ -20,11 +20,11 @@ diff --git a/src/coreclr/tests/src/readytorun/determinism/crossgen2determinism.csproj b/src/coreclr/tests/src/readytorun/determinism/crossgen2determinism.csproj index c5c2f35a5c170..10b4f8610064c 100644 --- a/src/coreclr/tests/src/readytorun/determinism/crossgen2determinism.csproj +++ b/src/coreclr/tests/src/readytorun/determinism/crossgen2determinism.csproj @@ -18,16 +18,16 @@ diff --git a/src/installer/pkg/projects/netcoreapp/pkg/Directory.Build.props b/src/installer/pkg/projects/netcoreapp/pkg/Directory.Build.props index d60af6f2d5b2e..a34488f1be6c3 100644 --- a/src/installer/pkg/projects/netcoreapp/pkg/Directory.Build.props +++ b/src/installer/pkg/projects/netcoreapp/pkg/Directory.Build.props @@ -15,7 +15,6 @@ RuntimeIdentifier=$(PackageTargetRuntime) diff --git a/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Crossgen2.pkgproj b/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Crossgen2.pkgproj index 1938be1e126cc..ce1ab049241bc 100644 --- a/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Crossgen2.pkgproj +++ b/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Crossgen2.pkgproj @@ -29,13 +29,63 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - tools - - + + + + + + + tools + + + +