]> git.lizzy.rs Git - rust.git/commitdiff
llvm, rt: build using the Ninja generator if available
authorBen Boeckel <mathstuf@gmail.com>
Fri, 1 Jul 2016 23:47:30 +0000 (19:47 -0400)
committerBen Boeckel <mathstuf@gmail.com>
Fri, 8 Jul 2016 01:10:18 +0000 (21:10 -0400)
The Ninja generator generally builds much faster than make. It may also
be used on Windows to have a vast speed improvement over the Visual
Studio generators.

Currently hidden behind an `--enable-ninja` flag because it does not
obey the top-level `-j` or `-l` flags given to `make`.

configure
mk/llvm.mk
src/bootstrap/config.rs

index 6451b87673f628c230d2686f3f7dc3773506bd10..3ff728b86a9f5901cf5817e6e88deaa3655069f0 100755 (executable)
--- a/configure
+++ b/configure
@@ -612,6 +612,7 @@ opt rustbuild 0 "use the rust and cargo based build system"
 opt orbit 0 "get MIR where it belongs - everywhere; most importantly, in orbit"
 opt codegen-tests 1 "run the src/test/codegen tests"
 opt option-checking 1 "complain about unrecognized options in this configure script"
+opt ninja 0 "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)"
 
 # Optimization and debugging options. These may be overridden by the release channel, etc.
 opt_nosave optimize 1 "build optimized rust code"
@@ -775,6 +776,17 @@ probe CFG_BISON            bison
 probe CFG_GDB              gdb
 probe CFG_LLDB             lldb
 
+if [ -n "$CFG_ENABLE_NINJA" ]
+then
+  probe CFG_NINJA            ninja
+  if [ -z "$CFG_NINJA" ]
+  then
+    # On Debian and Fedora, the `ninja` binary is an IRC bot, so the build tool was
+    # renamed. Handle this case.
+    probe CFG_NINJA            ninja-build
+  fi
+fi
+
 # For building LLVM
 probe_need CFG_CMAKE cmake
 
@@ -1524,7 +1536,10 @@ do
     fi
 
     # We need the generator later on for compiler-rt even if LLVM's not built
-    if [ ${is_msvc} -ne 0 ]
+    if [ -n "$CFG_NINJA" ]
+    then
+        generator="Ninja"
+    elif [ ${is_msvc} -ne 0 ]
     then
         case "$CFG_MSVC_ROOT" in
             *14.0*)
index 2298565221072acf3e36dc9a4ff148dc16a40379..602c20430298b8414c9e910a56244fb43ffa7125 100644 (file)
@@ -43,7 +43,9 @@ $$(LLVM_CONFIG_$(1)): $$(LLVM_DONE_$(1))
 
 $$(LLVM_DONE_$(1)): $$(LLVM_DEPS_TARGET_$(1)) $$(LLVM_STAMP_$(1))
        @$$(call E, cmake: llvm)
-ifeq ($$(findstring msvc,$(1)),msvc)
+ifneq ($$(CFG_NINJA),)
+       $$(Q)$$(CFG_NINJA) -C $$(CFG_LLVM_BUILD_DIR_$(1))
+else ifeq ($$(findstring msvc,$(1)),msvc)
        $$(Q)$$(CFG_CMAKE) --build $$(CFG_LLVM_BUILD_DIR_$(1)) \
                --config $$(LLVM_BUILD_CONFIG_MODE)
 else
@@ -51,7 +53,11 @@ else
 endif
        $$(Q)touch $$@
 
-ifeq ($$(findstring msvc,$(1)),msvc)
+ifneq ($$(CFG_NINJA),)
+clean-llvm$(1):
+       @$$(call E, clean: llvm)
+       $$(Q)$$(CFG_NINJA) -C $$(CFG_LLVM_BUILD_DIR_$(1)) -t clean
+else ifeq ($$(findstring msvc,$(1)),msvc)
 clean-llvm$(1):
 else
 clean-llvm$(1):
index 498196e9b6dfc12454274e75cd695c2ad2a04b65..e64d7e5a437e6103b13f7b5a471c90fa1f9b7c5b 100644 (file)
@@ -317,6 +317,7 @@ macro_rules! check {
                 ("OPTIMIZE_TESTS", self.rust_optimize_tests),
                 ("DEBUGINFO_TESTS", self.rust_debuginfo_tests),
                 ("LOCAL_REBUILD", self.local_rebuild),
+                ("NINJA", self.ninja),
             }
 
             match key {