@@ -275,6 +275,7 @@ build() {
275275 shift
276276 local args=(" ${base_args[@]} " )
277277 local target_rustflags=" ${base_rustflags} "
278+ local rustc_target_flags=()
278279 if ! grep -Eq " ^${target} $" <<< " ${rustc_target_list}" || [[ -f " target-specs/${target} .json" ]]; then
279280 if [[ " ${target} " == " avr-none" ]]; then
280281 target=avr-unknown-gnu-atmega2560 # custom target
@@ -295,19 +296,21 @@ build() {
295296 info " target '${target} ' requires 1.91-nightly or later (skipped)"
296297 return 0
297298 fi
298- local target_flags=(--target " ${workspace_dir} /target-specs/${target} .json" )
299299 if { cargo ${pre_args[@]+" ${pre_args[@]} " } -Z help || true ; } | grep -Fq json-target-spec; then
300300 args+=(-Z json-target-spec)
301+ rustc_target_flags+=(-Z unstable-options)
301302 fi
303+ args+=(--target " ${workspace_dir} /target-specs/${target} .json" )
304+ rustc_target_flags+=(--target " ${workspace_dir} /target-specs/${target} .json" )
302305 elif [[ " ${target} " != " ${host} " ]]; then
303- local target_flags=(--target " ${target} " )
306+ args+=(--target " ${target} " )
307+ rustc_target_flags+=(--target " ${target} " )
304308 else
305- local no_target_flags=' 1 '
309+ local no_target_flags=1
306310 fi
307- args+=(${target_flags[@]+" ${target_flags[@]} " } )
308311 local cfgs
309312 if grep -Eq " ^${target} $" <<< " ${rustup_target_list}" ; then
310- cfgs=$( RUSTC_BOOTSTRAP=1 rustc ${pre_args[@]+" ${pre_args[@]} " } --print cfg ${target_flags [@]+" ${target_flags [@]} " } )
313+ cfgs=$( RUSTC_BOOTSTRAP=1 rustc ${pre_args[@]+" ${pre_args[@]} " } --print cfg ${rustc_target_flags [@]+" ${rustc_target_flags [@]} " } )
311314 retry rustup ${pre_args[@]+" ${pre_args[@]} " } target add " ${target} " & > /dev/null
312315 # core/alloc/std sets feature(strict_provenance_lints), so we cannot use
313316 # -Z crate-attr=feature(strict_provenance_lints) when -Z build-std is needed.
@@ -318,7 +321,7 @@ build() {
318321 info " -Z build-std not available on ${rustc_version} (skipped all checks for '${target} ')"
319322 return 0
320323 fi
321- cfgs=$( RUSTC_BOOTSTRAP=1 rustc ${pre_args[@]+" ${pre_args[@]} " } --print cfg ${target_flags [@]+" ${target_flags [@]} " } )
324+ cfgs=$( RUSTC_BOOTSTRAP=1 rustc ${pre_args[@]+" ${pre_args[@]} " } --print cfg ${rustc_target_flags [@]+" ${rustc_target_flags [@]} " } )
322325 if [[ -n " ${TARGET_GROUP:- } " ]]; then
323326 case " ${target} " in
324327 # builtin xtensa targets are completely broken with builtin LLVM (last checked: nightly-2025-09-11): https://github.com/rust-lang/rust/pull/125141#discussion_r1637484228
@@ -633,14 +636,14 @@ build() {
633636 if grep -Eq " ^target_os=\" (aix|android|freebsd|hurd|linux|nto|redox|teeos|trusty|vxworks|wasi|windows)\" " <<< " ${cfgs}" ; then
634637 if grep -Eq ' ^target_feature="crt-static"' <<< " ${cfgs}" ; then
635638 CARGO_TARGET_DIR=" ${target_dir} /no-crt-static" \
636- RUSTFLAGS=" ${target_rustflags} -C target_feature =-crt-static" \
639+ RUSTFLAGS=" ${target_rustflags} -C target-feature =-crt-static" \
637640 x_cargo " ${args[@]} " " $@ "
638641 CARGO_TARGET_DIR=" ${target_dir} /no-crt-static-no-outline-atomics" \
639- RUSTFLAGS=" ${target_rustflags} -C target_feature =-crt-static --cfg portable_atomic_no_outline_atomics" \
642+ RUSTFLAGS=" ${target_rustflags} -C target-feature =-crt-static --cfg portable_atomic_no_outline_atomics" \
640643 x_cargo " ${args[@]} " " $@ "
641644 else
642645 CARGO_TARGET_DIR=" ${target_dir} /crt-static" \
643- RUSTFLAGS=" ${target_rustflags} -C target_feature =+crt-static" \
646+ RUSTFLAGS=" ${target_rustflags} -C target-feature =+crt-static" \
644647 x_cargo " ${args[@]} " ${no_target_flags+" --target=${target} " } " $@ "
645648 fi
646649 fi
0 commit comments