Modified: trunk/configure.ac (39 => 40)
--- trunk/configure.ac 2009-09-25 08:44:52 UTC (rev 39)
+++ trunk/configure.ac 2009-09-25 09:53:30 UTC (rev 40)
@@ -109,6 +109,32 @@
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
#
+# This is a bit subtle: on i386 systems without at least -march=i486 defined,
+# certain built-in atomics fall back to depending on undefined symbols if
+# their return values are used.
+#
+AC_CACHE_CHECK([for gcc atomic builtins],[dispatch_cv_atomic],
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([],[[
+int i, x =0;
+i = __sync_add_and_fetch(&x,1);
+return x;]])],[dispatch_cv_atomic=yes],
+ [saveCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -march=i486"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[[
+ int i, x =0;
+ i = __sync_add_and_fetch(&x,1);
+ return x;]])],[CFLAGS="$saveCFLAGS"
+dispatch_cv_atomic="-march=i486"
+])])])
+
+case $dispatch_cv_atomic in
+ yes) ;;
+ -march*) MARCH_FLAGS="$dispatch_cv_atomic"
+ AC_SUBST([MARCH_FLAGS]) ;;
+ *) AC_MSG_ERROR([No gcc builtin atomic operations available]) ;;
+esac
+
+#
# Find libraries we will need
#
AC_SEARCH_LIBS(clock_gettime, rt)
Modified: trunk/src/Makefile.am (39 => 40)
--- trunk/src/Makefile.am 2009-09-25 08:44:52 UTC (rev 39)
+++ trunk/src/Makefile.am 2009-09-25 09:53:30 UTC (rev 40)
@@ -19,13 +19,7 @@
INCLUDES=-I$(top_builddir) -I$(top_srcdir) \
@APPLE_LIBC_SOURCE_PATH@ @APPLE_XNU_SOURCE_PATH@
-#
-# This will need some refinement: gcc requires a minimum of -march=i486 on
-# x86 in order to implement built-in atomic operations. But when should we
-# define this optional argument? We need appropriate configure parts to make
-# this conditional.
-#
-libdispatch_la_CFLAGS+=-march=i686
+libdispatch_la_CFLAGS+=$(MARCH_FLAGS)
if USE_LEGACY_API
libdispatch_la_SOURCES+= \