summaryrefslogtreecommitdiff
path: root/recipes/glib/0001-meson-Add-exception-for-atomic-ops-test-for-Android.patch
blob: a06af7c467fdb2945e9e606bdc27f6a8cf346177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 9c704bc1381610ddcb6c01ff136bee861fe83526 Mon Sep 17 00:00:00 2001
From: Nirbheek Chauhan <nirbheek@centricular.com>
Date: Tue, 22 May 2018 11:45:37 +0530
Subject: [PATCH] meson: Add exception for atomic ops test for Android

Some compilers, particularly Android on armv5 and old versions of Clang
provide atomic ops, but don't define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
so we need to define it ourselves.

This matches what configure does, with the exception that now it's only
done for Android since clang defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
now.

https://bugzilla.gnome.org/show_bug.cgi?id=796325
---
 meson.build | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 11ae73919..b8b1e353c 100644
--- a/meson.build
+++ b/meson.build
@@ -1375,14 +1375,26 @@ atomictest = '''int main() {
   return 0;
 }
 '''
+atomicdefine = '''
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#error "compiler has atomic ops, but doesn't define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"
+#endif
+'''
 if cc.get_id() == 'msvc' or cc.links(atomictest, name : 'atomic ops')
-  glibconfig_conf.set('G_ATOMIC_LOCK_FREE', true)
+  have_atomic_lock_free = true
+  if host_system == 'android' and not cc.compiles(atomicdefine, name : 'atomic ops define')
+    # When building for armv5 on Android, gcc 4.9 provides
+    # __sync_bool_compare_and_swap but doesn't define
+    # __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+    glib_conf.set('__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4', true)
+  endif
 else
+  have_atomic_lock_free = false
   if host_machine.cpu_family() == 'x86' and cc.links(atomictest, args : '-march=i486')
     error('GLib must be built with -march=i486 or later.')
   endif
-  glibconfig_conf.set('G_ATOMIC_LOCK_FREE', false)
 endif
+glibconfig_conf.set('G_ATOMIC_LOCK_FREE', have_atomic_lock_free)
 
 # === Threads ===
 
-- 
2.17.0