@@ -349,21 +349,44 @@ EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
349
349
350
350
CFGFLAG$(1 ) _T_$(2 ) _H_$(3 ) = stage$(1 )
351
351
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
+
352
367
# Pass --cfg stage0 only for the build->host part of stage0;
353
368
# if you're building a cross config, the host->* parts are
354
369
# 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.
355
378
ifeq ($(1 ) ,0)
356
379
ifneq ($(strip $(CFG_BUILD ) ) ,$(strip $(3 ) ) )
357
380
CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
358
- endif
359
- endif
360
381
361
382
ifeq ($$(OSTYPE_$(3 ) ) ,apple-darwin)
362
383
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 ) ) "
364
385
else
365
386
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
367
390
endif
368
391
369
392
STAGE$(1 ) _T_$(2 ) _H_$(3 ) := \
@@ -390,6 +413,11 @@ $(foreach build,$(CFG_HOST), \
390
413
$(eval $(foreach stage,$(STAGES), \
391
414
$(eval $(call SREQ,$(stage),$(target),$(build))))))))
392
415
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
+
393
421
# #####################################################################
394
422
# rustc-H-targets
395
423
#
0 commit comments