GNOME Bugzilla – Bug 697017
Undefined symbols: ___sync_fetch_and_or ___sync_fetch_and_add ___sync_fetch_and_and ___sync_synchronize
Last modified: 2013-11-23 16:08:38 UTC
I'm the maintainer of glib in MacPorts, and I just discovered that after updating our glib2 port to 2.36.0, it now fails to build on OS X 10.5 Leopard. :info:build In file included from 1bit-mutex.c:54: :info:build ../../glib/gbitlock.c: In function ‘g_futex_wait’: :info:build ../../glib/gbitlock.c:129: warning: implicit declaration of function ‘__sync_synchronize’ :info:build ../../glib/gbitlock.c: In function ‘_emufutex_g_bit_lock’: :info:build ../../glib/gbitlock.c:240: warning: implicit declaration of function ‘__sync_fetch_and_or’ :info:build ../../glib/gbitlock.c:246: warning: implicit declaration of function ‘__sync_fetch_and_add’ :info:build ../../glib/gbitlock.c: In function ‘_emufutex_g_bit_unlock’: :info:build ../../glib/gbitlock.c:329: warning: implicit declaration of function ‘__sync_fetch_and_and’ :info:build Undefined symbols: :info:build "___sync_fetch_and_or", referenced from: :info:build __emufutex_g_bit_lock in 1bit_emufutex-1bit-mutex.o :info:build __emufutex_g_bit_trylock in 1bit_emufutex-1bit-mutex.o :info:build __emufutex_g_pointer_bit_lock in 1bit_emufutex-1bit-mutex.o :info:build __emufutex_g_pointer_bit_trylock in 1bit_emufutex-1bit-mutex.o :info:build "___sync_fetch_and_add", referenced from: :info:build __emufutex_g_bit_lock in 1bit_emufutex-1bit-mutex.o :info:build __emufutex_g_bit_lock in 1bit_emufutex-1bit-mutex.o :info:build __emufutex_g_pointer_bit_lock in 1bit_emufutex-1bit-mutex.o :info:build __emufutex_g_pointer_bit_lock in 1bit_emufutex-1bit-mutex.o :info:build "___sync_fetch_and_and", referenced from: :info:build __emufutex_g_bit_unlock in 1bit_emufutex-1bit-mutex.o :info:build __emufutex_g_pointer_bit_unlock in 1bit_emufutex-1bit-mutex.o :info:build "___sync_synchronize", referenced from: :info:build _g_futex_wait in 1bit_emufutex-1bit-mutex.o :info:build __emufutex_g_bit_unlock in 1bit_emufutex-1bit-mutex.o :info:build __emufutex_g_pointer_bit_unlock in 1bit_emufutex-1bit-mutex.o :info:build ld: symbol(s) not found
Probably caused by bug 682818.
In MacPorts we are working around this problem by using gcc-4.2 instead of gcc-4.0 on Leopard. That's not so easy on Tiger though since its Xcode does not include anything newer than gcc-4.0.
The test in configure.ac for __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 is reversed. It's currently this... AC_TRY_COMPILE([], [__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4;], [], [AC_DEFINE(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4, 1, [ compiler supports atomic operations])]) where it should be.... AC_TRY_COMPILE([], [__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4;], [AC_DEFINE(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4, 1, [ compiler supports atomic operations])], []) which causes many of the reported problems to do with undefined symbols for __sync_fetch_and_add_4 etc.
*** This bug has been marked as a duplicate of bug 701897 ***