Skip to content

Commit

Permalink
Always use load(Acquire) for load_consume on Miri/TSan
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jun 17, 2023
1 parent 041f6f2 commit e9f98af
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions crossbeam-epoch/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ include!("no_atomic.rs");
include!("build-common.rs");

fn main() {
println!("cargo:rerun-if-changed=no_atomic.rs");

let target = match env::var("TARGET") {
Ok(target) => convert_custom_linux_target(target),
Err(e) => {
Expand Down Expand Up @@ -52,6 +54,4 @@ fn main() {
if !cfg.probe_rustc_version(1, 61) {
println!("cargo:rustc-cfg=crossbeam_no_const_fn_trait_bound");
}

println!("cargo:rerun-if-changed=no_atomic.rs");
}
4 changes: 2 additions & 2 deletions crossbeam-queue/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ include!("no_atomic.rs");
include!("build-common.rs");

fn main() {
println!("cargo:rerun-if-changed=no_atomic.rs");

let target = match env::var("TARGET") {
Ok(target) => convert_custom_linux_target(target),
Err(e) => {
Expand All @@ -36,6 +38,4 @@ fn main() {
if NO_ATOMIC_CAS.contains(&&*target) {
println!("cargo:rustc-cfg=crossbeam_no_atomic_cas");
}

println!("cargo:rerun-if-changed=no_atomic.rs");
}
4 changes: 2 additions & 2 deletions crossbeam-skiplist/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ include!("no_atomic.rs");
include!("build-common.rs");

fn main() {
println!("cargo:rerun-if-changed=no_atomic.rs");

let target = match env::var("TARGET") {
Ok(target) => convert_custom_linux_target(target),
Err(e) => {
Expand All @@ -36,6 +38,4 @@ fn main() {
if NO_ATOMIC_CAS.contains(&&*target) {
println!("cargo:rustc-cfg=crossbeam_no_atomic_cas");
}

println!("cargo:rerun-if-changed=no_atomic.rs");
}
8 changes: 7 additions & 1 deletion crossbeam-utils/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ include!("no_atomic.rs");
include!("build-common.rs");

fn main() {
println!("cargo:rerun-if-changed=no_atomic.rs");

let target = match env::var("TARGET") {
Ok(target) => convert_custom_linux_target(target),
Err(e) => {
Expand Down Expand Up @@ -57,5 +59,9 @@ fn main() {
// Otherwise, assuming `"max-atomic-width" == 64` or `"max-atomic-width" == 128`.
}

println!("cargo:rerun-if-changed=no_atomic.rs");
// `cfg(sanitize = "..")` is not stabilized.
let sanitize = env::var("CARGO_CFG_SANITIZE").unwrap_or_default();
if sanitize.contains("thread") {
println!("cargo:rustc-cfg=crossbeam_sanitize_thread");
}
}
12 changes: 10 additions & 2 deletions crossbeam-utils/src/atomic/consume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ pub trait AtomicConsume {
}

#[cfg(not(crossbeam_no_atomic))]
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
// Miri doesn't support "consume" ordering and ThreadSanitizer doesn't treat
// load(Relaxed) + compiler_fence(Acquire) as "consume" load.
#[cfg(all(
any(target_arch = "arm", target_arch = "aarch64"),
not(any(miri, crossbeam_sanitize_thread)),
))]
macro_rules! impl_consume {
() => {
#[inline]
Expand All @@ -40,7 +45,10 @@ macro_rules! impl_consume {
}

#[cfg(not(crossbeam_no_atomic))]
#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))]
#[cfg(not(all(
any(target_arch = "arm", target_arch = "aarch64"),
not(any(miri, crossbeam_sanitize_thread)),
)))]
macro_rules! impl_consume {
() => {
#[inline]
Expand Down

0 comments on commit e9f98af

Please sign in to comment.