Created attachment 184466 [details] testcase: shar of audio/jack port The latest version of audio/jack fails to link an executable: undefined reference to `__atomic_store' Adding any of these gcc libraries makes the linking stage to succeed: /usr/local/lib/gcc5/libatomic.a /usr/local/lib/gcc48/libatomic.a /usr/local/lib/gcc6/libatomic.a But jack is built with clang and shouldn't depend on anything gcc, and there are no other libatomic.a available. What should be the resolution of this problem? Attaching the failing port.
Hi Brooks, Do you happen to know where `__atomic_store' should come from in clang? Is there supposed to be libatomic.a? Thanks, Yuri
It looks like an __atomic_store() implementation exists in contrib/compiler-rt/lib/builtins/atomic.c, but we don't build it in lib/libcompiler_rt. I'm not sure if it's as simple as adding that or if we need to/can do it only on certain platforms. Adding some CC's of people who have touched lib/libcompiler_rt recently.
Upstream builds atomic.c if(COMPILER_RT_HAS_ATOMIC_KEYWORD AND NOT COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN) builtin_check_c_compiler_source(COMPILER_RT_HAS_ATOMIC_KEYWORD " int foo(int x, int y) { _Atomic int result = x * y; return result; } ") I suspect that we can just add atomic.c on archs that now build with Clang
As far as I know, we have never had libatomic support. The problem is that we still support arches and CPUs which lack a way to do 64 bit atomic operations, like i486. The implementations in compiler-rt/lib/builtins are rather unknown to me, and I am unsure whether we can simply enable these and hope that they work correctly.
Apparently, nobody else uses c++ atomic functions. Out of all ports built with clang jack is the only one. -D__STDC_NO_ATOMICS__ is a workaround for jack, so this isn't a pressing issue.
As it turned out, atomic_fetch_add_explicit is a standard C built-in function, and __atomic_fetch_add is a gcc extension. Strangely, this gcc extension is supported by clang.
I am getting this error when building dns/knot2 only in FreeBSD 12 i386, clang 6.0.0, pr #227620. ./.libs/libknotd.a(libknotd_la-query_module.o): In function `knotd_mod_stats_incr': query_module.c:(.text+0x9d0): undefined reference to `__atomic_fetch_add_8' ./.libs/libknotd.a(libknotd_la-query_module.o): In function `knotd_mod_stats_decr': query_module.c:(.text+0xa80): undefined reference to `__atomic_fetch_sub_8' ./.libs/libknotd.a(libknotd_la-query_module.o): In function `knotd_mod_stats_store': query_module.c:(.text+0xb30): undefined reference to `__atomic_store_8' cc: error: linker command failed with exit code 1 (use -v to see invocation) ------------------------------------------------------------------------ root@12-i386-head:~ # gcc6 -dM -E -x c /dev/null | grep LLONG_LOCK #define __GCC_ATOMIC_LLONG_LOCK_FREE 1 root@12-i386-head:~ # clang -dM -E -x c /dev/null | grep LLONG_LOCK #define __CLANG_ATOMIC_LLONG_LOCK_FREE 1 #define __GCC_ATOMIC_LLONG_LOCK_FREE 1 root@12-i386-head:~ # clang --version FreeBSD clang version 6.0.0 (tags/RELEASE_600/final 326565) (based on LLVM 6.0.0) ------------------------------------------------------------------------ root@11-i386-head:~ # gcc6 -dM -E -x c /dev/null | grep LLONG_LOCK #define __GCC_ATOMIC_LLONG_LOCK_FREE 1 root@11-i386-head:~ # clang -dM -E -x c /dev/null | grep LLONG_LOCK #define __GCC_ATOMIC_LLONG_LOCK_FREE 1 root@11-i386-head:~ # clang --version FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0) ------------------------------------------------------------------------
audio/audacity also has the same issue. ld: error: unable to find library -latomic c++: error: linker command failed with exit code 1 (use -v to see invocation)
*** This bug has been marked as a duplicate of bug 230888 ***