#####################################################################
-libatomic = []
-if not cc.links('''#include <stdint.h>
- int main() {
- char i;
- __atomic_exchange_1(&i, 1, 0);
- return 1;
- }''',
- name : 'Atomic builtin requires -latomic')
- libatomic = cc.find_library('atomic')
-endif
threads = dependency('threads')
librt = cc.find_library('rt')
libm = cc.find_library('m')
libdl = cc.find_library('dl')
libcrypt = cc.find_library('crypt')
+# On some architectures, libatomic is required. But on some installations,
+# it is found, but actual linking fails. So let's try to use it opportunistically.
+# If it is installed, but not needed, it will be dropped because of --as-needed.
+if cc.links('''int main(int argc, char **argv) { return 0; }''',
+ args : '-latomic',
+ name : 'libatomic')
+ libatomic = declare_dependency(link_args : '-latomic')
+else
+ libatomic = []
+endif
+
crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
foreach ident : [
['crypt_ra', crypt_header],