From e13f02eb2e188a3d8c2a5f7ba20823a85ab14307 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 25 Aug 2017 10:10:27 -0700 Subject: [PATCH] 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 --- src/bootstrap/sanity.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index a64a6130929..54208d8bb57 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -93,10 +93,27 @@ pub fn check(build: &mut Build) { } // Ninja is currently only used for LLVM itself. - // Some Linux distros rename `ninja` to `ninja-build`. - // CMake can work with either binary name. - if building_llvm && build.config.ninja && cmd_finder.maybe_have("ninja-build").is_none() { - cmd_finder.must_have("ninja"); + if building_llvm { + if build.config.ninja { + // Some Linux distros rename `ninja` to `ninja-build`. + // CMake can work with either binary name. + if cmd_finder.maybe_have("ninja-build").is_none() { + cmd_finder.must_have("ninja"); + } + } + + // If ninja isn't enabled but we're building for MSVC then we try + // doubly hard to enable it. It was realized in #43767 that the msbuild + // CMake generator for MSVC doesn't respect configuration options like + // disabling LLVM assertions, which can often be quite important! + // + // In these cases we automatically enable Ninja if we find it in the + // environment. + if !build.config.ninja && build.config.build.contains("msvc") { + if cmd_finder.maybe_have("ninja").is_some() { + build.config.ninja = true; + } + } } build.config.python = build.config.python.take().map(|p| cmd_finder.must_have(p))