Skip to content

Commit 85d0bdc

Browse files
bors[bot]taiki-e
andauthored
Merge #776
776: Automatically creates PR when no_atomic.rs needs to be updated r=taiki-e a=taiki-e follow-up #698 Co-authored-by: Taiki Endo <[email protected]>
2 parents 8d0080d + 4d02994 commit 85d0bdc

File tree

17 files changed

+160
-126
lines changed

17 files changed

+160
-126
lines changed

.github/workflows/ci.yml

+35-4
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,40 @@ jobs:
100100
run: ./ci/dependencies.sh
101101

102102
# When this job failed, run ci/no_atomic.sh and commit result changes.
103-
# TODO(taiki-e): Ideally, this should be automated using a bot that creates
104-
# PR when failed, but there is no bandwidth to implement it
105-
# right now...
106103
codegen:
107104
runs-on: ubuntu-latest
105+
permissions:
106+
contents: write
107+
pull-requests: write
108108
steps:
109109
- uses: actions/checkout@v2
110110
- name: Install Rust
111111
run: rustup update nightly && rustup default nightly
112112
- run: ci/no_atomic.sh
113-
- run: git diff --exit-code
113+
- run: git add -N . && git diff --exit-code
114+
if: github.event_name != 'schedule' && !(github.event_name == 'push' && github.ref == 'refs/heads/main')
115+
- id: diff
116+
run: |
117+
git config user.name "Taiki Endo"
118+
git config user.email "[email protected]"
119+
git add -N .
120+
if ! git diff --exit-code; then
121+
git add .
122+
git commit -m "Update no_atomic.rs"
123+
echo "::set-output name=success::false"
124+
fi
125+
if: github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main'
126+
- uses: taiki-e/create-pull-request@v3
127+
with:
128+
title: Update no_atomic.rs
129+
body: |
130+
Auto-generated by [create-pull-request][1]
131+
[Please close and immediately reopen this pull request to run CI.][2]
132+
133+
[1]: https://github.com/peter-evans/create-pull-request
134+
[2]: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#workarounds-to-trigger-further-workflow-runs
135+
branch: update-no-atomic-sh
136+
if: (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false'
114137

115138
# Check formatting.
116139
rustfmt:
@@ -172,6 +195,14 @@ jobs:
172195
- name: docs
173196
run: ./ci/docs.sh
174197

198+
shellcheck:
199+
runs-on: ubuntu-latest
200+
steps:
201+
- uses: actions/checkout@v2
202+
- name: Install shellcheck
203+
uses: taiki-e/install-action@shellcheck
204+
- run: shellcheck $(git ls-files '*.sh')
205+
175206
# This job doesn't actually test anything, but they're used to tell bors the
176207
# build completed, as there is no practical way to detect when a workflow is
177208
# successful listening to webhooks only.

ci/check-features.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
2-
2+
set -euxo pipefail
3+
IFS=$'\n\t'
34
cd "$(dirname "$0")"/..
4-
set -ex
55

66
if [[ "$RUST_VERSION" != "nightly"* ]]; then
77
# On MSRV, features other than nightly should work.

ci/clippy.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
2-
2+
set -euxo pipefail
3+
IFS=$'\n\t'
34
cd "$(dirname "$0")"/..
4-
set -ex
55

66
rustup component add clippy
77

ci/crossbeam-epoch-loom.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
2-
2+
set -euxo pipefail
3+
IFS=$'\n\t'
34
cd "$(dirname "$0")"/../crossbeam-epoch
4-
set -ex
55

66
export RUSTFLAGS="-D warnings --cfg crossbeam_loom --cfg crossbeam_sanitize"
77

ci/dependencies.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/bin/bash
2-
2+
set -euxo pipefail
3+
IFS=$'\n\t'
34
cd "$(dirname "$0")"/..
4-
set -ex
55

66
cargo tree
77
cargo tree --duplicate
8-
cargo tree --duplicate || exit 1
98

109
# Check minimal versions.
1110
# Remove dev-dependencies from Cargo.toml to prevent the next `cargo update`
@@ -15,5 +14,3 @@ cargo hack --remove-dev-deps --workspace
1514
cargo update -Zminimal-versions
1615
cargo tree
1716
cargo hack check --all --all-features --exclude benchmarks
18-
19-
exit 0

ci/docs.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
2-
2+
set -euxo pipefail
3+
IFS=$'\n\t'
34
cd "$(dirname "$0")"/..
4-
set -ex
55

66
export RUSTDOCFLAGS="-D warnings"
77

ci/miri.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
2-
2+
set -euxo pipefail
3+
IFS=$'\n\t'
34
cd "$(dirname "$0")"/..
4-
set -ex
55

66
MIRIFLAGS="-Zmiri-tag-raw-pointers" \
77
cargo miri test \

ci/no_atomic.sh

+53-49
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,69 @@
11
#!/bin/bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
cd "$(dirname "$0")"/..
25

36
# Update the list of targets that do not support atomic/CAS operations.
47
#
58
# Usage:
69
# ./ci/no_atomic.sh
710

8-
set -euo pipefail
9-
IFS=$'\n\t'
10-
11-
cd "$(cd "$(dirname "$0")" && pwd)"/..
12-
1311
file="no_atomic.rs"
1412

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=()
2216
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
2638
done
27-
echo "];" >>"$file"
2839

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}"
4948
done
50-
echo "];" >>"$file"
49+
cat >>"${file}" <<EOF
50+
];
5151
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+
];
5360
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}"
6466
done
65-
echo "];" >>"$file"
67+
cat >>"${file}" <<EOF
68+
];
69+
EOF

ci/rustfmt.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
2-
2+
set -euxo pipefail
3+
IFS=$'\n\t'
34
cd "$(dirname "$0")"/..
4-
set -ex
55

66
rustup component add rustfmt
77

ci/san.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
2-
2+
set -euxo pipefail
3+
IFS=$'\n\t'
34
cd "$(dirname "$0")"/..
4-
set -ex
55

66
if [[ "$OSTYPE" != "linux"* ]]; then
77
exit 0
@@ -45,7 +45,7 @@ RUSTFLAGS="-Dwarnings -Zsanitizer=memory --cfg crossbeam_sanitize" \
4545
cargo test -Zbuild-std --all --release --target x86_64-unknown-linux-gnu --tests --exclude benchmarks -- --test-threads=1
4646

4747
# Run thread sanitizer
48-
export TSAN_OPTIONS="suppressions=$(pwd)/ci/tsan"
4948
cargo clean
49+
TSAN_OPTIONS="suppressions=$(pwd)/ci/tsan" \
5050
RUSTFLAGS="-Dwarnings -Zsanitizer=thread --cfg crossbeam_sanitize" \
5151
cargo test -Zbuild-std --all --release --target x86_64-unknown-linux-gnu --tests --exclude benchmarks -- --test-threads=1

ci/test.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/bash
2-
2+
set -euxo pipefail
3+
IFS=$'\n\t'
34
cd "$(dirname "$0")"/..
4-
set -ex
55

66
export RUSTFLAGS="-D warnings"
77

8-
if [[ -n "$RUST_TARGET" ]]; then
8+
if [[ -n "${RUST_TARGET:-}" ]]; then
99
# If RUST_TARGET is specified, use cross for testing.
1010
cross test --all --target "$RUST_TARGET" --exclude benchmarks -- --test-threads=1
1111

crossbeam-channel/benchmarks/run.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
2-
2+
set -euxo pipefail
3+
IFS=$'\n\t'
34
cd "$(dirname "$0")"
4-
set -ex
55

66
cargo run --release --bin chan | tee chan.txt
77
cargo run --release --bin crossbeam-channel | tee crossbeam-channel.txt
88
cargo run --release --bin futures-channel | tee futures-channel.txt
99
cargo run --release --bin mpsc | tee mpsc.txt
1010
go run go.go | tee go.txt
1111

12-
./plot.py *.txt
12+
./plot.py ./*.txt

crossbeam-epoch/build.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#![warn(rust_2018_idioms)]
2-
3-
use std::env;
4-
5-
include!("no_atomic.rs");
6-
71
// The rustc-cfg listed below are considered public API, but it is *unstable*
82
// and outside of the normal semver guarantees:
93
//
@@ -13,10 +7,15 @@ include!("no_atomic.rs");
137
// need to enable it manually when building for custom targets or using
148
// non-cargo build systems that don't run the build script.
159
//
16-
// With the exceptions mentioned above, the rustc-cfg strings below are
17-
// *not* public API. Please let us know by opening a GitHub issue if your build
18-
// environment requires some way to enable these cfgs other than by executing
19-
// our build script.
10+
// With the exceptions mentioned above, the rustc-cfg emitted by the build
11+
// script are *not* public API.
12+
13+
#![warn(rust_2018_idioms)]
14+
15+
use std::env;
16+
17+
include!("no_atomic.rs");
18+
2019
fn main() {
2120
let target = match env::var("TARGET") {
2221
Ok(target) => target,

crossbeam-queue/build.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#![warn(rust_2018_idioms)]
2-
3-
use std::env;
4-
5-
include!("no_atomic.rs");
6-
71
// The rustc-cfg listed below are considered public API, but it is *unstable*
82
// and outside of the normal semver guarantees:
93
//
@@ -13,10 +7,15 @@ include!("no_atomic.rs");
137
// need to enable it manually when building for custom targets or using
148
// non-cargo build systems that don't run the build script.
159
//
16-
// With the exceptions mentioned above, the rustc-cfg strings below are
17-
// *not* public API. Please let us know by opening a GitHub issue if your build
18-
// environment requires some way to enable these cfgs other than by executing
19-
// our build script.
10+
// With the exceptions mentioned above, the rustc-cfg emitted by the build
11+
// script are *not* public API.
12+
13+
#![warn(rust_2018_idioms)]
14+
15+
use std::env;
16+
17+
include!("no_atomic.rs");
18+
2019
fn main() {
2120
let target = match env::var("TARGET") {
2221
Ok(target) => target,

crossbeam-skiplist/build.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#![warn(rust_2018_idioms)]
2-
3-
use std::env;
4-
5-
include!("no_atomic.rs");
6-
71
// The rustc-cfg listed below are considered public API, but it is *unstable*
82
// and outside of the normal semver guarantees:
93
//
@@ -13,10 +7,15 @@ include!("no_atomic.rs");
137
// need to enable it manually when building for custom targets or using
148
// non-cargo build systems that don't run the build script.
159
//
16-
// With the exceptions mentioned above, the rustc-cfg strings below are
17-
// *not* public API. Please let us know by opening a GitHub issue if your build
18-
// environment requires some way to enable these cfgs other than by executing
19-
// our build script.
10+
// With the exceptions mentioned above, the rustc-cfg emitted by the build
11+
// script are *not* public API.
12+
13+
#![warn(rust_2018_idioms)]
14+
15+
use std::env;
16+
17+
include!("no_atomic.rs");
18+
2019
fn main() {
2120
let target = match env::var("TARGET") {
2221
Ok(target) => target,

0 commit comments

Comments
 (0)