[glib] meson: Add exception for atomic ops test for Android
- From: Nirbheek Chauhan <nirbheekc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] meson: Add exception for atomic ops test for Android
- Date: Tue, 22 May 2018 09:06:07 +0000 (UTC)
commit 74af3841534af022a250e84c50543244c4ec6c0f
Author: Nirbheek Chauhan <nirbheek centricular com>
Date: Tue May 22 11:45:37 2018 +0530
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 | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/meson.build b/meson.build
index 8e1beb80f..f0ffe77a5 100644
--- a/meson.build
+++ b/meson.build
@@ -1460,15 +1460,28 @@ atomictest = '''int main() {
}
'''
+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
+'''
+
# We know that we can always use real ("lock free") atomic operations with MSVC
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 ===
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]