Skip to content

Commit

Permalink
ci: Clean up no_atomic.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Dec 15, 2024
1 parent 5ab2fe4 commit 5092a9b
Showing 1 changed file with 13 additions and 34 deletions.
47 changes: 13 additions & 34 deletions ci/no_atomic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,24 @@ cd "$(dirname "$0")"/..
# Usage:
# ./ci/no_atomic.sh

file="no_atomic.rs"
file=no_atomic.rs

no_atomic=()
for target_spec in $(RUSTC_BOOTSTRAP=1 rustc +stable -Z unstable-options --print all-target-specs-json | jq -c '. | to_entries | .[]'); do
target=$(jq <<<"${target_spec}" -r '.key')
target_spec=$(jq <<<"${target_spec}" -c '.value')
res=$(jq <<<"${target_spec}" -r 'select(."atomic-cas" == false)')
[[ -z "${res}" ]] || no_atomic_cas+=("${target}")
max_atomic_width=$(jq <<<"${target_spec}" -r '."max-atomic-width"')
min_atomic_width=$(jq <<<"${target_spec}" -r '."min-atomic-width"')
case "${max_atomic_width}" in
# `"max-atomic-width" == 0` means that atomic is not supported at all.
# We do not have a cfg for targets with {8,16}-bit atomic only, so
# for now we treat them the same as targets that do not support atomic.
0) no_atomic+=("${target}") ;;
# It is not clear exactly what `"max-atomic-width" == null` means, but they
# actually seem to have the same max-atomic-width as the target-pointer-width.
# The targets currently included in this group are "mipsel-sony-psp",
# "thumbv4t-none-eabi", "thumbv6m-none-eabi", all of which are
# `"target-pointer-width" == "32"`, so assuming them `"max-atomic-width" == 32`
# for now.
null | 8 | 16 | 32 | 64 | 128) ;;
*) exit 1 ;;
esac
case "${min_atomic_width}" in
8 | null) ;;
*) no_atomic+=("${target}") ;;
esac
done
# `"max-atomic-width" == 0` means that atomic is not supported at all.
# We do not have a cfg for targets with {8,16}-bit atomic only, so
# for now we treat them the same as targets that do not support atomic.
# It is not clear exactly what `"max-atomic-width" == null` means, but they
# actually seem to have the same max-atomic-width as the target-pointer-width.
# The targets currently included in this group are "mipsel-sony-psp",
# "thumbv4t-none-eabi", "thumbv6m-none-eabi", all of which are
# `"target-pointer-width" == "32"`, so assuming them `"max-atomic-width" == 32`
# for now.
no_atomic=$(RUSTC_BOOTSTRAP=1 rustc +stable -Z unstable-options --print all-target-specs-json | jq -r '. | to_entries[] | select((.value."max-atomic-width" == 0) or (.value."min-atomic-width" and .value."min-atomic-width" != 8)) | " \"" + .key + "\","')

cat >"${file}" <<EOF
// This file is @generated by $(basename "$0").
// This file is @generated by ${0##*/}.
// It is not intended for manual editing.
const NO_ATOMIC: &[&str] = &[
EOF
for target in "${no_atomic[@]}"; do
echo " \"${target}\"," >>"${file}"
done
cat >>"${file}" <<EOF
${no_atomic}
];
EOF

0 comments on commit 5092a9b

Please sign in to comment.