Skip to content

Commit 558c3ce

Browse files
committed
Remove uses of unstable feature(cfg_target_has_atomic)
1 parent fcec876 commit 558c3ce

File tree

25 files changed

+254
-38
lines changed

25 files changed

+254
-38
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,27 @@ jobs:
8686
- name: dependency tree check
8787
run: ./ci/dependencies.sh
8888

89+
# When this job failed, run ci/no_atomic_cas.sh and commit result changes.
90+
# TODO(taiki-e): Ideally, this should be automated using a bot that creates
91+
# PR when failed, but there is no bandwidth to implement it
92+
# right now...
93+
codegen:
94+
runs-on: ubuntu-latest
95+
steps:
96+
- uses: actions/checkout@v2
97+
- name: Install Rust
98+
run: rustup update nightly && rustup default nightly
99+
- run: ci/no_atomic_cas.sh
100+
- run: git diff --exit-code
101+
89102
# Check formatting.
90103
rustfmt:
91104
name: rustfmt
92105
runs-on: ubuntu-latest
93106
steps:
94107
- uses: actions/checkout@v2
95108
- name: Install Rust
96-
run: rustup update stable && rustup default stable
109+
run: rustup update stable
97110
- name: rustfmt
98111
run: ./ci/rustfmt.sh
99112

@@ -104,7 +117,7 @@ jobs:
104117
steps:
105118
- uses: actions/checkout@v2
106119
- name: Install Rust
107-
run: rustup update stable && rustup default stable
120+
run: rustup update stable
108121
- name: clippy
109122
run: ./ci/clippy.sh
110123

@@ -126,7 +139,7 @@ jobs:
126139
steps:
127140
- uses: actions/checkout@v2
128141
- name: Install Rust
129-
run: rustup update stable && rustup default stable
142+
run: rustup update stable
130143
- name: loom
131144
run: ./ci/crossbeam-epoch-loom.sh
132145

@@ -154,6 +167,7 @@ jobs:
154167
- test
155168
- features
156169
- dependencies
170+
- codegen
157171
- rustfmt
158172
- clippy
159173
- san

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ alloc = ["crossbeam-epoch/alloc", "crossbeam-queue/alloc"]
3636

3737
# Enable to use of unstable functionality.
3838
# This is disabled by default and requires recent nightly compiler.
39-
# Note that this is outside of the normal semver guarantees and minor versions
40-
# of crossbeam may make breaking changes to them at any time.
39+
#
40+
# NOTE: This feature is outside of the normal semver guarantees and minor or
41+
# patch versions of crossbeam may make breaking changes to them at any time.
4142
nightly = ["crossbeam-epoch/nightly", "crossbeam-utils/nightly", "crossbeam-queue/nightly"]
4243

4344
[dependencies]

build.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#![warn(rust_2018_idioms)]
2+
3+
use std::env;
4+
5+
include!("no_atomic_cas.rs");
6+
7+
// The rustc-cfg strings below are *not* public API. Please let us know by
8+
// opening a GitHub issue if your build environment requires some way to enable
9+
// these cfgs other than by executing our build script.
10+
fn main() {
11+
let target = match env::var("TARGET") {
12+
Ok(target) => target,
13+
Err(e) => {
14+
println!(
15+
"cargo:warning={}: unable to get TARGET environment variable: {}",
16+
env!("CARGO_PKG_NAME"),
17+
e
18+
);
19+
return;
20+
}
21+
};
22+
23+
// Note that this is `no_*`, not `has_*`. This allows treating
24+
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
25+
// run. This is needed for compatibility with non-cargo build systems that
26+
// don't run the build script.
27+
if NO_ATOMIC_CAS.contains(&&*target) {
28+
println!("cargo:rustc-cfg=crossbeam_no_atomic_cas");
29+
}
30+
31+
println!("cargo:rerun-if-changed=no_atomic_cas.rs");
32+
}

ci/check-features.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,5 @@ else
2222
rustup target add thumbv7m-none-eabi
2323
rustup target add thumbv6m-none-eabi
2424
cargo hack check --all --feature-powerset --no-dev-deps --exclude benchmarks --target thumbv7m-none-eabi --skip std,default
25-
# * `--features nightly` is required for enable `cfg_target_has_atomic`.
26-
# * `--ignore-unknown-features` - some crates doesn't have 'nightly' feature
27-
cargo hack check --all --feature-powerset --no-dev-deps --exclude benchmarks --target thumbv6m-none-eabi --skip std,default --features nightly --ignore-unknown-features
25+
cargo hack check --all --feature-powerset --no-dev-deps --exclude benchmarks --target thumbv6m-none-eabi --skip std,default
2826
fi

ci/no_atomic_cas.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
# Update the list of targets that do not support atomic CAS operations.
4+
#
5+
# Usage:
6+
# ./ci/no_atomic_cas.sh
7+
8+
set -euo pipefail
9+
IFS=$'\n\t'
10+
11+
cd "$(cd "$(dirname "$0")" && pwd)"/..
12+
13+
file="no_atomic_cas.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"

crossbeam-channel/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ default = ["std"]
2020

2121
# Enable to use APIs that require `std`.
2222
# This is enabled by default.
23+
#
24+
# NOTE: Disabling `std` feature is not supported yet.
2325
std = ["crossbeam-utils/std"]
2426

2527
[dependencies]

crossbeam-deque/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ default = ["std"]
2020

2121
# Enable to use APIs that require `std`.
2222
# This is enabled by default.
23+
#
24+
# NOTE: Disabling `std` feature is not supported yet.
2325
std = ["crossbeam-epoch/std", "crossbeam-utils/std"]
2426

2527
[dependencies]

crossbeam-epoch/Cargo.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,21 @@ std = ["alloc", "crossbeam-utils/std", "lazy_static"]
2424

2525
# Enable to use APIs that require `alloc`.
2626
# This is enabled by default and also enabled if the `std` feature is enabled.
27+
#
28+
# NOTE: Disabling both `std` *and* `alloc` features is not supported yet.
2729
alloc = []
2830

2931
# Enable to use of unstable functionality.
3032
# This is disabled by default and requires recent nightly compiler.
31-
# Note that this is outside of the normal semver guarantees and minor versions
32-
# of crossbeam may make breaking changes to them at any time.
33+
#
34+
# NOTE: This feature is outside of the normal semver guarantees and minor or
35+
# patch versions of crossbeam may make breaking changes to them at any time.
3336
nightly = ["crossbeam-utils/nightly", "const_fn"]
3437

3538
# Enable the use of loom for concurrency testing.
3639
#
37-
# This configuration option is outside of the normal semver guarantees: minor
38-
# versions of crossbeam may make breaking changes to it at any time.
40+
# NOTE: This feature is outside of the normal semver guarantees and minor or
41+
# patch versions of crossbeam may make breaking changes to them at any time.
3942
loom = ["loom-crate", "crossbeam-utils/loom"]
4043

4144
[dependencies]
@@ -45,8 +48,8 @@ memoffset = "0.6"
4548

4649
# Enable the use of loom for concurrency testing.
4750
#
48-
# This configuration option is outside of the normal semver guarantees: minor
49-
# versions of crossbeam may make breaking changes to it at any time.
51+
# NOTE: This feature is outside of the normal semver guarantees and minor or
52+
# patch versions of crossbeam may make breaking changes to them at any time.
5053
[target.'cfg(crossbeam_loom)'.dependencies]
5154
loom-crate = { package = "loom", version = "0.5", optional = true }
5255

crossbeam-epoch/build.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#![warn(rust_2018_idioms)]
2+
3+
use std::env;
4+
5+
include!("no_atomic_cas.rs");
6+
7+
// The rustc-cfg strings below are *not* public API. Please let us know by
8+
// opening a GitHub issue if your build environment requires some way to enable
9+
// these cfgs other than by executing our build script.
10+
fn main() {
11+
let target = match env::var("TARGET") {
12+
Ok(target) => target,
13+
Err(e) => {
14+
println!(
15+
"cargo:warning={}: unable to get TARGET environment variable: {}",
16+
env!("CARGO_PKG_NAME"),
17+
e
18+
);
19+
return;
20+
}
21+
};
22+
23+
// Note that this is `no_*`, not `has_*`. This allows treating
24+
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
25+
// run. This is needed for compatibility with non-cargo build systems that
26+
// don't run the build script.
27+
if NO_ATOMIC_CAS.contains(&&*target) {
28+
println!("cargo:rustc-cfg=crossbeam_no_atomic_cas");
29+
}
30+
31+
println!("cargo:rerun-if-changed=no_atomic_cas.rs");
32+
}

crossbeam-epoch/no_atomic_cas.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../no_atomic_cas.rs

0 commit comments

Comments
 (0)