diff --git a/mk/docs.mk b/mk/docs.mk index 48eb9e81c20..0b5240d51d5 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -299,7 +299,8 @@ $(2) += doc/$(1)/index.html doc/$(1)/index.html: CFG_COMPILER_HOST_TRIPLE = $(CFG_TARGET) doc/$(1)/index.html: $$(LIB_DOC_DEP_$(1)) doc/$(1)/ @$$(call E, rustdoc: $$@) - $$(Q)$$(RUSTDOC) --cfg dox --cfg stage2 $$< + $$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(CFG_BUILD)) \ + $$(RUSTDOC) --cfg dox --cfg stage2 $$< endef $(foreach crate,$(DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),DOC_TARGETS))) diff --git a/mk/llvm.mk b/mk/llvm.mk index bce43902056..ba2e0738039 100644 --- a/mk/llvm.mk +++ b/mk/llvm.mk @@ -49,6 +49,12 @@ else LLVM_STDCPP_LOCATION_$(1) = endif + +# LLVM linkage: +LLVM_LINKAGE_PATH_$(1):=$$(abspath $$(RT_OUTPUT_DIR_$(1))/llvmdeps.rs) +$$(LLVM_LINKAGE_PATH_$(1)): $(S)src/etc/mklldeps.py $$(LLVM_CONFIG_$(1)) + $(Q)$(CFG_PYTHON) "$$<" "$$@" "$$(LLVM_COMPONENTS)" "$$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \ + $$(LLVM_CONFIG_$(1)) endef $(foreach host,$(CFG_HOST), \ @@ -57,10 +63,14 @@ $(foreach host,$(CFG_HOST), \ $(foreach host,$(CFG_HOST), \ $(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_$(host)))) -$(S)src/librustc_llvm/llvmdeps.rs: \ - $(LLVM_CONFIGS) \ - $(S)src/etc/mklldeps.py \ - $(MKFILE_DEPS) - $(Q)$(CFG_PYTHON) $(S)src/etc/mklldeps.py \ - "$@" "$(LLVM_COMPONENTS)" "$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \ - $(LLVM_CONFIGS) +# This can't be done in target.mk because it's included before this file. +define LLVM_LINKAGE_DEPS +$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.rustc_llvm: $$(LLVM_LINKAGE_PATH_$(3)) +endef + +$(foreach source,$(CFG_HOST), \ + $(foreach target,$(CFG_TARGET), \ + $(eval $(call LLVM_LINKAGE_DEPS,0,$(target),$(source))) \ + $(eval $(call LLVM_LINKAGE_DEPS,1,$(target),$(source))) \ + $(eval $(call LLVM_LINKAGE_DEPS,2,$(target),$(source))) \ + $(eval $(call LLVM_LINKAGE_DEPS,3,$(target),$(source))))) diff --git a/mk/target.mk b/mk/target.mk index acdf780f105..5b0de64574c 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -79,7 +79,8 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \ $$(dir $$@)$$(call CFG_LIB_GLOB_$(2),$(4))) $$(call REMOVE_ALL_OLD_GLOB_MATCHES, \ $$(dir $$@)$$(call CFG_RLIB_GLOB,$(4))) - $$(STAGE$(1)_T_$(2)_H_$(3)) \ + $(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(2)) \ + $$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) \ $$(RUST_LIB_FLAGS_ST$(1)) \ -L "$$(RT_OUTPUT_DIR_$(2))" \ -L "$$(LLVM_LIBDIR_$(2))" \ @@ -134,8 +135,6 @@ SNAPSHOT_RUSTC_POST_CLEANUP=$(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD)) define TARGET_HOST_RULES -$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.rustc_llvm: $(S)src/librustc_llvm/llvmdeps.rs - $$(TBIN$(1)_T_$(2)_H_$(3))/: mkdir -p $$@ diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index d67d0fa59ae..8c12ccb9c8b 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -2214,4 +2214,6 @@ pub unsafe fn static_link_hack_this_sucks() { // parts of LLVM that rustllvm depends on aren't thrown away by the linker. // Works to the above fix for #15460 to ensure LLVM dependencies that // are only used by rustllvm don't get stripped by the linker. -mod llvmdeps; +mod llvmdeps { + include!(env!("CFG_LLVM_LINKAGE_FILE")) +}