@@ -349,21 +349,44 @@ EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
349349
350350CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
351351
352+ endef
353+
354+ # Same macro/variables as above, but defined in a separate loop so it can use
355+ # all the varibles above for all archs. The RPATH_VAR setup sometimes needs to
356+ # reach across triples to get things in order.
357+ define SREQ_CMDS
358+
359+ ifeq ($$(OSTYPE_$(3)),apple-darwin)
360+ RPATH_VAR$(1)_T_$(2)_H_$(3) := \
361+ DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
362+ else
363+ RPATH_VAR$(1)_T_$(2)_H_$(3) := \
364+ LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
365+ endif
366+
352367# Pass --cfg stage0 only for the build->host part of stage0;
353368# if you're building a cross config, the host->* parts are
354369# effectively stage1, since it uses the just-built stage0.
370+ #
371+ # This logic is similar to how the LD_LIBRARY_PATH variable must
372+ # change be slightly different when doing cross compilations.
373+ # The build doesn't copy over all target libraries into
374+ # a new directory, so we need to point the library path at
375+ # the build directory where all the target libraries came
376+ # from (the stage0 build host). Otherwise the relative rpaths
377+ # inside of the rustc binary won't get resolved correctly.
355378ifeq ($(1),0)
356379ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
357380CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
358- endif
359- endif
360381
361382ifeq ($$(OSTYPE_$(3)),apple-darwin)
362383 RPATH_VAR$(1)_T_$(2)_H_$(3) := \
363- DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1 )_H_$(3 ))"
384+ DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(TLIB1_T_$(2 )_H_$(CFG_BUILD ))"
364385else
365386 RPATH_VAR$(1)_T_$(2)_H_$(3) := \
366- LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
387+ LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(TLIB1_T_$(2)_H_$(CFG_BUILD))"
388+ endif
389+ endif
367390endif
368391
369392STAGE$(1)_T_$(2)_H_$(3) := \
@@ -390,6 +413,11 @@ $(foreach build,$(CFG_HOST), \
390413 $(eval $(foreach stage,$(STAGES), \
391414 $(eval $(call SREQ,$(stage),$(target),$(build))))))))
392415
416+ $(foreach build,$(CFG_HOST), \
417+ $(eval $(foreach target,$(CFG_TARGET), \
418+ $(eval $(foreach stage,$(STAGES), \
419+ $(eval $(call SREQ_CMDS,$(stage),$(target),$(build))))))))
420+
393421######################################################################
394422# rustc-H-targets
395423#
0 commit comments