Skip to content

Commit 8fd9106

Browse files
Copilotakoeplingerjkotas
authored
Replace deprecated wmic with MSBuild parallelism properties (#122386)
`wmic` is deprecated and missing on newer Windows builds. The build scripts used it to detect processor cores for CL parallelism tuning via `CL_MPCount`. **Changes:** - Remove `wmic cpu get NumberOfCores` detection from `src/coreclr/build-runtime.cmd` and `src/tests/build.cmd` - Remove `CL_MPCount` property from `src/coreclr/Directory.Build.props` - Add MSBuild properties in root `Directory.Build.props` to control build parallelism: - `UseMultiToolTask=true` - `EnforceProcessCountAcrossBuilds=true` - `EnableClServerMode=true` The MSBuild properties are set globally in the root Directory.Build.props file (in a separate PropertyGroup right after the Arcade SDK import) so they apply to all projects in the repository. This follows Microsoft's [recommended approach](https://devblogs.microsoft.com/cppblog/cpp-build-throughput-investigation-and-tune-up/#3.-tune-build-options-for-better-parallelism) for C++ build parallelism on modern systems. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>wmic deprecated/missing on newer builds of windows</issue_title> > <issue_description>We should find an alternative > > https://github.com/dotnet/runtime/blob/ac764af3e2d77aa582dff3511295ee701b831a7d/src/coreclr/build-runtime.cmd#L276 > > https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmic</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > <comment_new><author>@jkotas</author><body> > This was introduced by ac172ef . > > Is this workaround for a buggy parallelism still needed?</body></comment_new> > <comment_new><author>@akoeplinger</author><body> > https://github.com/dotnet/runtime/blob/8dbca2cd19e608d45f13b8f193299dd2fe52d3b3/src/tests/build.cmd#L277 is another instance</body></comment_new> > <comment_new><author>@akoeplinger</author><body> > Judging from https://devblogs.microsoft.com/cppblog/cpp-build-throughput-investigation-and-tune-up/#3.-tune-build-options-for-better-parallelism. I think we can just use: > > ``` > set UseMultiToolTask=true > set EnforceProcessCountAcrossBuilds=true > set EnableClServerMode=true > ``` > > instead of setting NumberOfCores > > this means we can also stop setting CL_MPCount in src/coreclr/Directory.Build.props which was being set to NumberOfCores</body></comment_new> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #118223 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: akoeplinger <1376924+akoeplinger@users.noreply.github.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com>
1 parent 090d98d commit 8fd9106

4 files changed

Lines changed: 8 additions & 25 deletions

File tree

Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
<!-- Import the Arcade SDK -->
5757
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
5858

59+
<!-- MSBuild parallelism settings for better build performance.
60+
See https://devblogs.microsoft.com/cppblog/cpp-build-throughput-investigation-and-tune-up/ -->
61+
<PropertyGroup>
62+
<UseMultiToolTask>true</UseMultiToolTask>
63+
<EnforceProcessCountAcrossBuilds>true</EnforceProcessCountAcrossBuilds>
64+
<EnableClServerMode>true</EnableClServerMode>
65+
</PropertyGroup>
66+
5967
<!-- The TFMs to build and test against. -->
6068
<PropertyGroup>
6169
<NetCoreAppCurrentVersion>11.0</NetCoreAppCurrentVersion>

src/coreclr/Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@
2424

2525
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
2626
<SignAssembly Condition="'$(UsingMicrosoftNETSdk)' != 'true'">false</SignAssembly>
27-
<CL_MPCount>$(NumberOfCores)</CL_MPCount>
2827
</PropertyGroup>
2928
</Project>

src/coreclr/build-runtime.cmd

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,6 @@ echo %__MsgPrefix%Using CMake from !CMakePath!
266266

267267
:SkipLocateCMake
268268

269-
REM NumberOfCores is an WMI property providing number of physical cores on machine
270-
REM processor(s). It is used to set optimal level of CL parallelism during native build step
271-
if not defined NumberOfCores (
272-
REM Determine number of physical processor cores available on machine
273-
set TotalNumberOfCores=0
274-
for /f "tokens=*" %%I in (
275-
'wmic cpu get NumberOfCores /value ^| find "=" 2^>NUL'
276-
) do set %%I & set /a TotalNumberOfCores=TotalNumberOfCores+NumberOfCores
277-
set NumberOfCores=!TotalNumberOfCores!
278-
)
279-
echo %__MsgPrefix%Number of processor cores %NumberOfCores%
280-
281269
REM =========================================================================================
282270
REM ===
283271
REM === Start the build steps

src/tests/build.cmd

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -268,18 +268,6 @@ echo %__MsgPrefix%Commencing build of native test components for %__BuildArch%/%
268268

269269
REM Set the environment for the native build
270270

271-
REM NumberOfCores is an WMI property providing number of physical cores on machine
272-
REM processor(s). It is used to set optimal level of CL parallelism during native build step
273-
if not defined NumberOfCores (
274-
REM Determine number of physical processor cores available on machine
275-
set TotalNumberOfCores=0
276-
for /f "tokens=*" %%I in (
277-
'wmic cpu get NumberOfCores /value ^| find "=" 2^>NUL'
278-
) do set %%I & set /a TotalNumberOfCores=TotalNumberOfCores+NumberOfCores
279-
set NumberOfCores=!TotalNumberOfCores!
280-
)
281-
echo %__MsgPrefix%Number of processor cores %NumberOfCores%
282-
283271
@if defined _echo @echo on
284272

285273
set __ExtraCmakeArgs=

0 commit comments

Comments
 (0)