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