build: Fix test for G_ATOMIC_LOCK_FREE in meson.build

Commit 3e96523e6b did not entirely fix the test, as the compiled test
code did not have a main() function, so failed to link with:

 /usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

This caused an invalid mixtures of builtin and non-builtin atomics/locks
to be used, which caused deadlocks in a number of tests.

Fix the atomic ops test in meson.build, and the unit tests all start
working again.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=796164
This commit is contained in:
Philip Withnall 2018-05-16 12:16:17 +01:00
parent d388a00028
commit 1a6fc60fe9

View File

@ -1460,9 +1460,10 @@ glibconfig_conf.set('G_ATOMIC_OP_MEMORY_BARRIER_NEEDED', glib_memory_barrier_nee
# to abort and advise the user to fix their CFLAGS. It's better to do
# that then to silently fall back on emulated atomic ops just because
# the user had the wrong build environment.
atomictest = '''void func() {
atomictest = '''int main() {
volatile int atomic = 2;
__sync_bool_compare_and_swap (&atomic, 2, 3);
return 0;
}
'''
if cc.links(atomictest, name : 'atomic ops')