-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add riscv64 support #14
Conversation
Signed-off-by: Felix Yan <[email protected]>
@@ -309,6 +309,9 @@ fn main() { | |||
} else if !target.contains("windows") { | |||
println!("cargo:rustc-link-lib=pthread"); | |||
} | |||
if target.contains("riscv") { | |||
println!("cargo:rustc-link-lib=atomic"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's it for?
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@plt Clang 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.