From d01837b51cc7e159c4a3cdd84ab5be82e295e8cf Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 13 Jul 2021 10:42:26 -0700 Subject: [PATCH] Do PGO restore as part of PGO path lookup. Remove one MSBuild process invocation from our CoreCLR build scripts. --- src/coreclr/build-runtime.cmd | 27 +++++++-------------------- src/coreclr/build-runtime.sh | 21 +++++++-------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 731c255468e831..ab805f370aa209 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -246,10 +246,6 @@ if NOT "%__BuildType%"=="Release" ( set __PgoOptimize=0 ) -if %__PgoOptimize%==0 ( - set __RestoreOptData=0 -) - set "__BinDir=%__RootBinDir%\bin\coreclr\%__TargetOS%.%__BuildArch%.%__BuildType%" set "__IntermediatesDir=%__RootBinDir%\obj\coreclr\%__TargetOS%.%__BuildArch%.%__BuildType%" set "__LogsDir=%__RootBinDir%\log\!__BuildType!" @@ -335,29 +331,20 @@ REM === Restore optimization profile data REM === REM ========================================================================================= -set OptDataProjectFilePath=%__ProjectDir%\.nuget\optdata\optdata.csproj -if %__RestoreOptData% EQU 1 ( - echo %__MsgPrefix%Restoring the OptimizationData Package - set "__BinLog=\"%__LogsDir%\OptRestore_%__TargetOS%__%__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 ( - set __exitCode=!errorlevel! - echo %__ErrMsgPrefix%%__MsgPrefix%Error: Failed to restore the optimization data package. - goto ExitWithCode - ) -) set __PgoOptDataPath= if %__PgoOptimize% EQU 1 ( + set OptDataProjectFilePath=%__ProjectDir%\.nuget\optdata\optdata.csproj + set __OptDataRestoreArg= + if %__RestoreOptData% EQU 1 ( + set __OptDataRestoreArg=/restore + ) set PgoDataPackagePathOutputFile=%__IntermediatesDir%\optdatapath.txt set "__BinLog=\"%__LogsDir%\PgoVersionRead_%__TargetOS%__%__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^ - /p:PgoDataPackagePathOutputFile="!PgoDataPackagePathOutputFile!"^ + "!OptDataProjectFilePath!" /t:DumpPgoDataPackagePath^ + /p:PgoDataPackagePathOutputFile="!PgoDataPackagePathOutputFile!" !__OptDataRestoreArg!^ %__CommonMSBuildArgs% %__UnprocessedBuildArgs% /bl:!__BinLog! if not !errorlevel! == 0 ( diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index 0b39613aac369e..1d9881f281b183 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -39,27 +39,20 @@ setup_dirs_local() restore_optdata() { local OptDataProjectFilePath="$__ProjectRoot/.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 \ - -bl:"$__LogsDir/OptRestore_$__ConfigTriplet.binlog" \ - $__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" + local RestoreArg="" + + if [[ "$__SkipRestoreOptData" == "0" ]]; then + RestoreArg="/restore" + fi + # Writes into ${PgoDataPackagePathOutputFile} - "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs $OptDataProjectFilePath /t:DumpPgoDataPackagePath \ + "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs $OptDataProjectFilePath $RestoreArg /t:DumpPgoDataPackagePath \ ${__CommonMSBuildArgs} /p:PgoDataPackagePathOutputFile=${PgoDataPackagePathOutputFile} \ -bl:"$__LogsDir/PgoVersionRead_$__ConfigTriplet.binlog" > /dev/null 2>&1 local exit_code="$?"