Default to ninja for faster builds (mac & linux)#124041
Default to ninja for faster builds (mac & linux)#124041steveisok wants to merge 5 commits intodotnet:mainfrom
Conversation
Benchmarking showed ninja provides ~8.8% faster builds on macOS (avg 654s vs 718s per build). This change defaults to using ninja when the host OS is macOS. Changes: - eng/build.sh: Default --ninja true on macOS, track explicit user override - eng/native/build-commons.sh: Default -ninja on macOS, add -ninja false opt-out Users can opt out with --ninja false (or -ninja false for native builds).
There was a problem hiding this comment.
Pull request overview
This PR improves macOS build performance by defaulting to the Ninja build system instead of Make, achieving approximately 8.8% faster build times (654s vs 718s average). The change is opt-out via --ninja false to maintain flexibility.
Changes:
- Default ninja build system on macOS for improved performance
- Add explicit flag tracking to prevent overriding user preferences
- Update help text to document the new default and opt-out mechanism
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| eng/build.sh | Adds macOS-specific ninja default with tracking to avoid overriding explicit user settings |
| eng/native/build-commons.sh | Sets ninja as default on macOS and enhances -ninja flag to accept true/false values |
|
docs\workflow\requirements\macos-requirements.md needs to be updated - ninja is no longer optional by default after this change. |
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
|
Windows also defaults to ninja. Maybe we should flip the switch: |
Nit: Avoiding negations in names is a generally better UX design. I like |
- Use single useNinja variable in eng/build.sh instead of tracking explicit-ness - Initialize __UseNinja=0 in build-commons.sh, then override to 1 on macOS - Remove __UseNinja=0 initialization from build-runtime.sh and tests/build.sh so the macOS default takes effect - Update macOS requirements docs to reflect ninja is now default
|
I was just talking with @agocke about requiring Ninja on macOS to make it easier to maintain our Swift usage (as CMake only supports Swift with Ninja and XCode) so we don't need to manually invoke the Swift compiler and do our own object file handling. I think this is a great first step in that direction! |
Based on PR feedback, default to using Ninja for native builds on any Unix platform where ninja is installed, rather than only on macOS. This aligns with the Mono subtree behavior and provides faster builds when ninja is available.
Require ninja by default for a predictable build experience on Unix platforms. Users can opt out with --ninja false. Contributes to dotnet#54022
b144e62 to
23add9a
Compare
Benchmarking showed ninja provides ~8.8% faster builds on macOS (avg 654s vs 718s per build). This change defaults to using ninja for both MacOS and Linux.
Changes:
Users can opt out with --ninja false (or -ninja false for native builds).
Contributes to #54022 (#54022)