@@ -51,34 +51,6 @@ CARGO_BUILD_FLAGS = "\
51
51
${EXTRA_CARGO_FLAGS} \
52
52
"
53
53
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
-
68
- # (Rust unstable) - See do_compile below.
69
- echo "[host]" >> ${CARGO_HOME} /config
70
- echo "linker = '${WRAPPER_DIR} /linker-native-wrapper.sh'" >> ${CARGO_HOME} /config
71
- fi
72
-
73
- echo >> ${CARGO_HOME} /config
74
- echo "[build]" >> ${CARGO_HOME} /config
75
- echo "rustflags = ['-C', 'rpath']" >> ${CARGO_HOME} /config
76
-
77
- echo >> ${CARGO_HOME} /config
78
- echo "[profile.release]" >> ${CARGO_HOME} /config
79
- echo "debug = true" >> ${CARGO_HOME} /config
80
- }
81
-
82
54
cargo_bin_do_configure () {
83
55
mkdir -p "${B} "
84
56
mkdir -p "${CARGO_HOME} "
@@ -110,9 +82,6 @@ cargo_bin_do_configure() {
110
82
echo "#!/bin/sh" >"${WRAPPER_DIR} /linker-native-wrapper.sh"
111
83
echo "${BUILD_CC} ${BUILD_LDFLAGS} \" \$@\" " >>"${WRAPPER_DIR} /linker-native-wrapper.sh"
112
84
chmod +x "${WRAPPER_DIR} /linker-native-wrapper.sh"
113
-
114
- # Create our global config in CARGO_HOME
115
- create_cargo_config
116
85
}
117
86
118
87
cargo_bin_do_compile () {
@@ -123,20 +92,24 @@ cargo_bin_do_compile() {
123
92
export PKG_CONFIG_ALLOW_CROSS = "1"
124
93
export LDFLAGS = ""
125
94
export RUSTFLAGS = "${RUSTFLAGS} "
126
- export SSH_AUTH_SOCK = "${SSH_AUTH_SOCK} "
127
- # When RUST_BUILD == RUST_TARGET, we need to use an unstable Rust feature
128
- # to specify different build options for the target and the Host.
129
- # The Host configuration is set in do_configure() above.
130
- if [ "${RUST_BUILD} " = "${RUST_TARGET} " ]; then
131
- export __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS = "nightly"
132
- export CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST = "true"
133
- export CARGO_UNSTABLE_HOST_CONFIG = "true"
134
- export CARGO_TARGET_APPLIES_TO_HOST = "false"
135
-
136
- # Make sure the cc crate does not use CFLAGS when building for the host.
137
- export HOST_CFLAGS = ""
138
- export HOST_CXXFLAGS = ""
139
- fi
95
+
96
+ # This "DO_NOT_USE_THIS" option of cargo is currently the only way to
97
+ # configure a different linker for host and target builds when RUST_BUILD ==
98
+ # RUST_TARGET.
99
+ export __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS = "nightly"
100
+ export CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST = "true"
101
+ export CARGO_UNSTABLE_HOST_CONFIG = "true"
102
+ export CARGO_TARGET_APPLIES_TO_HOST = "false"
103
+ export CARGO_TARGET_ ${@ rust_target (d , 'BUILD' ). replace ('-' , '_' )}_LINKER = "${WRAPPER_DIR} /linker-wrapper.sh"
104
+ export CARGO_HOST_LINKER = "${WRAPPER_DIR} /linker-native-wrapper.sh"
105
+ export CARGO_BUILD_FLAGS = "-C rpath"
106
+ export CARGO_PROFILE_RELEASE_DEBUG = "true"
107
+
108
+ # The CC crate defaults to using CFLAGS when compiling everything. We can
109
+ # give it custom flags for compiling on the host.
110
+ export HOST_CXXFLAGS = ""
111
+ export HOST_CFLAGS = ""
112
+
140
113
bbnote "which rustc:" `which rustc `
141
114
bbnote "rustc --version" `rustc --version `
142
115
bbnote "which cargo:" `which cargo `
0 commit comments