if defined VisualStudioVersion (
if not defined __VSVersion echo %__MsgPrefix%Detected Visual Studio %VisualStudioVersion% developer command ^prompt environment
goto :Run
-)
+)
-echo %__MsgPrefix%"Searching for Visual Studio 2017 or 2015 installation"
+echo %__MsgPrefix%Searching ^for Visual Studio 2017 or 2015 installation
set _VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if exist %_VSWHERE% (
for /f "usebackq tokens=*" %%i in (`%_VSWHERE% -latest -prerelease -property installationPath`) do set _VSCOMNTOOLS=%%i\Common7\Tools
:Run
+REM Make the work-around to a bug in the microsoft.dotnet.buildtools.coreclr package until it is fixed.
+reg query HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{3BFCEA48-620F-4B6B-81F7-B9AF75454C7D}\InprocServer32 > NUL: 2>&1
+if NOT '%ERRORLEVEL%' == '0' (
+ echo.
+ echo.**********************************************************************************
+ echo.Error: We have detected that the msdia120.dll is not registered.
+ echo.This is necessary for the build to complete without a Class_Not_Registered error.
+ echo.
+ echo.You can fix this by
+ echo. 1. Launching the "Developer Command Prompt for VS2017" with Administrative privileges
+ echo. 2. Running regsvr32.exe "%%VSINSTALLDIR%%\Common7\IDE\msdia120.dll"
+ echo.
+ echo.This will only need to be done once for the lifetime of the machine.
+ echo.For more details see: https://github.com/dotnet/coreclr/issues/11305
+ exit /b 1
+)
+
if defined VS150COMNTOOLS (
set "__VSToolsRoot=%VS150COMNTOOLS%"
set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build"
if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
set "__ProjectFilesDir=%__ProjectDir%"
set "__SourceDir=%__ProjectDir%\src"
-set "__PackagesDir=%__ProjectDir%\packages"
+set "__PackagesDir=%DotNetRestorePackagesPath%"
+if [%__PackagesDir%]==[] set "__PackagesDir=%__ProjectDir%\packages"
set "__RootBinDir=%__ProjectDir%\bin"
set "__LogsDir=%__RootBinDir%\Logs"
set "__PgoOptDataVersion="
set __BuildPackages=1
set __BuildNativeCoreLib=1
set __RestoreOptData=1
+set __GenerateLayout=0
+set __CrossgenAltJit=
+
+@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" == "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 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!]==[] (
if /i "%1" == "-nopgooptimize" (set __PgoOptimize=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "-ibcinstrument" (set __IbcTuning=/Tuning&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "-toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
+if /i "%1" == "-crossgenaltjit" (set __CrossgenAltJit=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
REM TODO these are deprecated remove them eventually
REM don't add more, use the - syntax instead
if /i "%1" == "skiptests" (set __BuildTests=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "skipbuildpackages" (set __BuildPackages=0&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" == "generatelayout" (set __GenerateLayout=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "usenmakemakefiles" (set __NMakeMakefiles=1&set __ConfigureOnly=1&set __BuildNative=1&set __BuildNativeCoreLib=0&set __BuildCoreLib=0&set __BuildTests=0&set __BuildPackages=0&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" == "ibcinstrument" (set __IbcTuning=/Tuning&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
-@REM The following can be deleted once the CI system that passes it is updated to not pass it.
-if /i "%1" == "altjitcrossgen" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
-
if [!processedArgs!]==[] (
set __UnprocessedBuildArgs=%__args%
) else (
:ArgsDone
+@REM Special handling for -priority=N argument.
+if defined __Priority (
+ if defined __PassThroughArgs (
+ set __PassThroughArgs=%__PassThroughArgs% -priority=%__Priority%
+ ) else (
+ set __PassThroughArgs=-priority=%__Priority%
+ )
+ set __UnprocessedBuildArgs=!__UnprocessedBuildArgs! -priority=%__Priority%
+)
+
if %__PgoOptimize%==0 set __RestoreOptData=0
if defined __BuildAll goto BuildAll
)
)
+REM Determine if this is a cross-arch build
+
+if /i "%__BuildArch%"=="arm64" (
+ set __DoCrossArchBuild=1
+ )
+
+if /i "%__BuildArch%"=="arm" (
+ set __DoCrossArchBuild=1
+ )
+
:: Set the remaining variables based upon the determined build configuration
set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__IntermediatesDir=%__RootBinDir%\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
:: Eval the output from probe-win1.ps1
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__SourceDir%\pal\tools\probe-win.ps1"""') do %%a
-REM NumberOfEnabledCore is an WMI property providing number of enabled cores on machine
-REM processor(s) and later is used to set optimal level of CL parallelism during native build step
+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
for /f "tokens=*" %%I in (
REM =========================================================================================
REM ===
+REM === Generate source files for eventing
+REM ===
+REM =========================================================================================
+
+set __IntermediatesIncDir=%__IntermediatesDir%\src\inc
+set __IntermediatesEventingDir=%__IntermediatesDir%\eventing
+
+REM Find python and set it to the variable PYTHON
+echo import sys; sys.stdout.write(sys.executable) | (py -3 || py -2 || python3 || python2 || python) > %TEMP%\pythonlocation.txt 2> NUL
+set /p PYTHON=<%TEMP%\pythonlocation.txt
+
+if /i "%__BuildNative%"=="1" (
+ if NOT DEFINED PYTHON (
+ echo %__MsgPrefix%Error: Could not find a python installation
+ exit /b 1
+ )
+
+ echo %__MsgPrefix%Laying out dynamically generated files consumed by the native build system
+ echo %__MsgPrefix%Laying out dynamically generated Event test files and etmdummy stub functions
+ "!PYTHON!" -B -Wall %__SourceDir%\scripts\genEventing.py --inc %__IntermediatesIncDir% --dummy %__IntermediatesIncDir%\etmdummy.h --man %__SourceDir%\vm\ClrEtwAll.man --nonextern --noxplatheader|| exit /b 1
+
+ echo %__MsgPrefix%Laying out dynamically generated EventPipe Implementation
+ "!PYTHON!" -B -Wall %__SourceDir%\scripts\genEventPipe.py --man %__SourceDir%\vm\ClrEtwAll.man --intermediate %__IntermediatesEventingDir%\eventpipe --nonextern || exit /b 1
+
+ echo %__MsgPrefix%Laying out ETW event logging interface
+ "!PYTHON!" -B -Wall %__SourceDir%\scripts\genEtwProvider.py --man %__SourceDir%\vm\ClrEtwAll.man --intermediate %__IntermediatesIncDir% --exc %__SourceDir%\vm\ClrEtwAllMeta.lst || exit /b 1
+)
+
+if /i "%__DoCrossArchBuild%"=="1" (
+ if NOT DEFINED PYTHON (
+ echo %__MsgPrefix%Error: Could not find a python installation
+ exit /b 1
+ )
+
+ set __CrossCompIntermediatesIncDir=%__CrossCompIntermediatesDir%\src\inc
+ set __CrossCompIntermediatesEventingDir=%__CrossCompIntermediatesDir%\eventing
+
+ echo %__MsgPrefix%Laying out dynamically generated files consumed by the crossarch build system
+ echo %__MsgPrefix%Laying out dynamically generated Event test files and etmdummy stub functions
+ "!PYTHON!" -B -Wall %__SourceDir%\scripts\genEventing.py --inc !__CrossCompIntermediatesIncDir! --dummy !__CrossCompIntermediatesIncDir!\etmdummy.h --man %__SourceDir%\vm\ClrEtwAll.man --nonextern || exit /b 1
+
+ echo %__MsgPrefix%Laying out dynamically generated EventPipe Implementation
+ "!PYTHON!" -B -Wall %__SourceDir%\scripts\genEventPipe.py --man %__SourceDir%\vm\ClrEtwAll.man --intermediate !__CrossCompIntermediatesEventingDir!\eventpipe --nonextern || exit /b 1
+
+ echo %__MsgPrefix%Laying out ETW event logging interface
+ "!PYTHON!" -B -Wall %__SourceDir%\scripts\genEtwProvider.py --man %__SourceDir%\vm\ClrEtwAll.man --intermediate !__CrossCompIntermediatesIncDir! --exc %__SourceDir%\vm\ClrEtwAllMeta.lst || exit /b 1
+)
+
+REM =========================================================================================
+REM ===
REM === Build the CLR VM
REM ===
REM =========================================================================================
echo %__MsgPrefix%Commencing build of native components for %__BuildOS%.%__BuildArch%.%__BuildType%
- set nativePlatfromArgs=-platform=%__BuildArch%
- if /i "%__BuildArch%" == "arm64" ( set nativePlatfromArgs=-useEnv )
+ set __NativePlatformArgs=-platform=%__BuildArch%
+ if not "%__ToolsetDir%" == "" ( set __NativePlatformArgs=-useEnv )
- if /i "%__BuildArch%" == "arm64" (
+ if not "%__ToolsetDir%" == "" (
rem arm64 builds currently use private toolset which has not been released yet
REM TODO, remove once the toolset is open.
call :PrivateToolSet
REM Make CMake pick the highest installed version in the 10.0.* range
set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0"
)
+ if /i "%__BuildArch%" == "arm64" (
+ set __VCBuildArch=x86_arm64
+
+ REM Make CMake pick the highest installed version in the 10.0.* range
+ set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0"
+ )
echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch!
call "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch!
set __MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn!
set __MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr!
- @call %__ProjectDir%\run.cmd build -Project=%__IntermediatesDir%\install.vcxproj -MsBuildLog=!__MsbuildLog! -MsBuildWrn=!__MsbuildWrn! -MsBuildErr=!__MsbuildErr! -configuration=%__BuildType% %nativePlatfromArgs% %__RunArgs% -ExtraParameters="/p:ForceImportBeforeCppTargets=%__ProjectDir%/clr.nativebuild.props /m:2" %__UnprocessedBuildArgs%
+ @call %__ProjectDir%\run.cmd build -Project=%__IntermediatesDir%\install.vcxproj -MsBuildLog=!__MsbuildLog! -MsBuildWrn=!__MsbuildWrn! -MsBuildErr=!__MsbuildErr! -configuration=%__BuildType% %__NativePlatformArgs% %__RunArgs% -MSBuildNodeCount="/m:2" %__UnprocessedBuildArgs%
if not !errorlevel! == 0 (
echo %__MsgPrefix%Error: native component build failed. Refer to the build log files for details:
REM ===
REM =========================================================================================
-if /i "%__BuildArch%"=="arm64" (
- set __DoCrossArchBuild=1
- )
-
-if /i "%__BuildArch%"=="arm" (
- set __DoCrossArchBuild=1
- )
-
if /i "%__DoCrossArchBuild%"=="1" (
REM Scope environment changes start {
setlocal
set __MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn!
set __MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr!
- @call %__ProjectDir%\run.cmd build -Project=%__CrossCompIntermediatesDir%\install.vcxproj -configuration=%__BuildType% -platform=%__CrossArch% -MsBuildLog=!__MsbuildLog! -MsBuildWrn=!__MsbuildWrn! -MsBuildErr=!__MsbuildErr! %__RunArgs% -ExtraParameters="/p:ForceImportBeforeCppTargets=%__ProjectDir%/clr.nativebuild.props /m:2" %__UnprocessedBuildArgs%
+ @call %__ProjectDir%\run.cmd build -Project=%__CrossCompIntermediatesDir%\install.vcxproj -configuration=%__BuildType% -platform=%__CrossArch% -MsBuildLog=!__MsbuildLog! -MsBuildWrn=!__MsbuildWrn! -MsBuildErr=!__MsbuildErr! %__RunArgs% -MSBuildNodeCount="/m:2" %__UnprocessedBuildArgs%
- if not !errorlevel! == 0 (
+ if not !errorlevel! == 0 (
echo %__MsgPrefix%Error: cross-arch components build failed. Refer to the build log files for details:
echo !__BuildLog!
echo !__BuildWrn!
set PATH=%PATH%;%WinDir%\Microsoft.Net\Framework64\V4.0.30319;%WinDir%\Microsoft.Net\Framework\V4.0.30319
if %__BuildNativeCoreLib% EQU 1 (
- echo %__MsgPrefix%Generating native image of System.Private.CoreLib for %__BuildOS%.%__BuildArch%.%__BuildType%
+ 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 (
REM End HACK
)
+ if defined __CrossgenAltJit (
+ REM Set altjit flags for the crossgen run. Note that this entire crossgen section is within a setlocal/endlocal scope,
+ REM so we don't need to save or unset these afterwards.
+ 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
+ )
+
set NEXTCMD="%__CrossgenExe%" %__IbcTuning% /Platform_Assemblies_Paths "%__BinDir%"\IL /out "%__BinDir%\System.Private.CoreLib.dll" "%__BinDir%\IL\System.Private.CoreLib.dll"
echo %__MsgPrefix%!NEXTCMD!
- !NEXTCMD! > "%__CrossGenCoreLibLog%" 2>&1
+ echo %__MsgPrefix%!NEXTCMD! >> "%__CrossGenCoreLibLog%"
+ !NEXTCMD! >> "%__CrossGenCoreLibLog%" 2>&1
if NOT !errorlevel! == 0 (
echo %__MsgPrefix%Error: CrossGen System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog%
:: Put it in the same log, helpful for Jenkins
set NEXTCMD="%__CrossgenExe%" /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 %__MsgPrefix%Error: CrossGen /CreatePdb System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog%
rem arm64 builds currently use private toolset which has not been released yet
REM TODO, remove once the toolset is open.
- if /i "%__BuildArch%" == "arm64" call :PrivateToolSet
+ if not "%__ToolsetDir%" == "" call :PrivateToolSet
set NEXTCMD=call %__ProjectDir%\build-test.cmd %__BuildArch% %__BuildType% %__UnprocessedBuildArgs%
echo %__MsgPrefix%!NEXTCMD!
REM buildtest.cmd has already emitted an error message and mentioned the build log file to examine.
exit /b 1
)
+) else if %__GenerateLayout% EQU 1 (
+ echo %__MsgPrefix%Generating layout for %__BuildOS%.%__BuildArch%.%__BuildType%
+
+ REM Construct the arguments to pass to the runtest build script.
+
+ rem arm64 builds currently use private toolset which has not been released yet
+ REM TODO, remove once the toolset is open.
+ if not "%__ToolsetDir%" == "" call :PrivateToolSet
+
+ set NEXTCMD=call %__ProjectDir%\test\runtest.cmd %__BuildArch% %__BuildType% GenerateLayoutOnly %__UnprocessedBuildArgs%
+ echo %__MsgPrefix%!NEXTCMD!
+ !NEXTCMD!
+
+ if not !errorlevel! == 0 (
+ REM runtest.cmd has already emitted an error message and mentioned the build log file to examine.
+ exit /b 1
+ )
)
REM =========================================================================================
echo -priority=^<N^> : specify a set of test that will be built and run, with priority N.
echo -officialbuildid=^<ID^>: specify the official build ID to be used by this build.
echo -Rebuild: passes /t:rebuild to the build projects.
+echo -crossgenaltjit ^<JIT dll^>: run crossgen using specified altjit ^(used for JIT testing^).
echo portable : build for portable RID.
echo.
echo If "all" is specified, then all build architectures and types are built. If, in addition,
:PrivateToolSet
-echo %__MsgPrefix% Setting Up the usage of __ToolsetDir:%__ToolsetDir%
+echo %__MsgPrefix%Setting up the usage of __ToolsetDir:%__ToolsetDir%
if /i "%__ToolsetDir%" == "" (
echo %__MsgPrefix%Error: A toolset directory is required for the Arm64 Windows build. Use the toolset_dir argument.