Skip to content

Commit

Permalink
Merge #666
Browse files Browse the repository at this point in the history
666: Make loom dependency optional r=jonhoo a=taiki-e

The loom dependency will never compile unless users enable cfg, but the way cargo and crates.io handle cfg-ed dependencies is not very good and confuses users.

This issue seems to work around by the way proposed by @matklad in #487 (comment).
So this PR uses that workaround.

Closes #665

r? @jeehoonkang @jonhoo 

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e committed Feb 23, 2021
2 parents d709c89 + 50d2b85 commit f8c9922
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ci/crossbeam-epoch-loom.sh
Expand Up @@ -8,4 +8,4 @@ export RUSTFLAGS="-D warnings --cfg crossbeam_loom --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 --release -- --nocapture
env LOOM_MAX_PREEMPTIONS=2 cargo test --test loom --release --features loom -- --nocapture
8 changes: 7 additions & 1 deletion crossbeam-epoch/Cargo.toml
Expand Up @@ -32,6 +32,12 @@ alloc = []
# of crossbeam may make breaking changes to them at any time.
nightly = ["crossbeam-utils/nightly", "const_fn"]

# Enable the use of loom for concurrency testing.
#
# This configuration option is outside of the normal semver guarantees: minor
# versions of crossbeam may make breaking changes to it at any time.
loom = ["loom-crate", "crossbeam-utils/loom"]

[dependencies]
cfg-if = "1"
const_fn = { version = "0.4.4", optional = true }
Expand All @@ -42,7 +48,7 @@ memoffset = "0.6"
# This configuration option is outside of the normal semver guarantees: minor
# versions of crossbeam may make breaking changes to it at any time.
[target.'cfg(crossbeam_loom)'.dependencies]
loom = "0.4"
loom-crate = { package = "loom", version = "0.4", optional = true }

[dependencies.crossbeam-utils]
version = "0.8"
Expand Down
3 changes: 3 additions & 0 deletions crossbeam-epoch/src/lib.rs
Expand Up @@ -65,6 +65,9 @@
#![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))]
#![cfg_attr(feature = "nightly", feature(const_fn))]

#[cfg(crossbeam_loom)]
extern crate loom_crate as loom;

use cfg_if::cfg_if;

#[cfg(crossbeam_loom)]
Expand Down
1 change: 1 addition & 0 deletions crossbeam-epoch/tests/loom.rs
@@ -1,6 +1,7 @@
#![cfg(crossbeam_loom)]

use crossbeam_epoch as epoch;
use loom_crate as loom;

use epoch::*;
use epoch::{Atomic, Owned};
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-utils/Cargo.toml
Expand Up @@ -37,7 +37,7 @@ lazy_static = { version = "1.4.0", optional = true }
# This configuration option is outside of the normal semver guarantees: minor
# versions of crossbeam may make breaking changes to it at any time.
[target.'cfg(crossbeam_loom)'.dependencies]
loom = "0.4"
loom = { version = "0.4", optional = true }

[build-dependencies]
autocfg = "1.0.0"
Expand Down

0 comments on commit f8c9922

Please sign in to comment.