Skip to content

Commit 003a929

Browse files
committed
Auto merge of #44084 - alexcrichton:msvc-ninja, r=Mark-Simulacrum
rustbuild: Automatically enable Ninja on MSVC Discovered in #43767 it turns out the default MSBuild generator in CMake for whatever reason isn't supporting many of the configuration options we give to LLVM. To improve the contributor experience automatically enable Ninja if we find it to ensure that "flavorful" configurations of LLVM work by default in more situations. Closes #43767
2 parents 315e702 + e13f02e commit 003a929

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/bootstrap/sanity.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,27 @@ pub fn check(build: &mut Build) {
9393
}
9494

9595
// Ninja is currently only used for LLVM itself.
96-
// Some Linux distros rename `ninja` to `ninja-build`.
97-
// CMake can work with either binary name.
98-
if building_llvm && build.config.ninja && cmd_finder.maybe_have("ninja-build").is_none() {
99-
cmd_finder.must_have("ninja");
96+
if building_llvm {
97+
if build.config.ninja {
98+
// Some Linux distros rename `ninja` to `ninja-build`.
99+
// CMake can work with either binary name.
100+
if cmd_finder.maybe_have("ninja-build").is_none() {
101+
cmd_finder.must_have("ninja");
102+
}
103+
}
104+
105+
// If ninja isn't enabled but we're building for MSVC then we try
106+
// doubly hard to enable it. It was realized in #43767 that the msbuild
107+
// CMake generator for MSVC doesn't respect configuration options like
108+
// disabling LLVM assertions, which can often be quite important!
109+
//
110+
// In these cases we automatically enable Ninja if we find it in the
111+
// environment.
112+
if !build.config.ninja && build.config.build.contains("msvc") {
113+
if cmd_finder.maybe_have("ninja").is_some() {
114+
build.config.ninja = true;
115+
}
116+
}
100117
}
101118

102119
build.config.python = build.config.python.take().map(|p| cmd_finder.must_have(p))

0 commit comments

Comments
 (0)