Skip to content

unresolved import std::sync::atomic::AtomicUsize in no_std environment #526

@mutantbob

Description

@mutantbob

I am trying to port an app to an atmega2560 (avr architecture).

The embedded-svc crate uses log with this clause

[dependencies.log]
version = "0.4"
default-features = false

This should make the log crate no_std

lib.rs:321: #![cfg_attr(all(not(feature = "std"), not(test)), no_std)]

However, I still get the following compile error:

error[E0432]: unresolved import `std::sync::atomic::AtomicUsize`
   --> /home/thoth/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.17/src/lib.rs:348:25
    |
348 | use std::sync::atomic::{AtomicUsize, Ordering};
    |                         ^^^^^^^^^^^ no `AtomicUsize` in `sync::atomic`

Shouldn't a no_std build avoid pulling things from std? Other crates use the atomic-polyfill crate in this situation. Maybe switching to core::sync would work, but I'm not sure which version of rust stabilized that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions