about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-05-11 14:14:11 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-05-19 10:53:04 -0700
commita4ef308473f284a93d2d9f32763e09ba7424540b (patch)
tree77d9604bcccef0b8a7d579d2dd1b4e09ab8e90b6
parent6122a5f559362dad03ed6e2433b8d71cece649c5 (diff)
downloadrust-a4ef308473f284a93d2d9f32763e09ba7424540b.tar.gz
rust-a4ef308473f284a93d2d9f32763e09ba7424540b.zip
mk: Add the ability to depend on native LLVM tools
The compiler will require that `llvm-ar.exe` be available for MSVC-targeting
builds (more comments on this soon), so this commit adds support for targets to
depend on LLVM tools. The `core` library for MSVC depends on `llvm-ar.exe` which
will be copied into place for the target before the compiler starts to run.

Note that these targets all depend on `llvm-config.exe` to ensure that they're
built before they're attempted to be copied.
-rw-r--r--mk/cfg/x86_64-pc-windows-msvc.mk6
-rw-r--r--mk/llvm.mk2
-rw-r--r--mk/main.mk1
-rw-r--r--mk/target.mk9
4 files changed, 17 insertions, 1 deletions
diff --git a/mk/cfg/x86_64-pc-windows-msvc.mk b/mk/cfg/x86_64-pc-windows-msvc.mk
index 4e97ae3abe1..209c53f0452 100644
--- a/mk/cfg/x86_64-pc-windows-msvc.mk
+++ b/mk/cfg/x86_64-pc-windows-msvc.mk
@@ -39,3 +39,9 @@ endif
 ifdef CFG_MSVC_LINK
 export PATH := $(CFG_MSVC_ROOT)/VC/bin/amd64:$(PATH)
 endif
+
+# There are more comments about this available in the target specification for
+# Windows MSVC in the compiler, but the gist of it is that we use `llvm-ar.exe`
+# instead of `lib.exe` for assembling archives, so we need to inject this custom
+# dependency here.
+NATIVE_TOOL_DEPS_core_T_x86_64-pc-windows-msvc += llvm-ar.exe
diff --git a/mk/llvm.mk b/mk/llvm.mk
index 356366bd5c6..d5b608e88da 100644
--- a/mk/llvm.mk
+++ b/mk/llvm.mk
@@ -58,6 +58,8 @@ else
 clean-llvm$(1):
 endif
 
+$$(LLVM_AR_$(1)): $$(LLVM_CONFIG_$(1))
+
 # This is used to independently force an LLVM clean rebuild
 # when we changed something not otherwise captured by builtin
 # dependencies. In these cases, commit a change that touches
diff --git a/mk/main.mk b/mk/main.mk
index a70200e4d8a..bf96d8f660f 100644
--- a/mk/main.mk
+++ b/mk/main.mk
@@ -292,6 +292,7 @@ endif
 # Any rules that depend on LLVM should depend on LLVM_CONFIG
 LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X_$(1))
 LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X_$(1))
+LLVM_AR_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-ar$$(X_$(1))
 LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
 LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
 LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
diff --git a/mk/target.mk b/mk/target.mk
index 97b08ebb033..4359eec8447 100644
--- a/mk/target.mk
+++ b/mk/target.mk
@@ -37,7 +37,9 @@ CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4) := \
 		$$(foreach dep,$$(NATIVE_DEPS_$(4)), \
 		  $$(RT_OUTPUT_DIR_$(2))/$$(call CFG_STATIC_LIB_NAME_$(2),$$(dep))) \
 		$$(foreach dep,$$(NATIVE_DEPS_$(4)_T_$(2)), \
-		  $$(RT_OUTPUT_DIR_$(2))/$$(dep))
+		  $$(RT_OUTPUT_DIR_$(2))/$$(dep)) \
+		$$(foreach dep,$$(NATIVE_TOOL_DEPS_$(4)_T_$(2)), \
+		  $$(TBIN$(1)_T_$(3)_H_$(3))/$$(dep))
 endef
 
 $(foreach host,$(CFG_HOST), \
@@ -149,6 +151,11 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/%: $$(RT_OUTPUT_DIR_$(2))/% \
 	    | $$(TLIB$(1)_T_$(2)_H_$(3))/ $$(SNAPSHOT_RUSTC_POST_CLEANUP)
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
+
+$$(TBIN$(1)_T_$(2)_H_$(3))/%: $$(CFG_LLVM_INST_DIR_$(2))/bin/% \
+	    | $$(TBIN$(1)_T_$(2)_H_$(3))/ $$(SNAPSHOT_RUSTC_POST_CLEANUP)
+	@$$(call E, cp: $$@)
+	$$(Q)cp $$< $$@
 endef
 
 $(foreach source,$(CFG_HOST), \