@@ -51,30 +51,6 @@ CARGO_BUILD_FLAGS = "\
5151 ${EXTRA_CARGO_FLAGS} \
5252"
5353
54- create_cargo_config () {
55- if [ "${RUST_BUILD} " != "${RUST_TARGET} " ]; then
56- echo > ${CARGO_HOME} /config
57- echo "[target.${RUST_BUILD} ]" >> ${CARGO_HOME} /config
58- echo "linker = '${WRAPPER_DIR} /linker-native-wrapper.sh'" >> ${CARGO_HOME} /config
59-
60- echo >> ${CARGO_HOME} /config
61- echo "[target.${RUST_TARGET} ]" >> ${CARGO_HOME} /config
62- echo "linker = '${WRAPPER_DIR} /linker-wrapper.sh'" >> ${CARGO_HOME} /config
63- else
64- echo > ${CARGO_HOME} /config
65- echo "[target.${RUST_TARGET} ]" >> ${CARGO_HOME} /config
66- echo "linker = '${WRAPPER_DIR} /linker-wrapper.sh'" >> ${CARGO_HOME} /config
67- fi
68-
69- echo >> ${CARGO_HOME} /config
70- echo "[build]" >> ${CARGO_HOME} /config
71- echo "rustflags = ['-C', 'rpath']" >> ${CARGO_HOME} /config
72-
73- echo >> ${CARGO_HOME} /config
74- echo "[profile.release]" >> ${CARGO_HOME} /config
75- echo "debug = true" >> ${CARGO_HOME} /config
76- }
77-
7854cargo_bin_do_configure () {
7955 mkdir -p "${B} "
8056 mkdir -p "${CARGO_HOME} "
@@ -106,22 +82,35 @@ cargo_bin_do_configure() {
10682 echo "#!/bin/sh" >"${WRAPPER_DIR} /linker-native-wrapper.sh"
10783 echo "${BUILD_CC} ${BUILD_LDFLAGS} \" \$@\" " >>"${WRAPPER_DIR} /linker-native-wrapper.sh"
10884 chmod +x "${WRAPPER_DIR} /linker-native-wrapper.sh"
109-
110- # Create our global config in CARGO_HOME
111- create_cargo_config
11285}
11386
11487cargo_bin_do_compile () {
11588 export TARGET_CC = "${WRAPPER_DIR} /cc-wrapper.sh"
11689 export TARGET_CXX = "${WRAPPER_DIR} /cxx-wrapper.sh"
11790 export CC = "${WRAPPER_DIR} /cc-native-wrapper.sh"
11891 export CXX = "${WRAPPER_DIR} /cxx-native-wrapper.sh"
119- export TARGET_LD = "${WRAPPER_DIR} /ld-wrapper.sh"
120- export LD = "${WRAPPER_DIR} /ld-native-wrapper.sh"
12192 export PKG_CONFIG_ALLOW_CROSS = "1"
12293 export LDFLAGS = ""
12394 export RUSTFLAGS = "${RUSTFLAGS} "
12495 export SSH_AUTH_SOCK = "${SSH_AUTH_SOCK} "
96+
97+ # This "DO_NOT_USE_THIS" option of cargo is currently the only way to
98+ # configure a different linker for host and target builds when RUST_BUILD ==
99+ # RUST_TARGET.
100+ export __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS = "nightly"
101+ export CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST = "true"
102+ export CARGO_UNSTABLE_HOST_CONFIG = "true"
103+ export CARGO_TARGET_APPLIES_TO_HOST = "false"
104+ export CARGO_TARGET_ ${@ rust_target (d , 'BUILD' ). replace ('-' , '_' )}_LINKER = "${WRAPPER_DIR} /linker-wrapper.sh"
105+ export CARGO_HOST_LINKER = "${WRAPPER_DIR} /linker-native-wrapper.sh"
106+ export CARGO_BUILD_FLAGS = "-C rpath"
107+ export CARGO_PROFILE_RELEASE_DEBUG = "true"
108+
109+ # The CC crate defaults to using CFLAGS when compiling everything. We can
110+ # give it custom flags for compiling on the host.
111+ export HOST_CXXFLAGS = ""
112+ export HOST_CFLAGS = ""
113+
125114 bbnote "which rustc:" `which rustc `
126115 bbnote "rustc --version" `rustc --version `
127116 bbnote "which cargo:" `which cargo `
0 commit comments