aboutsummaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build17
1 files changed, 17 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index e9928a37931..bb6a835084f 100644
--- a/meson.build
+++ b/meson.build
@@ -790,9 +790,26 @@ else
endif
# Check for GCC style atomics
+dep_atomic = declare_dependency()
+
if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
name : 'GCC atomic builtins')
pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
+
+ # Not all atomic calls can be turned into lock-free instructions, in which
+ # GCC will make calls into the libatomic library. Check whether we need to
+ # link with -latomic.
+ #
+ # This can happen for 64-bit atomic operations on 32-bit architectures such
+ # as ARM.
+ if not cc.links('''#include <stdint.h>
+ int main() {
+ uint64_t n;
+ return (int)__atomic_load_n(&n, __ATOMIC_ACQUIRE);
+ }''',
+ name : 'GCC atomic builtins required -latomic')
+ dep_atomic = cc.find_library('atomic')
+ endif
endif
if not cc.links('''#include <stdint.h>
uint64_t v;