Unresolved import core::sync::atomic::AtomicU64

Hi

I'm encountering an issue with an unresolved import related to the atomic_float crate while working on my project. Specifically, the error is about the missing AtomicU64 import within the crate.

My code is based on RTIC framework and I want to synchronize ADC interrupt with PWM Timer. I am using the AtomicU32 variable ('DT') within an interrupt handler (adc task) to store and modify a time value (dt ).

But I get the following error:

error[E0432]: unresolved import `core::sync::atomic::AtomicU64`
 --> C:\Users\.cargo\registry\src\index.crates.io-6f17d22bba15001f\atomic_float-0.1.0\src\atomic_f64.rs:3:5
  |
3 |     AtomicU64,
  |     ^^^^^^^^^
  |     |
  |     no `AtomicU64` in `sync::atomic`
  |     help: a similar name exists in the module: `AtomicU32`

I am a beginner in embedded programming and RUST. I do not know what to do next.

Thank you!

Some targets don't have hardware support for 64-bit atomics -- see the "Portability" section here:

You may need to ask the atomic_float author to use #[cfg(target_has_atomic = "64")] on APIs that require 64-bit atomics, assuming there's still other functionality you'll be able to use. I'm guessing that AtomicF32 should be ok, but not AtomicF64.

2 Likes

Oh, atomic_float has their own "Portability" section:

2 Likes

Thank you @cuviper!

I am still little stuck.

Where do I add RUSTFLAGS="--cfg=force_disable_atomic64" to override feature selection and force disable AtomicF64?

Documentation says - " Because it's on-by-default, it's possible it will be enabled by accident. If you're the person compiling the end-result (invoking cargo build ), and some crate has done this (e.g. you can't simply add default-features=false ) to a Cargo.toml line, you can override feature selection and force-disable AtomicF64 using the force_disable_atomic64 cfg (that is, by adding RUSTFLAGS="--cfg=force_disable_atomic64" ). "

Thank you!

If you are directly depending on atomic_float, then you should set it in your Cargo.toml:

[dependencies]
atomic_float = { version = "0.1.0", default-features = false }

Otherwise, that RUSTFLAGS setting is an environment variable. You can also set rustflags in a local Cargo configuration. (separate from Cargo.toml!)

2 Likes

Thank you very much, @cuviper!!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.