Closed
Description
Consider this code:
#include <atomic>
std::atomic<float> x(0.0f);
int main() { return (float)x; }
Which is taken from cmake's $PREFIX/lib/cmake/llvm/CheckCompilerVersion.cmake
and used for checking for libstdc++4.8 or newer. When compiling this on arm with clang++ tmp.cpp
I get
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/tmp/tmp-77121f.o: in function `main':
tmp.cpp:(.text+0x40): undefined reference to `__atomic_load_4'
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
We get the same error for some i686 (and arm?) packages when cross-compiling, but there it can be solved with -latomic
. Compiling on device with clang++ -latomic tmp.cpp
has no effect though, it gives the same error message.
I suppose this is due to the difference between android's linker and the standard gnu/Linux linker, and we can solve this by linking one of llvm/clang's libraries against libatomic.a. But which one?