Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 36 additions & 56 deletions src/coreclr/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set __ThisScriptFull="%~f0"
set __ThisScriptDir="%~dp0"

call "%__ThisScriptDir%"\setup_vs_tools.cmd
if NOT '%ERRORLEVEL%' == '0' goto ExitWithError
if NOT '%ERRORLEVEL%' == '0' exit /b 1

if defined VS160COMNTOOLS (
set "__VSToolsRoot=%VS160COMNTOOLS%"
Expand Down Expand Up @@ -376,8 +376,7 @@ powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__RepoRootDir%\eng
%__CommonMSBuildArgs% %__UnprocessedBuildArgs%
if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: Failed to generate version headers.
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)

REM =========================================================================================
Expand All @@ -394,8 +393,7 @@ if %__RestoreOptData% EQU 1 (
%__CommonMSBuildArgs% %__UnprocessedBuildArgs%
if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: Failed to restore the optimization data package.
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)
)

Expand All @@ -408,12 +406,11 @@ powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__RepoRootDir%\eng

if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%Failed to get PGO data package path.
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)
if not exist "!PgoDataPackagePathOutputFile!" (
echo %__ErrMsgPrefix%Failed to get PGO data package path.
goto ExitWithError
exit /b 1
)

set /p __PgoOptDataPath=<"!PgoDataPackagePathOutputFile!"
Expand All @@ -423,13 +420,12 @@ powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__RepoRootDir%\eng

if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%Failed to get IBC data package path.
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)

if not exist "!IbcDataPackagePathOutputFile!" (
echo %__ErrMsgPrefix%Failed to get IBC data package path.
goto ExitWithError
exit /b 1
)

set /p __IbcOptDataPath=<"!IbcDataPackagePathOutputFile!"
Expand All @@ -451,12 +447,12 @@ set /p PYTHON=<%TEMP%\pythonlocation.txt

if NOT DEFINED PYTHON (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: Could not find a python installation
goto ExitWithError
exit /b 1
)

if %__BuildCoreLib% EQU 1 (
echo %__MsgPrefix%Laying out dynamically generated EventSource classes
"!PYTHON!" -B -Wall %__SourceDir%\scripts\genRuntimeEventSources.py --man %__SourceDir%\vm\ClrEtwAll.man --intermediate %__IntermediatesEventingDir% || goto ExitWithError
"!PYTHON!" -B -Wall %__SourceDir%\scripts\genRuntimeEventSources.py --man %__SourceDir%\vm\ClrEtwAll.man --intermediate %__IntermediatesEventingDir% || exit /b 1
)

REM =========================================================================================
Expand Down Expand Up @@ -489,14 +485,14 @@ if %__BuildCrossArchNative% EQU 1 (

if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate native component build project!
goto ExitWithError
exit /b 1
)
@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
exit /b 1
)

if defined __ConfigureOnly goto SkipCrossCompBuild
Expand All @@ -515,8 +511,7 @@ if %__BuildCrossArchNative% EQU 1 (

if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: cross-arch components build failed.
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)

:SkipCrossCompBuild
Expand Down Expand Up @@ -559,7 +554,7 @@ if %__BuildNative% EQU 1 (

if not defined VSINSTALLDIR (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: VSINSTALLDIR variable not defined.
goto ExitWithError
exit /b 1
)
if not exist "!VSINSTALLDIR!DIA SDK" goto NoDIA

Expand All @@ -571,15 +566,15 @@ if %__BuildNative% EQU 1 (
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
exit /b 1
)

@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
exit /b 1
)

if defined __ConfigureOnly goto SkipNativeBuild
Expand All @@ -598,8 +593,7 @@ if %__BuildNative% EQU 1 (

if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: native component build failed.
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)

:SkipNativeBuild
Expand Down Expand Up @@ -646,8 +640,7 @@ if %__BuildCoreLib% EQU 1 (
echo !__BuildLog!
echo !__BuildWrn!
echo !__BuildErr!
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)

powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -Command "%__RepoRootDir%\eng\common\msbuild.ps1" %__ArcadeScriptArgs%^
Expand All @@ -658,8 +651,7 @@ if %__BuildCoreLib% EQU 1 (
echo !__BuildLog!
echo !__BuildWrn!
echo !__BuildErr!
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)

if "%__BuildManagedTools%" == "1" (
Expand All @@ -671,8 +663,7 @@ if %__BuildCoreLib% EQU 1 (
echo !__BuildLog!
echo !__BuildWrn!
echo !__BuildErr!
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)

copy /Y "%__BinDir%\clrjit.dll" "%__BinDir%\crossgen2\clrjitilc.dll"
Expand All @@ -688,12 +679,11 @@ if %__BuildCoreLib% EQU 1 (

if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%Failed to determine IBC Merge path.
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)
if not exist "!IbcMergePackagePathOutputFile!" (
echo %__ErrMsgPrefix%Failed to determine IBC Merge path.
goto ExitWithError
exit /b 1
)

set /p __IbcMergePath=<"!IbcMergePackagePathOutputFile!"
Expand Down Expand Up @@ -726,7 +716,7 @@ if %__BuildCoreLib% EQU 1 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: IbcMerge of System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog%
REM Put it in the same log, helpful for Jenkins
type %__CrossGenCoreLibLog%
goto ExitWithError
goto CrossgenFailure
)

REM Verify that the optimization data has been merged
Expand All @@ -737,7 +727,7 @@ if %__BuildCoreLib% EQU 1 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: IbcMerge of System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog%
REM Put it in the same log, helpful for Jenkins
type %__CrossGenCoreLibLog%
goto ExitWithError
goto CrossgenFailure
)

REM Save the module as *.pgo to match the convention expected
Expand All @@ -756,7 +746,7 @@ if %__BuildCoreLib% EQU 1 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: IbcMerge of System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog%
REM Put it in the same log, helpful for Jenkins
type %__CrossGenCoreLibLog%
goto ExitWithError
goto CrossgenFailure
)

REM Verify that the optimization data has been applied
Expand All @@ -767,18 +757,18 @@ if %__BuildCoreLib% EQU 1 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: IbcMerge of System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog%
REM Put it in the same log, helpful for Jenkins
type %__CrossGenCoreLibLog%
goto ExitWithError
goto CrossgenFailure
)
) else (
echo %__MsgPrefix%!TargetOptimizationDataFile! does not exist >> %__CrossGenCoreLibLog%
echo %__ErrMsgPrefix%%__MsgPrefix%Error: IbcMerge of System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog%
REM Put it in the same log, helpful for Jenkins
type %__CrossGenCoreLibLog%
goto ExitWithError
goto CrossgenFailure
)
) else (
echo Could not find IBCMerge at !IbcMergePath!. Have you restored src/.nuget/optdata/ibcmerge.csproj?
goto ExitWithError
goto CrossgenFailure
)
)

Expand Down Expand Up @@ -811,7 +801,7 @@ if %__BuildNativeCoreLib% EQU 1 (
@if defined _echo @echo on
if NOT !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: Failed to load native tools environment for !__VCExecArch!
goto ExitWithError
goto CrossgenFailure
)

REM HACK: Workaround for [dotnet/coreclr#13970](https://github.com/dotnet/coreclr/issues/13970)
Expand All @@ -822,7 +812,7 @@ if %__BuildNativeCoreLib% EQU 1 (
echo %__MsgPrefix%Copying "!__PgoRtPath!" into "%__BinDir%"
copy /y "!__PgoRtPath!" "%__BinDir%" || (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: copy failed
goto ExitWithError
goto CrossgenFailure
)
REM End HACK
)
Expand All @@ -848,7 +838,7 @@ if %__BuildNativeCoreLib% EQU 1 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: CrossGen System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog%
REM Put it in the same log, helpful for Jenkins
type %__CrossGenCoreLibLog%
goto ExitWithError
goto CrossgenFailure
)

set NEXTCMD="%__CrossgenExe%" /Platform_Assemblies_Paths "%__BinDir%" /CreatePdb "%__BinDir%\PDB" "%__BinDir%\System.Private.CoreLib.dll"
Expand All @@ -859,7 +849,7 @@ if %__BuildNativeCoreLib% EQU 1 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: CrossGen /CreatePdb System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog%
REM Put it in the same log, helpful for Jenkins
type %__CrossGenCoreLibLog%
goto ExitWithError
goto CrossgenFailure
)
)

Expand Down Expand Up @@ -890,8 +880,7 @@ if %__BuildPackages% EQU 1 (
if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: Nuget package generation failed. Refer to the build log file for details.
echo !__BuildLog!
set __exitCode=!errorlevel!
goto ExitWithCode
exit /b !errorlevel!
)

REM } Scope environment changes end
Expand All @@ -917,7 +906,7 @@ if %__BuildTests% EQU 1 (

if not !errorlevel! == 0 (
REM buildtest.cmd has already emitted an error message and mentioned the build log file to examine.
goto ExitWithError
exit /b 1
)
) else if %__GenerateLayout% EQU 1 (
echo %__MsgPrefix%Generating layout for %__BuildOS%.%__BuildArch%.%__BuildType%
Expand All @@ -928,7 +917,7 @@ if %__BuildTests% EQU 1 (

if not !errorlevel! == 0 (
REM runtest.cmd has already emitted an error message and mentioned the build log file to examine.
goto ExitWithError
exit /b 1
)
)

Expand Down Expand Up @@ -997,7 +986,7 @@ if %__AllBuildSuccess%==true (
echo %__MsgPrefix%Builds failed:
type %__BuildResultFile%
del /f /q %__BuildResultFile%
goto ExitWithError
exit /b 1
)

REM This code is unreachable, but leaving it nonetheless, just in case things change.
Expand All @@ -1021,18 +1010,9 @@ 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
:CrossgenFailure
exit /b 1

:ExitWithCode
exit /b !__exitCode!

:Usage
echo.
echo Build the CoreCLR repo.
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ cmake_policy(SET CMP0083 NEW)
include(CheckPIESupported)
include(CheckCXXCompilerFlag)


# All code we build should be compiled as position independent
check_pie_supported(OUTPUT_VARIABLE PIE_SUPPORT_OUTPUT LANGUAGES CXX)
if(NOT MSVC AND NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
Expand Down Expand Up @@ -642,7 +641,3 @@ if(CLR_CMAKE_ENABLE_CODE_COVERAGE)
endif(CLR_CMAKE_PLATFORM_UNIX)

endif(CLR_CMAKE_ENABLE_CODE_COVERAGE)

if (CMAKE_BUILD_TOOL STREQUAL nmake)
set(CMAKE_RC_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
endif(CMAKE_BUILD_TOOL STREQUAL nmake)