raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: raindrops@librelist.org
Subject: Re: Compilation on Solaris/SmartOS
Date: Wed, 28 Aug 2013 10:13:56 +0000	[thread overview]
Message-ID: <20130828101356.GA3888@dcvr.yhbt.net> (raw)
In-Reply-To: CAF5DW8+mhi2WVxzXCs4=jMH6_cum64CT53NTmKUeSHoVetQngQ@mail.gmail.com

Jonathan del Strother <maillist@steelskies.com> wrote:
> >  > I'm not familiar enough with building the atomic libs to say whether
> > it's
> > > definitely the correct fix, but it seems to work, and the ruby-atomic gem
> > > needed something similar :
> > > https://github.com/headius/ruby-atomic/blob/master/ext/extconf.rb.   Any
> > > thoughts?
> >
> > How does Ruby 2.0.0 / trunk build?  That also uses __sync_* and I can't
> > find -march=native anywhere.

Ah, it just used -march=i486 which is enough.  I missed your i386
mention in your first email, my mind just immediately associated
Solaris/SmartOS with SPARC :x

> Ruby 2 appears to build & run fine... I'm not sure what I'd need to execute
> to ensure I run a __sync_* instruction, but messed around with threads &
> mutexes without problems.

It's used pretty heavily (GC, signals, thread switches).  I haven't had
__sync_* fail me once it built.

> Interestingly, when I build raindrops with my regular ruby 1.9.3 install,
> the generated makefile includes "ARCH_FLAG = -m32", but when I build
> raindrops with ruby 2 / trunk, I get "ARCH_FLAGS = -march=i486".  When
> built with that flag, Raindrops works fine.

Ah, 2.0.0 adds -march=i486 in this way.  How about the following patch?
I just pushed it up to git://bogomips.org/raindrops.git

diff --git a/ext/raindrops/extconf.rb b/ext/raindrops/extconf.rb
index 447a90a..f012808 100644
--- a/ext/raindrops/extconf.rb
+++ b/ext/raindrops/extconf.rb
@@ -20,6 +20,7 @@ int main(int argc, char * const argv[]) {
         unsigned long i = 0;
         __sync_lock_test_and_set(&i, 0);
         __sync_lock_test_and_set(&i, 1);
+        __sync_bool_compare_and_swap(&i, 0, 1);
         __sync_add_and_fetch(&i, argc);
         __sync_sub_and_fetch(&i, argc);
         return 0;
@@ -30,7 +31,17 @@ SRC
     $defs.push(format("-DHAVE_GCC_ATOMIC_BUILTINS"))
     true
   else
-    false
+    # some compilers still target 386 by default, but we need at least 486
+    # to run atomic builtins.
+    prev_cflags = $CFLAGS
+    $CFLAGS += " -march=i486 "
+    if try_link(src)
+      $defs.push(format("-DHAVE_GCC_ATOMIC_BUILTINS"))
+      true
+    else
+      prev_cflags = $CFLAGS
+      false
+    end
   end
 end or have_header('atomic_ops.h') or abort <<-SRC
 

On a side note, I'm kind of curious about the reasoning for staying with
32-bit, though.  There's a lot more registers on x86_64

Ruby 1.9+ packs more short strings (up to 23 bytes vs 11 bytes on
32-bit), so you won't incur malloc/free for short strings.  With Ruby
2.0.0, you also get Flonum (avoids malloc for some Floats, like Fixnum
vs Bignum).


  reply	other threads:[~2013-08-28 10:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-27 11:02 Compilation on Solaris/SmartOS Jonathan del Strother
2013-08-27 19:40 ` Eric Wong
2013-08-28  9:16   ` Jonathan del Strother
2013-08-28 10:13     ` Eric Wong [this message]
2013-08-29  9:58       ` Jonathan del Strother

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/raindrops/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130828101356.GA3888@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=raindrops@librelist.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/raindrops.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).