diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7a7e96d6..89a651798 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,22 +24,31 @@ jobs: name: test env: RUST_VERSION: ${{ matrix.rust }} + TARGET: ${{ matrix.target }} strategy: matrix: - crates: - - crossbeam - - crossbeam-channel - - crossbeam-deque - - crossbeam-epoch - - crossbeam-queue - - crossbeam-skiplist - - crossbeam-utils - rust: - - 1.36.0 - - nightly - os: - - ubuntu-latest - - windows-latest + include: + - rust: 1.36.0 + os: ubuntu-latest + - rust: 1.36.0 + os: windows-latest + - rust: stable + os: ubuntu-latest + - rust: stable + os: windows-latest + - rust: nightly + os: ubuntu-latest + # TODO: https://github.com/crossbeam-rs/crossbeam/pull/518#issuecomment-633342606 + # - rust: nightly + # os: macos-latest + - rust: nightly + os: windows-latest + - rust: nightly + os: ubuntu-latest + target: i686-unknown-linux-gnu + - rust: nightly + os: ubuntu-latest + target: aarch64-unknown-linux-gnu runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -47,7 +56,7 @@ jobs: # --no-self-update is necessary because the windows environment cannot self-update rustup.exe. run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} - name: Test - run: ./ci/${{ matrix.crates }}.sh + run: ./ci/test.sh # Check all feature combinations works properly. features: @@ -116,6 +125,17 @@ jobs: - name: loom run: ./ci/crossbeam-epoch-loom.sh + # Check if the document can be generated without warning. + docs: + name: docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Rust + run: rustup update nightly && rustup default nightly + - name: docs + run: ./ci/docs.sh + # This job doesn't actually test anything, but they're used to tell bors the # build completed, as there is no practical way to detect when a workflow is # successful listening to webhooks only. @@ -132,6 +152,7 @@ jobs: - rustfmt - clippy - loom + - docs runs-on: ubuntu-latest steps: - name: Mark the job as a success diff --git a/ci/crossbeam-channel.sh b/ci/crossbeam-channel.sh deleted file mode 100755 index 3482365d0..000000000 --- a/ci/crossbeam-channel.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")"/../crossbeam-channel -set -ex - -export RUSTFLAGS="-D warnings" - -cargo check --bins --examples --tests -cargo test -- --test-threads=1 - -if [[ "$RUST_VERSION" == "nightly"* ]]; then - cd benchmarks - cargo check --bins - cd .. - - RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features -fi diff --git a/ci/crossbeam-deque.sh b/ci/crossbeam-deque.sh deleted file mode 100755 index fb53ab88c..000000000 --- a/ci/crossbeam-deque.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")"/../crossbeam-deque -set -ex - -export RUSTFLAGS="-D warnings" - -cargo check --bins --examples --tests -cargo test - -if [[ "$RUST_VERSION" == "nightly"* ]]; then - RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features -fi diff --git a/ci/crossbeam-epoch-loom.sh b/ci/crossbeam-epoch-loom.sh index 8cb393e29..d1534a8ac 100755 --- a/ci/crossbeam-epoch-loom.sh +++ b/ci/crossbeam-epoch-loom.sh @@ -3,9 +3,9 @@ cd "$(dirname "$0")"/../crossbeam-epoch set -ex -export RUSTFLAGS="-D warnings --cfg=loom_crossbeam" +export RUSTFLAGS="-D warnings --cfg loom_crossbeam --cfg crossbeam_sanitize" # With MAX_PREEMPTIONS=2 the loom tests (currently) take around 11m. # If we were to run with =3, they would take several times that, # which is probably too costly for CI. -env LOOM_MAX_PREEMPTIONS=2 cargo test --test loom --features sanitize --release -- --nocapture +env LOOM_MAX_PREEMPTIONS=2 cargo test --test loom --release -- --nocapture diff --git a/ci/crossbeam-epoch.sh b/ci/crossbeam-epoch.sh deleted file mode 100755 index 995f81c0d..000000000 --- a/ci/crossbeam-epoch.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")"/../crossbeam-epoch -set -ex - -export RUSTFLAGS="-D warnings" - -cargo check --bins --examples --tests -cargo test - -if [[ "$RUST_VERSION" == "nightly"* ]]; then - cargo test --features nightly - - RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features - - if [[ "$OSTYPE" == "linux"* ]]; then - ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" \ - RUSTFLAGS="-Z sanitizer=address" \ - cargo run \ - --release \ - --target x86_64-unknown-linux-gnu \ - --features sanitize,nightly \ - --example sanitize - fi -fi diff --git a/ci/crossbeam-queue.sh b/ci/crossbeam-queue.sh deleted file mode 100755 index b15303b5b..000000000 --- a/ci/crossbeam-queue.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")"/../crossbeam-queue -set -ex - -export RUSTFLAGS="-D warnings" - -cargo check --bins --examples --tests -cargo test - -if [[ "$RUST_VERSION" == "nightly"* ]]; then - RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features -fi diff --git a/ci/crossbeam-skiplist.sh b/ci/crossbeam-skiplist.sh deleted file mode 100755 index 3928d42e4..000000000 --- a/ci/crossbeam-skiplist.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")"/../crossbeam-skiplist -set -ex - -export RUSTFLAGS="-D warnings" - -cargo check --bins --examples --tests -cargo test - -if [[ "$RUST_VERSION" == "nightly"* ]]; then - cargo test --features nightly - - RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features -fi diff --git a/ci/crossbeam-utils.sh b/ci/crossbeam-utils.sh deleted file mode 100755 index 4879687de..000000000 --- a/ci/crossbeam-utils.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")"/../crossbeam-utils -set -ex - -export RUSTFLAGS="-D warnings" - -cargo check --bins --examples --tests -cargo test - -if [[ "$RUST_VERSION" == "nightly"* ]]; then - cargo test --features nightly - - RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features -fi diff --git a/ci/crossbeam.sh b/ci/crossbeam.sh deleted file mode 100755 index 99d4483bd..000000000 --- a/ci/crossbeam.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")"/.. -set -ex - -export RUSTFLAGS="-D warnings" - -cargo check --bins --examples --tests -cargo test - -if [[ "$RUST_VERSION" == "nightly"* ]]; then - cargo test --features nightly - - RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features -fi diff --git a/ci/docs.sh b/ci/docs.sh new file mode 100755 index 000000000..7cd5c4df7 --- /dev/null +++ b/ci/docs.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +cd "$(dirname "$0")"/.. +set -ex + +export RUSTDOCFLAGS="-D warnings" + +cargo doc --no-deps --all --all-features diff --git a/ci/test.sh b/ci/test.sh new file mode 100755 index 000000000..fe14ee846 --- /dev/null +++ b/ci/test.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +cd "$(dirname "$0")"/.. +set -ex + +export RUSTFLAGS="-D warnings" + +if [[ -n "$TARGET" ]]; then + # If TARGET is specified, use cross for testing. + cargo install cross + cross test --all --target "$TARGET" --exclude benchmarks + + # For now, the non-host target only runs tests. + exit 0 +fi + +# Otherwise, run tests and checks with the host target. +cargo check --all --bins --examples --tests --exclude benchmarks +cargo test --all --exclude benchmarks -- --test-threads=1 + +if [[ "$RUST_VERSION" == "nightly"* ]]; then + # Some crates have `nightly` feature, so run tests with --all-features. + cargo test --all --all-features --exclude benchmarks -- --test-threads=1 + + # Benchmarks are only checked on nightly because depending on unstable features. + cargo check --all --benches + cargo check --bins --manifest-path crossbeam-channel/benchmarks/Cargo.toml + + # Run address sanitizer on crossbeam-epoch + # Note: this will be significantly rewritten by https://github.com/crossbeam-rs/crossbeam/pull/591. + if [[ "$OSTYPE" == "linux"* ]]; then + cargo clean + + # TODO: Once `cfg(sanitize = "..")` is stable, replace + # `cfg(crossbeam_sanitize)` with `cfg(sanitize = "..")` and remove + # `--cfg crossbeam_sanitize`. + ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" \ + RUSTFLAGS="-Z sanitizer=address --cfg crossbeam_sanitize" \ + cargo run \ + --release \ + --target x86_64-unknown-linux-gnu \ + --features nightly \ + --example sanitize \ + --manifest-path crossbeam-epoch/Cargo.toml + fi +fi diff --git a/crossbeam-epoch/Cargo.toml b/crossbeam-epoch/Cargo.toml index a0091612f..e24ac8738 100644 --- a/crossbeam-epoch/Cargo.toml +++ b/crossbeam-epoch/Cargo.toml @@ -33,9 +33,6 @@ alloc = [] # of crossbeam may make breaking changes to them at any time. nightly = ["crossbeam-utils/nightly", "const_fn"] -# TODO: docs -sanitize = [] # Makes it more likely to trigger any potential data races. - [dependencies] cfg-if = "1" const_fn = { version = "0.4.4", optional = true } diff --git a/crossbeam-epoch/src/internal.rs b/crossbeam-epoch/src/internal.rs index 6ad5b2236..4da5d0268 100644 --- a/crossbeam-epoch/src/internal.rs +++ b/crossbeam-epoch/src/internal.rs @@ -55,9 +55,9 @@ use crate::sync::list::{Entry, IsElement, IterError, List}; use crate::sync::queue::Queue; /// Maximum number of objects a bag can contain. -#[cfg(not(feature = "sanitize"))] +#[cfg(not(crossbeam_sanitize))] const MAX_OBJECTS: usize = 62; -#[cfg(feature = "sanitize")] +#[cfg(crossbeam_sanitize)] const MAX_OBJECTS: usize = 4; /// A bag of deferred functions. @@ -109,7 +109,7 @@ impl Default for Bag { #[rustfmt::skip] fn default() -> Self { // TODO: [no_op; MAX_OBJECTS] syntax blocked by https://github.com/rust-lang/rust/issues/49147 - #[cfg(not(feature = "sanitize"))] + #[cfg(not(crossbeam_sanitize))] return Bag { len: 0, deferreds: [ @@ -177,7 +177,7 @@ impl Default for Bag { Deferred::new(no_op_func), ], }; - #[cfg(feature = "sanitize")] + #[cfg(crossbeam_sanitize)] return Bag { len: 0, deferreds: [ @@ -278,7 +278,7 @@ impl Global { pub(crate) fn collect(&self, guard: &Guard) { let global_epoch = self.try_advance(guard); - let steps = if cfg!(feature = "sanitize") { + let steps = if cfg!(crossbeam_sanitize) { usize::max_value() } else { Self::COLLECT_STEPS