about summary refs log tree commit homepage
diff options
context:
space:
mode:
-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