Description
Some embedded targets (thumbv6m
, riscv32i
) don't support general atomic operations (compare_exchange
, fetch_add
, etc) but do support atomic load
and store
operations. We previously supported this on thumbv6m
(but not riscv32i
, see #98333) by cfg
ing out most of the methods on Atomic*
except for load
and store
. However recent changes to LLVM (#99595) cause it to emit calls to libatomic for load
and store
(it already does this for the other atomic operations).
It seems that LLVM's support for lowering atomic loads and stores on ARM was an accident that is being reverted. However the reason for this revert is that the directly lowered load/store cannot interoperate correctly with the other atomic operations which are lowered to libcalls. This concern doesn't apply to Rust since we don't expose emulated (read: not lock free) atomics, so there is no interoperability concern (except maybe for FFI with C that uses atomics?).
I see 2 ways we can move forward:
- Continue supporting atomic load/store on such targets by lowering them in rustc to a volatile load/store. This will avoid breakage in the embeded Rust ecosystem.
- Remove support for atomic load/store on targets that don't support full atomics. Users are expected to switch to using volatile load/store instead.