matklad / once_cell

Rust library for single assignment cells and lazy statics without macros

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

once_cell::race does not compile on ARM

tkaitchuck opened this issue · comments

These four lines: 1, 2, 3, 4 fail to compile on ARM because on ARM the AtomicUsize lacks a compare_exchange method.
It may be possible to work around this with a load and a store and a loop.

Do you know which cfg is used to detect if it is available for a particular target?

The only way I am aware of is by using target_arch = "arm". I don't know if there is a list somewhere of which architectures have which features.

FYI:

  • futures, crossbeam, heapless, defmt, etc. detect these targets using the TARGET environment variables provided by cargo for the build script and a list of targets that do not have atomic CAS. See rust-lang/futures-rs#2400 for more.
  • Another way that is available in stable rust is to use crates like autocfg. See rust-lang/futures-rs#2294 for more.