Open
Description
On Linux (and others?), the __atomic_store
(and other atomic) builtin doesn't work out of the box.
User will see a linker error
undefined reference to `__atomic_store'
If the system has gcc installed, the user could add -latomic
. However, on systems without gcc installed, the user would have to find the correct compiler-rt library that needs to be linked, which is not user friendly. clang should just atomically link to the compiler-rt when the builtin needs to be linked
Reproducer:
cat <<EOF | clang++ -xc++ -
struct Large {
int value[100];
};
struct GCC {
Large value;
};
void gcc(GCC& a, Large& val, int memory_order) {
__atomic_store(&a.value, &val, memory_order);
}
struct C11 {
_Atomic(Large) value;
};
void c11(C11& a, Large& val, int memory_order) {
__c11_atomic_store(&a.value, val, memory_order);
}
int main() { }
EOF
Godbolt: https://godbolt.org/z/f4jchEvxv