Skip to content

CI: use 32-bit hosted toolchain for all VsDevCmd.bat calls#6339

Merged
Fedr merged 4 commits into
masterfrom
ci/windows-cmake-host-x86
Jun 28, 2026
Merged

CI: use 32-bit hosted toolchain for all VsDevCmd.bat calls#6339
Fedr merged 4 commits into
masterfrom
ci/windows-cmake-host-x86

Conversation

@Fedr

@Fedr Fedr commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

What

The CMake/Ninja Windows builds configure the MSVC environment via:

VsDevCmd.bat -arch=amd64

-arch sets the target architecture but leaves the host tools at the OS default (amd64), so these builds use the 64-bit hosted compiler and linker.

The MSBuild build of MeshLib.sln instead uses the 32-bit hosted toolchain, selected by <PreferredToolArchitecture>x86</PreferredToolArchitecture> in source/platform.props.

This PR adds -host_arch=x86 to every VsDevCmd.bat call across the workflows so they cross-compile with the 32-bit hosted tools (x86 host → x64 target), matching the MSBuild toolchain. The produced binaries stay x64 (-arch=amd64 is unchanged).

Call sites updated

.github/workflows/build-test-windows.yml:

  • Generate C# bindings
  • Build (main MeshLib CMake/Ninja build)
  • (C bindings env setup)
  • Build C++ examples
  • Build C examples

.github/workflows/pip-build.yml:

  • Windows wheel build

Notes

  • Why VsDevCmd, not a CMake flag: these are Ninja builds, so the host toolchain comes from the vcvars environment — the -T host=x86 toolset spec only works with the Visual Studio generator, which MeshLib doesn't use here.
  • The 32-bit hosted cl.exe has a ~4 GB address-space limit, but this matches what the MSBuild build already runs, so behavior is at parity.

🤖 Generated with Claude Code

PCH size impact (32-bit vs 64-bit hosted toolchain)

The PCH-size logging from #6340 gives a clean before/after, since the only difference is this PR's -host_arch=x86:

  • Baseline (64-bit hosted, master without this change): run 28318048245
  • This PR (32-bit hosted): run 28330270559

CMake / Ninja — PCHs shrink ~37% (the path this PR changes), sizes in MB:

Job MRPch (64-bit → 32-bit) MRMesh MRViewer
msvc-2019 Debug · iterator-debug 1,425.44 → 899.19 (−36.9%) 613.12 → 373.75 677.94 → 411.94
msvc-2019 Debug · vs2019 1,395.81 → 881.62 (−36.8%) 600.94 → 366.06 665.19 → 403.94
msvc-2019 Release · vs2019 1,384.81 → 874.69 (−36.8%) 596.19 → 363.06 660.25 → 400.87
msvc-2026 Debug · meshlib 1,253.94 → 790.37 (−37.0%) 578.06 → 352.37 627.81 → 383.06
msvc-2026 Release · meshlib 1,247.25 → 786.19 (−37.0%) 573.81 → 349.75 623.38 → 380.31
msvc-2022 Debug · vs2022 1,230.87 → 777.69 (−36.8%) 567.88 → 346.19 617.31 → 376.75
msvc-2022 Release · vs2022 1,224.12 → 773.44 (−36.8%) 563.56 → 343.50 612.75 → 373.94

MSBuild — unchanged (already 32-bit hosted via PreferredToolArchitecture=x86), every value matches byte-for-byte, e.g. MRPch: msvc-2019 Debug 902.69, msvc-2026 Release 840.62, msvc-2022 Release 813.56.

This confirms the toolchain switch takes effect (only the CMake path moves) and is a nice side benefit: the 32-bit hosted compiler emits PCHs ~37% smaller, bringing the CMake builds in line with the (smaller) MSBuild PCHs.

The CMake (Ninja) Windows build configured MSVC via
`VsDevCmd.bat -arch=amd64`, which defaults the host tools to amd64,
so it used the 64-bit hosted compiler/linker. The MSBuild build of
MeshLib.sln instead uses the 32-bit hosted toolchain via
`<PreferredToolArchitecture>x86</PreferredToolArchitecture>` in
source/platform.props.

Add `-host_arch=x86` so the CMake build cross-compiles with the
32-bit hosted tools (x86 host -> x64 target), matching the MSBuild
toolchain while still producing x64 binaries.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extend the previous change to every remaining `VsDevCmd.bat -arch=amd64`
invocation (C# bindings generation, C++/C example builds, and the
pip-build wheel build) so all CMake/Ninja MSVC builds use the 32-bit
hosted toolchain (x86 host -> x64 target), matching MeshLib.sln's
PreferredToolArchitecture=x86. Targets stay x64.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Fedr Fedr changed the title CI: build Windows CMake target with 32-bit hosted toolchain CI: use 32-bit hosted toolchain for all VsDevCmd.bat calls Jun 28, 2026
@Fedr Fedr added full-ci run all steps test-pip-build Build Python wheels (and discard them) labels Jun 28, 2026
@Fedr Fedr merged commit 9b43ded into master Jun 28, 2026
59 checks passed
@Fedr Fedr deleted the ci/windows-cmake-host-x86 branch June 28, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant