Conversation
Signed-off-by: Felix Yan <[email protected]>
| println!("cargo:rustc-link-lib=pthread"); | ||
| } | ||
| if target.contains("riscv") { | ||
| println!("cargo:rustc-link-lib=atomic"); |
|
Any idea why you need |
|
I got a lot of linking errors like this, without |
|
OK, I believe this is a GCC deficiency riscvarchive/riscv-gcc#12 #include <stdatomic.h>
char meow(char *ptr, char val) {
return __atomic_exchange_n(ptr, val, memory_order_seq_cst);
}GCC may generate a % riscv64-linux-gnu-gcc -march=rv64gc -O2 -S a.c -o - | grep __atomic
tail __atomic_exchange_1@pltClang doesn't do this. Mix-and-match for a given object size/alignment is not good but it should be fine. libatomic's implementation doesn't use mutex array. |
|
Thank you @MaskRay @felixonmars for the analyze. @felixonmars can you also add the issue link in the code as a comment to explain why atomic is linked against explicitly? |
|
Sure. Hopefully I did it right :) |
|
You need to sign off all your commits, otherwise we can't merge your pr. |
Signed-off-by: Felix Yan <[email protected]>
Oops. Fixed now. |
|
@MaskRay mix-and-match is not okay according to https://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary . In this case, the behavior difference of GCC and Clang should be considered as a bug, and as (from my view) LLVM respects GCC for libatomic, Clang should be fixed to invoke atomic*. |
Builds fine and all tests are green.