about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-05-10 14:49:39 -0700
committerEric Wong <normalperson@yhbt.net>2012-05-10 14:49:39 -0700
commit71f80afdbcb45245a01ee2c278ebda692587e92a (patch)
tree01eea8885b8886be1c386cbc33e8b344ab88b46c
parent1c18fd9c13f95fef6bcbdc0587d38886fa8e9064 (diff)
downloadraindrops-71f80afdbcb45245a01ee2c278ebda692587e92a.tar.gz
Attempting to test for CMPXCHG on x86 should allow this check to
fail on i386 systems.  We also won't need try_run as a result,
enabling cross-compilation.  The configure.in check in Ruby
1.9.3 does something similar and that's far more widely used
than raindrops is.
-rw-r--r--ext/raindrops/extconf.rb15
1 files changed, 6 insertions, 9 deletions
diff --git a/ext/raindrops/extconf.rb b/ext/raindrops/extconf.rb
index 9f5de95..447a90a 100644
--- a/ext/raindrops/extconf.rb
+++ b/ext/raindrops/extconf.rb
@@ -13,23 +13,20 @@ have_func('rb_thread_blocking_region')
 have_func('rb_thread_io_blocking_region')
 
 checking_for "GCC 4+ atomic builtins" do
+  # we test CMPXCHG anyways even though we don't need it to filter out
+  # ancient i386-only targets without CMPXCHG
   src = <<SRC
 int main(int argc, char * const argv[]) {
-        volatile unsigned long i = 0;
+        unsigned long i = 0;
+        __sync_lock_test_and_set(&i, 0);
+        __sync_lock_test_and_set(&i, 1);
         __sync_add_and_fetch(&i, argc);
         __sync_sub_and_fetch(&i, argc);
         return 0;
 }
 SRC
 
-  if try_run(src)
-    # some systems target GCC for i386 and don't get the atomic builtins
-    # when building shared objects
-    arch = `#{CONFIG['CC']} -dumpmachine`.split(/-/)[0]
-    if arch == "i386" && $CFLAGS !~ /\b-march=/
-      $CFLAGS += " -march=i486 "
-    end
-
+  if try_link(src)
     $defs.push(format("-DHAVE_GCC_ATOMIC_BUILTINS"))
     true
   else