+# for gcc compiles we need -latomic for 128-bit atomic ops
+if cc.get_id() == 'gcc'
+ libatomic_dep = cc.find_library('atomic', required: false)
+ if not libatomic_dep.found()
+ build = false
+ reason = 'missing dependency, "libatomic"'
+ subdir_done()
+ endif
+
+ # libatomic could be half-installed when above check finds it but
+ # linkage fails
+ atomic_link_code = '''
+ #include <stdio.h>
+ void main() { printf("libatomic link check\n"); }
+ '''
+ if not cc.links(atomic_link_code, dependencies: libatomic_dep)
+ build = false
+ reason = 'broken dependency, "libatomic"'
+ subdir_done()
+ endif
+ ext_deps += libatomic_dep
+endif
+