From ee3443f1d960460f6f919fb924683fb9775ac75b Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 1 May 2023 01:07:03 +0900 Subject: [PATCH] Update scripts --- tools/build.sh | 10 ++++------ tools/no-std.sh | 10 +++++----- tools/test.sh | 4 ++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/tools/build.sh b/tools/build.sh index a66d6614..e6be658a 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -261,6 +261,7 @@ build() { local target_flags=(--target "${target}") fi args+=("${target_flags[@]}") + cfgs=$(RUSTC_BOOTSTRAP=1 rustc ${pre_args[@]+"${pre_args[@]}"} --print cfg "${target_flags[@]}") if grep <<<"${rustup_target_list}" -Eq "^${target}$"; then rustup ${pre_args[@]+"${pre_args[@]}"} target add "${target}" &>/dev/null elif [[ -n "${nightly}" ]]; then @@ -279,18 +280,15 @@ build() { # On musl, building std with pre-1.59 nightly requires musl toolchain. args+=(-Z build-std="core,alloc") args+=(--exclude-features "std") + elif grep <<<"${cfgs}" -q 'panic="abort"'; then + args+=(-Z build-std="panic_abort,std") else - case "${target}" in - # panic=abort - *-espidf*) args+=(-Z build-std="panic_abort,std") ;; - *) args+=(-Z build-std) ;; - esac + args+=(-Z build-std) fi else echo "target '${target}' requires nightly compiler (skipped all checks)" return 0 fi - cfgs=$(RUSTC_BOOTSTRAP=1 rustc ${pre_args[@]+"${pre_args[@]}"} --print cfg "${target_flags[@]}") has_atomic_cas='1' # target_has_atomic changed in 1.40.0-nightly: https://github.com/rust-lang/rust/pull/65214 if [[ "${rustc_minor_version}" -ge 40 ]]; then diff --git a/tools/no-std.sh b/tools/no-std.sh index 629309ff..b3b46aa9 100755 --- a/tools/no-std.sh +++ b/tools/no-std.sh @@ -83,7 +83,7 @@ fi rustup_target_list='' if [[ -z "${is_custom_toolchain}" ]]; then - rustup_target_list=$(rustup ${pre_args[@]+"${pre_args[@]}"} target list) + rustup_target_list=$(rustup ${pre_args[@]+"${pre_args[@]}"} target list | sed 's/ .*//g') fi rustc_target_list=$(rustc ${pre_args[@]+"${pre_args[@]}"} --print target-list) rustc_version=$(rustc ${pre_args[@]+"${pre_args[@]}"} -Vv | grep 'release: ' | sed 's/release: //') @@ -105,9 +105,9 @@ run() { echo "target '${target}' not available on ${rustc_version} (skipped)" return 0 fi - target_flags=(--target "$(pwd)/target-specs/${target}.json") + local target_flags=(--target "$(pwd)/target-specs/${target}.json") else - target_flags=(--target "${target}") + local target_flags=(--target "${target}") fi local subcmd=run case "${target}" in @@ -125,8 +125,8 @@ run() { ;; esac args+=("${subcmd}" "${target_flags[@]}") - if grep <<<"${rustup_target_list}" -Eq "^${target}( |$)"; then - x rustup ${pre_args[@]+"${pre_args[@]}"} target add "${target}" &>/dev/null + if grep <<<"${rustup_target_list}" -Eq "^${target}$"; then + rustup ${pre_args[@]+"${pre_args[@]}"} target add "${target}" &>/dev/null elif [[ -n "${nightly}" ]]; then args+=(-Z build-std="core") else diff --git a/tools/test.sh b/tools/test.sh index d08b58a9..57ab4dca 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -72,7 +72,7 @@ done cargo="${cargo:-cargo}" if type -P rustup &>/dev/null; then - rustup_target_list=$(rustup ${pre_args[@]+"${pre_args[@]}"} target list) + rustup_target_list=$(rustup ${pre_args[@]+"${pre_args[@]}"} target list | sed 's/ .*//g') fi rustc_target_list=$(rustc ${pre_args[@]+"${pre_args[@]}"} --print target-list) rustc_version=$(rustc ${pre_args[@]+"${pre_args[@]}"} -Vv | grep 'release: ' | sed 's/release: //') @@ -103,7 +103,7 @@ if [[ -n "${target}" ]]; then fi args+=("${target_flags[@]}") if type -P rustup &>/dev/null; then - if grep <<<"${rustup_target_list}" -Eq "^${target}( |$)"; then + if grep <<<"${rustup_target_list}" -Eq "^${target}$"; then rustup ${pre_args[@]+"${pre_args[@]}"} target add "${target}" &>/dev/null elif [[ -n "${nightly}" ]]; then if [[ -z "${build_std}" ]]; then