Description
openedon Oct 28, 2023
In csky, LLVM always generates libcalls (llvm/llvm-project@ec2de74), and atomic implementations are provided by libatomic.
However, as mentioned in #115577 (comment), the atomic RMW implementation provided in libatomic.a is not lock-free.
And it violates what the standard library is intended to guarantee.
https://doc.rust-lang.org/nightly/std/sync/atomic/index.html#portability
All atomic types in this module are guaranteed to be lock-free if they’re available. This means they don’t internally acquire a global mutex.
Also, mixing lock-free load/store and non-lock-free RMW can cause data races.
To fix this, we would need to do one of the following:
- Fix libatomic to make the RMW implementation lock-free.
- Fix LLVM to generate atomic instructions instead of libcalls.
It is not impossible to fix this on our end, but it is not very realistic as it would require writing a lot of inline assembly.
cc @Dirreke (mentioned because you are target maintainer)
@rustbot label +A-atomic +I-unsound