about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e+absinthe@yhbt.net>2010-09-25 00:14:48 -0700
committerEric Wong <normalperson@yhbt.net>2010-09-25 07:14:25 +0000
commit8a2a725a4ad074af493e5aa075155eda8b1d6be7 (patch)
tree0e8849d9532309f3164461de96131d5bc7dce43a
parent256cc7c8ffb441dcf2d2a2da3bbbcc82546962d9 (diff)
downloadraindrops-8a2a725a4ad074af493e5aa075155eda8b1d6be7.tar.gz
Nobody uses i386 anymore (especially not with Ruby!),
but some systems like FreeBSD 7.0 still target GCC at
i386 by default, so we force GCC to use a slightly
more modern instruction set and allow it to use
atomic builtins.
-rw-r--r--ext/raindrops/extconf.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/raindrops/extconf.rb b/ext/raindrops/extconf.rb
index 09d6e36..fc2b3fd 100644
--- a/ext/raindrops/extconf.rb
+++ b/ext/raindrops/extconf.rb
@@ -1,6 +1,5 @@
 require 'mkmf'
 
-# FIXME: test for GCC __sync_XXX builtins here, somehow...
 have_func('mmap', 'sys/mman.h') or abort 'mmap() not found'
 have_func('munmap', 'sys/mman.h') or abort 'munmap() not found'
 
@@ -18,6 +17,13 @@ int main(int argc, char * const argv[]) {
 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
+
     $defs.push(format("-DHAVE_GCC_ATOMIC_BUILTINS"))
     true
   else