@@ -181,3 +181,42 @@ $(foreach host,$(CFG_HOST), \
181
181
$(foreach stage,$(STAGES), \
182
182
$(foreach tool,$(TOOLS), \
183
183
$(eval $(call TARGET_TOOL,$(stage),$(target),$(host),$(tool)))))))
184
+
185
+ # We have some triples which are bootstrapped from other triples, and this means
186
+ # that we need to fixup some of the native tools that a triple depends on.
187
+ #
188
+ # For example, MSVC requires the llvm-ar.exe executable to manage archives, but
189
+ # it bootstraps from the GNU Windows triple. This means that the compiler will
190
+ # add this directory to PATH when executing new processes:
191
+ #
192
+ # $SYSROOT/rustlib/x86_64-pc-windows-gnu/bin
193
+ #
194
+ # Unfortunately, however, the GNU triple is not known about in stage0, so the
195
+ # tools are actually located in:
196
+ #
197
+ # $SYSROOT/rustlib/x86_64-pc-windows-msvc/bin
198
+ #
199
+ # To remedy this problem, the rules below copy all native tool dependencies into
200
+ # the bootstrap triple's location in stage 0 so the bootstrap compiler can find
201
+ # the right sets of tools. Later stages (1+) will have the right host triple for
202
+ # the compiler, so there's no need to worry there.
203
+ #
204
+ # $(1) - stage
205
+ # $(2) - triple that's being used as host/target
206
+ # $(3) - triple snapshot is built for
207
+ # $(4) - crate
208
+ # $(5) - tool
209
+ define MOVE_TOOLS_TO_SNAPSHOT_HOST_DIR
210
+ ifneq (,$(3 ) )
211
+ $$(TLIB$(1 ) _T_$(2 ) _H_$(2 ) ) /stamp.$(4 ) : $$(HLIB$(1 ) _H_$(2 ) ) /rustlib/$(3 ) /bin/$(5 )
212
+
213
+ $$(HLIB$(1 ) _H_$(2 ) ) /rustlib/$(3 ) /bin/$(5 ) : $$(TBIN$(1 ) _T_$(2 ) _H_$(2 ) ) /$(5 )
214
+ mkdir -p $$(@D )
215
+ cp $$< $$@
216
+ endif
217
+ endef
218
+
219
+ $(foreach target,$(CFG_TARGET), \
220
+ $(foreach crate,$(CRATES), \
221
+ $(foreach tool,$(NATIVE_TOOL_DEPS_$(crate)_T_$(target)), \
222
+ $(eval $(call MOVE_TOOLS_TO_SNAPSHOT_HOST_DIR,0,$(target),$(BOOTSTRAP_FROM_$(target)),$(crate),$(tool))))))
0 commit comments