about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure17
-rw-r--r--mk/llvm.mk14
-rw-r--r--mk/rt.mk7
-rw-r--r--src/bootstrap/config.rs1
4 files changed, 36 insertions, 3 deletions
diff --git a/configure b/configure
index fd009a757a4..d2ec457a1c8 100755
--- 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"
@@ -785,6 +786,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
 
@@ -1534,7 +1546,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*)
diff --git a/mk/llvm.mk b/mk/llvm.mk
index 22985652210..d6f812049e0 100644
--- a/mk/llvm.mk
+++ b/mk/llvm.mk
@@ -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,8 +53,16 @@ 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):
+	@$$(call E, clean: llvm)
+	$$(Q)$$(CFG_CMAKE) --build $$(CFG_LLVM_BUILD_DIR_$(1)) \
+		--config $$(LLVM_BUILD_CONFIG_MODE) \
+		--target clean
 else
 clean-llvm$(1):
 	@$$(call E, clean: llvm)
diff --git a/mk/rt.mk b/mk/rt.mk
index d0ab3102d7d..8113b683807 100644
--- a/mk/rt.mk
+++ b/mk/rt.mk
@@ -350,10 +350,17 @@ $$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS) $$(LLVM_CONFIG_$$(CFG_BUILD
 		$$(COMPRT_DEFINES_$(1)) \
 		$$(COMPRT_BUILD_CC_$(1)) \
 		-G"$$(CFG_CMAKE_GENERATOR)"
+ifneq ($$(CFG_NINJA),)
+	$$(CFG_CMAKE) --build "$$(COMPRT_BUILD_DIR_$(1))" \
+		--target $$(COMPRT_BUILD_TARGET_$(1)) \
+		--config $$(LLVM_BUILD_CONFIG_MODE) \
+		-- $$(COMPRT_BUILD_ARGS_$(1))
+else
 	$$(Q)$$(CFG_CMAKE) --build "$$(COMPRT_BUILD_DIR_$(1))" \
 		--target $$(COMPRT_BUILD_TARGET_$(1)) \
 		--config $$(LLVM_BUILD_CONFIG_MODE) \
 		-- $$(COMPRT_BUILD_ARGS_$(1)) $$(MFLAGS)
+endif
 	$$(Q)cp "$$(COMPRT_OUTPUT_$(1))" $$@
 
 endif
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 498196e9b6d..e64d7e5a437 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -317,6 +317,7 @@ impl Config {
                 ("OPTIMIZE_TESTS", self.rust_optimize_tests),
                 ("DEBUGINFO_TESTS", self.rust_debuginfo_tests),
                 ("LOCAL_REBUILD", self.local_rebuild),
+                ("NINJA", self.ninja),
             }
 
             match key {