Open taiki-e opened 8 months ago
Thanks!
I think to fix LLVM to generate atomic instructions instead of libcalls is a better idea.
The linux system and the gcc-toolchain of csky is not well maintained and the newest version of them is not open-source. Besides, there's many exsited devices with the system which is not suitable for upgrade.
Therefore, I think to fix LLVM is a more realizable and practical way.
(We don't have a CSky target label?)
I assume this is about the csky-unknown-linux-gnuabiv2 target.
I assume this is about the csky-unknown-linux-gnuabiv2 target.
and the csky-unknown-linux-gnuabiv2hf
WG-prioritization assigning priority (Zulip discussion).
@Dirreke AFAICS the compiler target csky-unknown-linux-gnuabiv2hf
is not mapped on our Tier support list. Do you think it should be updated?
@rustbot label -I-prioritize +P-low
@Dirreke AFAICS the compiler target
csky-unknown-linux-gnuabiv2hf
is not mapped on our Tier support list. Do you think it should be updated?
csky-unknown-linux-gnuabiv2hf
is introduced into rust at #117049 . The target csky-unknown-linux-gnuabiv2hf
and the related docs will be released in the next version.
In csky, LLVM always generates libcalls (https://github.com/llvm/llvm-project/commit/ec2de7490813a7593dad59f210c7ec41f1a29002), and atomic implementations are provided by libatomic.
https://github.com/rust-lang/rust/blob/c7224e3c954ce54853364c950608c1f0ed47ea85/compiler/rustc_target/src/spec/csky_unknown_linux_gnuabiv2.rs#L15
However, as mentioned in https://github.com/rust-lang/rust/pull/115577#issuecomment-1732597305, 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
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:
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