diff --git a/src/coreclr/build.cmd b/src/coreclr/build.cmd index 67028d922e2601..71f4831fc694e9 100644 --- a/src/coreclr/build.cmd +++ b/src/coreclr/build.cmd @@ -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%" @@ -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 ========================================================================================= @@ -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! ) ) @@ -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!" @@ -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!" @@ -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 ========================================================================================= @@ -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 @@ -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 @@ -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 @@ -571,7 +566,7 @@ 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 @@ -579,7 +574,7 @@ if %__BuildNative% EQU 1 ( :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 @@ -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 @@ -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%^ @@ -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" ( @@ -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" @@ -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!" @@ -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 @@ -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 @@ -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 @@ -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 ) ) @@ -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) @@ -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 ) @@ -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" @@ -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 ) ) @@ -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 @@ -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% @@ -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 ) ) @@ -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. @@ -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. diff --git a/src/coreclr/configurecompiler.cmake b/src/coreclr/configurecompiler.cmake index aa37d103b70e5d..588aff2812011b 100644 --- a/src/coreclr/configurecompiler.cmake +++ b/src/coreclr/configurecompiler.cmake @@ -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) @@ -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) \ No newline at end of file