Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac172ef

Browse filesBrowse files
4creatorsDan Moseley
authored andcommitted
Optimize native build of coreclr repo - 3x less memory , 11% build time improvement (dotnet/coreclr#14509)
* Fix native build overparallelism * Fix native build parallelization problems * Allow overriding all build workaround parameters * Fix cleanup ommisions and local environment variable naming * Address code review feedback * Fix nul spelling and add standard message prefix * Simplify settings for CL compiler parallelism * Address code review feedback - remove whitespace Commit migrated from dotnet/coreclr@a1142be
1 parent 2781c7e commit ac172ef
Copy full SHA for ac172ef

2 files changed

+18-3Lines changed: 18 additions & 3 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/coreclr/build.cmd‎

Copy file name to clipboardExpand all lines: src/coreclr/build.cmd
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,16 @@ echo %__MsgPrefix%Checking prerequisites
305305
:: Eval the output from probe-win1.ps1
306306
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__SourceDir%\pal\tools\probe-win.ps1"""') do %%a
307307

308+
REM NumberOfEnabledCore is an WMI property providing number of enabled cores on machine
309+
REM processor(s) and later is used to set optimal level of CL paralellism during native build step
310+
if not defined NumberOfEnabledCore (
311+
REM Determine number of physical processor cores available on machine
312+
for /f "tokens=*" %%I in (
313+
'wmic cpu get NumberOfEnabledCore /value ^| find "=" 2^>NUL'
314+
) do set %%I
315+
)
316+
echo %__MsgPrefix%Number of available CPU cores %NumberOfEnabledCore%
317+
308318
REM =========================================================================================
309319
REM ===
310320
REM === Start the build steps
@@ -415,7 +425,7 @@ if %__BuildNative% EQU 1 (
415425
set __MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn!
416426
set __MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr!
417427

418-
@call %__ProjectDir%\run.cmd build -Project=%__IntermediatesDir%\install.vcxproj -MsBuildLog=!__MsbuildLog! -MsBuildWrn=!__MsbuildWrn! -MsBuildErr=!__MsbuildErr! -configuration=%__BuildType% %nativePlatfromArgs% %__RunArgs% %__UnprocessedBuildArgs%
428+
@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%
419429

420430
if not !errorlevel! == 0 (
421431
echo %__MsgPrefix%Error: native component build failed. Refer to the build log files for details:
@@ -485,9 +495,9 @@ if /i "%__DoCrossArchBuild%"=="1" (
485495
set __MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn!
486496
set __MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr!
487497

488-
@call %__ProjectDir%\run.cmd build -Project=%__CrossCompIntermediatesDir%\install.vcxproj -configuration=%__BuildType% -platform=%__CrossArch% -MsBuildLog=!__MsbuildLog! -MsBuildWrn=!__MsbuildWrn! -MsBuildErr=!__MsbuildErr! %__RunArgs% %__UnprocessedBuildArgs%
498+
@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%
489499

490-
if not !errorlevel! == 0 (
500+
if not !errorlevel! == 0 (
491501
echo %__MsgPrefix%Error: cross-arch components build failed. Refer to the build log files for details:
492502
echo !__BuildLog!
493503
echo !__BuildWrn!
Collapse file

‎src/coreclr/clr.nativebuild.props‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<PropertyGroup>
3+
<CL_MPCount>$(NumberOfEnabledCore)</CL_MPCount>
4+
</PropertyGroup>
5+
</Project>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.