From 210c2419beeef0cabfb0b35106a27fdb0882d9cc Mon Sep 17 00:00:00 2001 From: James Brown Date: Wed, 17 Jul 2019 09:19:03 -0700 Subject: [PATCH 1/2] conservatively limit atomic features --- serde/build.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/serde/build.rs b/serde/build.rs index ae0f9869..58385a4a 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -14,6 +14,8 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; + let has_atomic_integers = target_has_at_least_atomic_u64(&target); + // std::collections::Bound was stabilized in Rust 1.17 // but it was moved to core::ops later in Rust 1.26: // https://doc.rust-lang.org/core/ops/enum.Bound.html @@ -69,7 +71,7 @@ fn main() { println!("cargo:rustc-cfg=num_nonzero"); } - if minor >= 34 { + if minor >= 34 && has_atomic_integers { println!("cargo:rustc-cfg=std_integer_atomics"); } } @@ -102,3 +104,17 @@ fn rustc_minor_version() -> Option { u32::from_str(next).ok() } + +fn target_has_at_least_atomic_u64(target: &str) -> bool { + // The cfg variable target_has_atomic is unstable + // so this data comes from the src/librustc_target/spec/*.rs + // files in the rust source. Generally, it's 64-bit platforms + // plus i686. + if target.starts_with("x86-64") || target.starts_with("i686") || + target.starts_with("aarch64") || target.starts_with("powerpc64") || + target.starts_with("sparc64") || target.starts_with("mips64el") { + true + } else { + false + } +} From 01fade764cdb902866fff666ed27f9869304453b Mon Sep 17 00:00:00 2001 From: James Brown Date: Wed, 17 Jul 2019 09:57:53 -0700 Subject: [PATCH 2/2] replaced one too many _ with - --- serde/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serde/build.rs b/serde/build.rs index 58385a4a..3069010f 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -110,7 +110,7 @@ fn target_has_at_least_atomic_u64(target: &str) -> bool { // so this data comes from the src/librustc_target/spec/*.rs // files in the rust source. Generally, it's 64-bit platforms // plus i686. - if target.starts_with("x86-64") || target.starts_with("i686") || + if target.starts_with("x86_64") || target.starts_with("i686") || target.starts_with("aarch64") || target.starts_with("powerpc64") || target.starts_with("sparc64") || target.starts_with("mips64el") { true