From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS47066 71.19.144.0/20 X-Spam-Status: No, score=-1.9 required=3.0 tests=AWL,BAYES_00, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.raindrops.general Subject: Re: Compilation on Solaris/SmartOS Date: Wed, 28 Aug 2013 10:13:56 +0000 Message-ID: <20130828101356.GA3888@dcvr.yhbt.net> References: <20130827194052.GA22109@dcvr.yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1377685131 27429 80.91.229.3 (28 Aug 2013 10:18:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Aug 2013 10:18:51 +0000 (UTC) To: raindrops@librelist.org Original-X-From: raindrops@librelist.org Wed Aug 28 12:18:55 2013 Return-path: Envelope-to: gclrrg-raindrops@m.gmane.org List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: raindrops@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.raindrops.general:117 Archived-At: Received: from zedshaw2.xen.prgmr.com ([71.19.156.177]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VEclM-0003lf-GA for gclrrg-raindrops@m.gmane.org; Wed, 28 Aug 2013 12:14:08 +0200 Received: from zedshaw2.xen.prgmr.com (unknown [IPv6:::1]) by zedshaw2.xen.prgmr.com (Postfix) with ESMTP id EA58574E77 for ; Wed, 28 Aug 2013 10:22:34 +0000 (UTC) Jonathan del Strother 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).