mk: Fix cross-host builds

The change in b20e748 had the unintended consequence of breaking cross-host
builds as we apparently relied on the incorrect definition of this variable in
the makefiles. That change, however, was required to get tests passing so we
couldn't just revert it.

This commit fixes the underlying bug by leaving the "more correct" definition of
`LD_LIBRARY_PATH_ENV_TARGETDIR` (also fixing it with a hardcoded reference to
`CFG_BUILD`) and updating the `RPATH_VAR` definition below. Turned out we
already had special-casing logic for passing `--cfg stage1` during the
well-we-print-this-as-stage0 build of a cross-host. That logic was just updated
to pull from a different variable as opposed to relying on the definition of
that variable to accommodate this.

Closes #32568
This commit is contained in:
Alex Crichton 2016-03-29 08:24:02 -07:00
parent a11129701c
commit 694d88394b
1 changed files with 5 additions and 9 deletions

View File

@ -493,7 +493,7 @@ endif
LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3) := \
$$(CURDIR)/$$(HLIB$(1)_H_$(3)):$$(CFG_LLVM_INST_DIR_$(3))/lib
LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3) := \
$$(CURDIR)/$$(TLIB$(1)_T_$(2)_H_$(CFG_BUILD))
$$(CURDIR)/$$(TLIB$(1)_T_$(2)_H_$(3))
HOST_RPATH_VAR$(1)_T_$(2)_H_$(3) := \
$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))=$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3)):$$$$$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))
@ -506,18 +506,14 @@ RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(HOST_RPATH_VAR$(1)_T_$(2)_H_$(3))
# if you're building a cross config, the host->* parts are
# effectively stage1, since it uses the just-built stage0.
#
# This logic is similar to how the LD_LIBRARY_PATH variable must
# change be slightly different when doing cross compilations.
# The build doesn't copy over all target libraries into
# a new directory, so we need to point the library path at
# the build directory where all the target libraries came
# from (the stage0 build host). Otherwise the relative rpaths
# inside of the rustc binary won't get resolved correctly.
# Also be sure to use the right rpath because we're loading libraries from the
# CFG_BUILD's stage1 directory for our target, so switch this one instance of
# `RPATH_VAR` to get the bootstrap working.
ifeq ($(1),0)
ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3))
RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(TARGET_RPATH_VAR1_T_$(2)_H_$$(CFG_BUILD))
endif
endif