@@ -187,6 +187,7 @@ rustc_minor_version="${rustc_minor_version%%.*}"
187
187
llvm_version=$( rustc ${pre_args[@]+" ${pre_args[@]} " } -Vv | (grep ' LLVM version: ' || true) | (sed ' s/LLVM version: //' || true))
188
188
llvm_version=" ${llvm_version%% .* } "
189
189
base_args=(${pre_args[@]+" ${pre_args[@]} " } hack build)
190
+ target_dir=$( pwd) /target
190
191
nightly=' '
191
192
if [[ " ${rustc_version} " == * " nightly" * ]] || [[ " ${rustc_version} " == * " dev" * ]]; then
192
193
nightly=1
@@ -253,8 +254,9 @@ build() {
253
254
case " ${target} " in
254
255
* -apple-* ) ;;
255
256
* )
256
- RUSTFLAGS=" ${target_rustflags} -C target-feature=+cmpxchg16b" \
257
- x_cargo " ${args[@]} " --target-dir target/cmpxchg16b " $@ "
257
+ CARGO_TARGET_DIR=" ${target_dir} /cmpxchg16b" \
258
+ RUSTFLAGS=" ${target_rustflags} -C target-feature=+cmpxchg16b" \
259
+ x_cargo " ${args[@]} " " $@ "
258
260
;;
259
261
esac
260
262
;;
@@ -263,39 +265,48 @@ build() {
263
265
case " ${target} " in
264
266
* -darwin) ;;
265
267
* )
266
- RUSTFLAGS=" ${target_rustflags} -C target-feature=+lse" \
267
- x_cargo " ${args[@]} " --target-dir target/lse " $@ "
268
+ CARGO_TARGET_DIR=" ${target_dir} /lse" \
269
+ RUSTFLAGS=" ${target_rustflags} -C target-feature=+lse" \
270
+ x_cargo " ${args[@]} " " $@ "
268
271
# FEAT_LSE2 doesn't imply FEAT_LSE.
269
- RUSTFLAGS=" ${target_rustflags} -C target-feature=+lse,+lse2" \
270
- x_cargo " ${args[@]} " --target-dir target/lse2 " $@ "
271
- RUSTFLAGS=" ${target_rustflags} -C target-feature=+rcpc" \
272
- x_cargo " ${args[@]} " --target-dir target/rcpc " $@ "
272
+ CARGO_TARGET_DIR=" ${target_dir} /lse2" \
273
+ RUSTFLAGS=" ${target_rustflags} -C target-feature=+lse,+lse2" \
274
+ x_cargo " ${args[@]} " " $@ "
275
+ CARGO_TARGET_DIR=" ${target_dir} /rcpc" \
276
+ RUSTFLAGS=" ${target_rustflags} -C target-feature=+rcpc" \
277
+ x_cargo " ${args[@]} " " $@ "
273
278
;;
274
279
esac
275
280
# Support for FEAT_LRCPC3 and FEAT_LSE128 requires LLVM 16+.
276
281
if [[ " ${llvm_version} " -ge 16 ]]; then
277
- RUSTFLAGS=" ${target_rustflags} -C target-feature=+lse,+lse2,+rcpc3" \
278
- x_cargo " ${args[@]} " --target-dir target/rcpc3 " $@ "
282
+ CARGO_TARGET_DIR=" ${target_dir} /rcpc3" \
283
+ RUSTFLAGS=" ${target_rustflags} -C target-feature=+lse,+lse2,+rcpc3" \
284
+ x_cargo " ${args[@]} " " $@ "
279
285
# FEAT_LSE128 implies FEAT_LSE but not FEAT_LSE2.
280
- RUSTFLAGS=" ${target_rustflags} -C target-feature=+lse2,+lse128" \
281
- x_cargo " ${args[@]} " --target-dir target/lse128 " $@ "
282
- RUSTFLAGS=" ${target_rustflags} -C target-feature=+lse2,+lse128,+rcpc3" \
283
- x_cargo " ${args[@]} " --target-dir target/lse128-rcpc3 " $@ "
286
+ CARGO_TARGET_DIR=" ${target_dir} /lse128" \
287
+ RUSTFLAGS=" ${target_rustflags} -C target-feature=+lse2,+lse128" \
288
+ x_cargo " ${args[@]} " " $@ "
289
+ CARGO_TARGET_DIR=" ${target_dir} /lse128-rcpc3" \
290
+ RUSTFLAGS=" ${target_rustflags} -C target-feature=+lse2,+lse128,+rcpc3" \
291
+ x_cargo " ${args[@]} " " $@ "
284
292
fi
285
293
;;
286
294
powerpc64-* )
287
295
# powerpc64le- (little-endian) is skipped because it is pwr8 by default
288
- RUSTFLAGS=" ${target_rustflags} -C target-cpu=pwr8" \
289
- x_cargo " ${args[@]} " --target-dir target/pwr8 " $@ "
296
+ CARGO_TARGET_DIR=" ${target_dir} /pwr8" \
297
+ RUSTFLAGS=" ${target_rustflags} -C target-cpu=pwr8" \
298
+ x_cargo " ${args[@]} " " $@ "
290
299
;;
291
300
powerpc64le-* )
292
301
# powerpc64- (big-endian) is skipped because it is pre-pwr8 by default
293
- RUSTFLAGS=" ${target_rustflags} -C target-cpu=pwr7" \
294
- x_cargo " ${args[@]} " --target-dir target/pwr7 " $@ "
302
+ CARGO_TARGET_DIR=" ${target_dir} /pwr7" \
303
+ RUSTFLAGS=" ${target_rustflags} -C target-cpu=pwr7" \
304
+ x_cargo " ${args[@]} " " $@ "
295
305
;;
296
306
s390x* )
297
- RUSTFLAGS=" ${target_rustflags} -C target-cpu=z196" \
298
- x_cargo " ${args[@]} " --target-dir target/z196 " $@ "
307
+ CARGO_TARGET_DIR=" ${target_dir} /z196" \
308
+ RUSTFLAGS=" ${target_rustflags} -C target-cpu=z196" \
309
+ x_cargo " ${args[@]} " " $@ "
299
310
;;
300
311
esac
301
312
}
0 commit comments