From 3c8473d9ed17f12db4487062f64eab705ea803b3 Mon Sep 17 00:00:00 2001 From: KodrAus Date: Tue, 11 Apr 2023 10:48:11 +1000 Subject: [PATCH 1/4] Revert "Revert "Remove build.rs file"" This reverts commit 4e689bbb8f7dc7c465e6367b7022f347a0fe09e9. --- .github/workflows/main.yml | 4 ++-- CHANGELOG.md | 9 +++++++- Cargo.toml | 2 +- build.rs | 46 -------------------------------------- src/lib.rs | 9 ++++---- 5 files changed, 16 insertions(+), 54 deletions(-) delete mode 100644 build.rs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f38d3b33e..c2f5af492 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 test --verbose --manifest-path tests/Cargo.toml embedded: diff --git a/CHANGELOG.md b/CHANGELOG.md index a6f251b3f..305518965 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## [Unreleased] +## [0.4.19] - 2023-06-10 + +* Use target_has_atomic instead of the old atomic_cas cfg by @KodrAus in https://github.com/rust-lang/log/pull/555 +* Put MSRV into Cargo.toml by @est31 in https://github.com/rust-lang/log/pull/557 + ## [0.4.18] - 2023-05-28 * fix markdown links (again) by @hellow554 in https://github.com/rust-lang/log/pull/513 @@ -239,7 +244,9 @@ version using log 0.4.x to avoid losing module and file information. Look at the [release tags] for information about older releases. -[Unreleased]: https://github.com/rust-lang-nursery/log/compare/0.4.17...HEAD +[Unreleased]: https://github.com/rust-lang-nursery/log/compare/0.4.18...HEAD +[0.4.19]: https://github.com/rust-lang-nursery/log/compare/0.4.18...0.4.19 +[0.4.18]: https://github.com/rust-lang-nursery/log/compare/0.4.17...0.4.18 [0.4.17]: https://github.com/rust-lang-nursery/log/compare/0.4.16...0.4.17 [0.4.16]: https://github.com/rust-lang-nursery/log/compare/0.4.15...0.4.16 [0.4.15]: https://github.com/rust-lang-nursery/log/compare/0.4.13...0.4.15 diff --git a/Cargo.toml b/Cargo.toml index 5004b08fa..eabb2c4fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ A lightweight logging facade for Rust categories = ["development-tools::debugging"] keywords = ["logging"] exclude = ["rfcs/**/*"] -build = "build.rs" +rust-version = "1.60.0" [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 4297344e0..c669206a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -371,7 +371,7 @@ impl AtomicUsize { self.v.set(val) } - #[cfg(atomic_cas)] + #[cfg(target_has_atomic = "ptr")] fn compare_exchange( &self, current: usize, @@ -1217,6 +1217,7 @@ where /// /// Note that `Trace` is the maximum level, because it provides the maximum amount of detail in the emitted logs. #[inline] +#[cfg(target_has_atomic = "ptr")] pub fn set_max_level(level: LevelFilter) { MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::Relaxed); } @@ -1285,7 +1286,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)) } @@ -1343,12 +1344,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 54d48fb53e6ba9cb059968c48dc9580bee4fc003 Mon Sep 17 00:00:00 2001 From: KodrAus Date: Sun, 28 May 2023 14:15:58 +1000 Subject: [PATCH 2/4] prepare for 0.4.19 release --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index eabb2c4fb..fa9ef428b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "log" -version = "0.4.18" # remember to update html_root_url +version = "0.4.19" # remember to update html_root_url authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/src/lib.rs b/src/lib.rs index c669206a4..e6a41d9c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -317,7 +317,7 @@ #![doc( html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://docs.rs/log/0.4.18" + html_root_url = "https://docs.rs/log/0.4.19" )] #![warn(missing_docs)] #![deny(missing_debug_implementations, unconditional_recursion)] From 92e83c04f3dfc99c71c63e6f144878517f0fd563 Mon Sep 17 00:00:00 2001 From: KodrAus Date: Sun, 28 May 2023 14:24:22 +1000 Subject: [PATCH 3/4] fixes for unrevert --- src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e6a41d9c2..d267d9e53 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -344,20 +344,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) } @@ -389,7 +389,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 From 5322e569d0549c6c23a1dc179122b5797fba1b0a Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Mon, 29 May 2023 13:22:55 +1000 Subject: [PATCH 4/4] update changelog to reflect actual changes --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 305518965..c45c875c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ## [0.4.19] - 2023-06-10 -* Use target_has_atomic instead of the old atomic_cas cfg by @KodrAus in https://github.com/rust-lang/log/pull/555 +* Use target_has_atomic instead of the old atomic_cas cfg by @GuillaumeGomez in https://github.com/rust-lang/log/pull/555 * Put MSRV into Cargo.toml by @est31 in https://github.com/rust-lang/log/pull/557 ## [0.4.18] - 2023-05-28 @@ -19,7 +19,6 @@ * GitHub Workflows security hardening by @sashashura in https://github.com/rust-lang/log/pull/538 * Fix build status badge by @atouchet in https://github.com/rust-lang/log/pull/539 * Add call_logger to the documentation by @a1ecbr0wn in https://github.com/rust-lang/log/pull/547 -* Remove build.rs file by @GuillaumeGomez in https://github.com/rust-lang/log/pull/543 * Use stable internals for key-value API by @KodrAus in https://github.com/rust-lang/log/pull/550 * Change wording of list of implementations by @Thomasdezeeuw in https://github.com/rust-lang/log/pull/553 * Add std-logger to list of implementations by @Thomasdezeeuw in https://github.com/rust-lang/log/pull/554