Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use load(Acquire) for load_consume on Miri/TSan #995

Merged
merged 1 commit into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}
15 changes: 11 additions & 4 deletions crossbeam-utils/src/atomic/consume.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
use crate::primitive::sync::atomic::compiler_fence;
#[cfg(not(crossbeam_no_atomic))]
use core::sync::atomic::Ordering;

Expand Down Expand Up @@ -27,11 +25,17 @@ 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]
fn load_consume(&self) -> Self::Val {
use crate::primitive::sync::atomic::compiler_fence;
let result = self.load(Ordering::Relaxed);
compiler_fence(Ordering::Acquire);
result
Expand All @@ -40,7 +44,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