From 7f09d72e5fd5387c672b9803ead6548b45920f55 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 6 Jan 2023 16:28:51 +0100 Subject: [PATCH 1/2] Remove build.rs file --- Cargo.toml | 1 - build.rs | 46 ---------------------------------------------- src/lib.rs | 20 ++++++++++---------- 3 files changed, 10 insertions(+), 57 deletions(-) delete mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index 909b29c0c..f4e944942 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ A lightweight logging facade for Rust categories = ["development-tools::debugging"] keywords = ["logging"] exclude = ["rfcs/**/*"] -build = "build.rs" [package.metadata.docs.rs] features = ["std", "serde", "kv_unstable_std", "kv_unstable_sval", "kv_unstable_serde"] diff --git a/build.rs b/build.rs deleted file mode 100644 index 11c26a333..000000000 --- a/build.rs +++ /dev/null @@ -1,46 +0,0 @@ -//! This build script detects target platforms that lack proper support for -//! atomics and sets `cfg` flags accordingly. - -use std::env; -use std::str; - -fn main() { - let target = match rustc_target() { - Some(target) => target, - None => return, - }; - - if target_has_atomic_cas(&target) { - println!("cargo:rustc-cfg=atomic_cas"); - } - - if target_has_atomics(&target) { - println!("cargo:rustc-cfg=has_atomics"); - } - - println!("cargo:rerun-if-changed=build.rs"); -} - -fn target_has_atomic_cas(target: &str) -> bool { - match target { - "thumbv6m-none-eabi" - | "msp430-none-elf" - | "riscv32i-unknown-none-elf" - | "riscv32imc-unknown-none-elf" => false, - _ => true, - } -} - -fn target_has_atomics(target: &str) -> bool { - match target { - "thumbv4t-none-eabi" - | "msp430-none-elf" - | "riscv32i-unknown-none-elf" - | "riscv32imc-unknown-none-elf" => false, - _ => true, - } -} - -fn rustc_target() -> Option { - env::var("TARGET").ok() -} diff --git a/src/lib.rs b/src/lib.rs index 732637801..0a710c77b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -342,20 +342,20 @@ mod serde; #[cfg(feature = "kv_unstable")] pub mod kv; -#[cfg(has_atomics)] +#[cfg(target_has_atomic = "ptr")] use std::sync::atomic::{AtomicUsize, Ordering}; -#[cfg(not(has_atomics))] +#[cfg(not(target_has_atomic = "ptr"))] use std::cell::Cell; -#[cfg(not(has_atomics))] +#[cfg(not(target_has_atomic = "ptr"))] use std::sync::atomic::Ordering; -#[cfg(not(has_atomics))] +#[cfg(not(target_has_atomic = "ptr"))] struct AtomicUsize { v: Cell, } -#[cfg(not(has_atomics))] +#[cfg(not(target_has_atomic = "ptr"))] impl AtomicUsize { const fn new(v: usize) -> AtomicUsize { AtomicUsize { v: Cell::new(v) } @@ -369,7 +369,7 @@ impl AtomicUsize { self.v.set(val) } - #[cfg(atomic_cas)] + #[cfg(target_has_atomic = "ptr")] fn compare_exchange( &self, current: usize, @@ -387,7 +387,7 @@ impl AtomicUsize { // Any platform without atomics is unlikely to have multiple cores, so // writing via Cell will not be a race condition. -#[cfg(not(has_atomics))] +#[cfg(not(target_has_atomic = "ptr"))] unsafe impl Sync for AtomicUsize {} // The LOGGER static holds a pointer to the global logger. It is protected by @@ -1256,7 +1256,7 @@ pub fn max_level() -> LevelFilter { /// An error is returned if a logger has already been set. /// /// [`set_logger`]: fn.set_logger.html -#[cfg(all(feature = "std", atomic_cas))] +#[cfg(all(feature = "std", target_has_atomic = "ptr"))] pub fn set_boxed_logger(logger: Box) -> Result<(), SetLoggerError> { set_logger_inner(|| Box::leak(logger)) } @@ -1314,12 +1314,12 @@ pub fn set_boxed_logger(logger: Box) -> Result<(), SetLoggerError> { /// ``` /// /// [`set_logger_racy`]: fn.set_logger_racy.html -#[cfg(atomic_cas)] +#[cfg(target_has_atomic = "ptr")] pub fn set_logger(logger: &'static dyn Log) -> Result<(), SetLoggerError> { set_logger_inner(|| logger) } -#[cfg(atomic_cas)] +#[cfg(target_has_atomic = "ptr")] fn set_logger_inner(make_logger: F) -> Result<(), SetLoggerError> where F: FnOnce() -> &'static dyn Log, From 0fe18a48a5a87f4beb835052f3445bb30e5a3e0a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 6 Jan 2023 16:32:14 +0100 Subject: [PATCH 2/2] Update minimum supported Rust version to 1.60.0 --- .github/workflows/main.yml | 4 ++-- README.md | 2 +- clippy.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 783b5052d..fb038d280 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -127,8 +127,8 @@ jobs: - uses: actions/checkout@master - name: Install Rust run: | - rustup update 1.31.0 --no-self-update - rustup default 1.31.0 + rustup update 1.60.0 --no-self-update + rustup default 1.60.0 - run: cargo build --verbose - run: cargo build --verbose --features serde - run: cargo build --verbose --features std diff --git a/README.md b/README.md index 5adff6bd7..41a1cb648 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ implementation that is most suitable for its use case. ## Minimum supported `rustc` -`1.31.0+` +`1.60.0+` This version is explicitly tested in CI and may be bumped in any release as needed. Maintaining compatibility with older compilers is a priority though, so the bar for bumping the minimum supported version is set very high. Any changes to the supported minimum version will be called out in the release notes. diff --git a/clippy.toml b/clippy.toml index 3d30690f1..16caf02ee 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.31.0" +msrv = "1.60.0"