Skip to content

[ML] Build acceleration with unity builds, PCH, Ninja, and /Z7 debug info#2905

Open
edsavage wants to merge 1 commit intoelastic:mainfrom
edsavage:build-acceleration-unity-pch
Open

[ML] Build acceleration with unity builds, PCH, Ninja, and /Z7 debug info#2905
edsavage wants to merge 1 commit intoelastic:mainfrom
edsavage:build-acceleration-unity-pch

Conversation

@edsavage
Copy link
Contributor

Summary

  • Enable CMake unity builds for faster compilation (batch size 16, with per-library exclusion lists for conflicting files)
  • Add precompiled headers (PCH) option (-DML_PCH=ON) for common STL and Boost headers
  • Switch Windows CI to Ninja Multi-Config generator for better parallel scheduling
  • Replace MSVC /Zi with /Z7 to eliminate mspdbsrv.exe PDB serialization bottleneck
  • Disable unity builds on macOS (counterproductive on 4-core Orka VMs)
  • Resolve all unity build symbol conflicts across lib/core, lib/maths/*, lib/model, and lib/api

Test plan

  • Benchmarked on Linux x86_64, Linux aarch64, macOS aarch64, Windows x86_64
  • All unit tests pass on all platforms
  • Unity build conflicts resolved via SKIP_UNITY_BUILD_INCLUSION or library-level disable
  • Verified PCH doesn't cause Boost header conflicts on GCC (removed boost/unordered_map.hpp)

Made with Cursor

@prodsecmachine
Copy link

prodsecmachine commented Feb 19, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@edsavage edsavage force-pushed the build-acceleration-unity-pch branch from 231a54d to 01f25ec Compare March 9, 2026 21:57
Enable CMake unity builds and precompiled headers (PCH) to reduce
compilation times. Use Ninja Multi-Config generator on Windows for
faster parallel compilation (downloaded on-demand during CI).

Unity builds:
- Enabled globally via -DCMAKE_UNITY_BUILD=ON (Windows/Linux)
- Disabled on macOS (counterproductive on 4-core Orka VMs)
- Disabled for MlApi and MlMathsAnalytics (too many symbol conflicts)
- Fix anonymous-namespace conflicts in core/ and maths/ sources

PCH:
- New ML_PCH option adds Boost headers as precompiled header targets
- Enabled via -DML_PCH=ON in CI pipeline environments

Ninja on Windows:
- Set CMAKE_GENERATOR=Ninja Multi-Config in Windows pipeline env
- build.ps1 downloads ninja.exe on-demand from GitHub releases when
  not already on PATH
- Remove /Zi in favour of /Z7 (embedded debug info avoids PDB locking
  issues with Ninja's parallel compilation)

Build system:
- build.gradle reads CMAKE_FLAGS from environment, allowing CI to
  pass unity/PCH flags through to cmake configure
- Fix ML_DEBUG handling: use env-dict in pipeline generators (not
  inline PowerShell commands) and restore debug build directory
  selection in build/test scripts

Made-with: Cursor
@edsavage edsavage force-pushed the build-acceleration-unity-pch branch from 01f25ec to e0c995a Compare March 10, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants