|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Update the list of targets that do not support atomic/CAS operations. |
| 4 | +# |
| 5 | +# Usage: |
| 6 | +# ./ci/no_atomic.sh |
| 7 | + |
| 8 | +set -euo pipefail |
| 9 | +IFS=$'\n\t' |
| 10 | + |
| 11 | +cd "$(cd "$(dirname "$0")" && pwd)"/.. |
| 12 | + |
| 13 | +file="no_atomic.rs" |
| 14 | + |
| 15 | +{ |
| 16 | + echo "// This file is @generated by $(basename "$0")." |
| 17 | + echo "// It is not intended for manual editing." |
| 18 | + echo "" |
| 19 | +} >"$file" |
| 20 | + |
| 21 | +echo "const NO_ATOMIC_CAS: &[&str] = &[" >>"$file" |
| 22 | +for target in $(rustc --print target-list); do |
| 23 | + res=$(rustc --print target-spec-json -Z unstable-options --target "$target" \ |
| 24 | + | jq -r "select(.\"atomic-cas\" == false)") |
| 25 | + [[ -z "$res" ]] || echo " \"$target\"," >>"$file" |
| 26 | +done |
| 27 | +echo "];" >>"$file" |
| 28 | + |
| 29 | +{ |
| 30 | + # Only crossbeam-utils actually uses this const. |
| 31 | + echo "#[allow(dead_code)]" |
| 32 | + echo "const NO_ATOMIC_64: &[&str] = &[" |
| 33 | +} >>"$file" |
| 34 | +for target in $(rustc --print target-list); do |
| 35 | + res=$(rustc --print target-spec-json -Z unstable-options --target "$target" \ |
| 36 | + | jq -r "select(.\"max-atomic-width\" == 32)") |
| 37 | + [[ -z "$res" ]] || echo " \"$target\"," >>"$file" |
| 38 | +done |
| 39 | +# It is not clear exactly what `"max-atomic-width" == null` means, but they |
| 40 | +# actually seem to have the same max-atomic-width as the target-pointer-width. |
| 41 | +# The targets currently included in this group are "mipsel-sony-psp", |
| 42 | +# "thumbv4t-none-eabi", "thumbv6m-none-eabi", all of which are |
| 43 | +# `"target-pointer-width" == "32"`, so assuming them `"max-atomic-width" == 32` |
| 44 | +# for now. |
| 45 | +for target in $(rustc --print target-list); do |
| 46 | + res=$(rustc --print target-spec-json -Z unstable-options --target "$target" \ |
| 47 | + | jq -r "select(.\"max-atomic-width\" == null)") |
| 48 | + [[ -z "$res" ]] || echo " \"$target\"," >>"$file" |
| 49 | +done |
| 50 | +echo "];" >>"$file" |
| 51 | + |
| 52 | +# There is no `"max-atomic-width" == 16` or `"max-atomic-width" == 8` targets. |
| 53 | + |
| 54 | +# `"max-atomic-width" == 0` means that atomic is not supported at all. |
| 55 | +{ |
| 56 | + # Only crossbeam-utils actually uses this const. |
| 57 | + echo "#[allow(dead_code)]" |
| 58 | + echo "const NO_ATOMIC: &[&str] = &[" |
| 59 | +} >>"$file" |
| 60 | +for target in $(rustc --print target-list); do |
| 61 | + res=$(rustc --print target-spec-json -Z unstable-options --target "$target" \ |
| 62 | + | jq -r "select(.\"max-atomic-width\" == 0)") |
| 63 | + [[ -z "$res" ]] || echo " \"$target\"," >>"$file" |
| 64 | +done |
| 65 | +echo "];" >>"$file" |
0 commit comments