Bug #2826

pthreads compilation failure on Solaris

Added by Fabian Groffen almost 2 years ago. Updated 10 months ago.

[ruby-core:28376]
Status:Feedback Start date:02/28/2010
Priority:Low Due date:
Assignee:Nobuyoshi Nakada % Done:

0%

Category:-
Target version:-
ruby -v:ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-solaris2.10]

Description

Original bug:
http://bugs.gentoo.org/show_bug.cgi?id=307159

Ruby's configure tries to find the right way to link against pthread libs by itself.  This fails amongst others on Solaris.  GCC itself knows fairly well how to link against pthreads libs using -pthread.  The original error on Solaris is:

i386-pc-solaris2.10-gcc -shared -o ../../.ext/i386-solaris2.10/bigdecimal.so
bigdecimal.o -L. -L../.. -L.  -Wl,-E    -Wl,-R
-Wl,/nilfisk/home/dve/gentoo-new/usr/lib -L/nilfisk/home/dve/gentoo-new/usr/lib
-lruby18  -lpthread -lrt -ldl -lcrypt -lm   -lc
/nilfisk/home/dve/gentoo-new/usr/lib/gcc/i386-pc-solaris2.10/4.4.3/../../../../i386-pc-solaris2.10/bin/ld:
../../libruby18.so: pthread_mutex_unlock: invalid version 2 (max 0)
../../libruby18.so: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [../../.ext/i386-solaris2.10/bigdecimal.so] Error 1

When -lpthread is replaced by -pthread (hence letting GCC inject the right linker arguments -- and in the correct order) this compiles fine.  I created a patch to configure.in for this, but it is quite hacky, and only serves as an indication.

I tested that this patch does not break compilation on Darwin (10.4/ppc).  I think the ideal solution would be to use something like ax_pthread (http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob;f=m4/ax_pthread.m4;h=37502dd83abe789d2287418f9ed10fd24c21b314;hb=7a6c511965489c38f5d3bef4afe113e3fe11c2ac) which contains all the gory logic to find the right argument to link against pthread libs.

ruby-1.8.7_p249-pthread-linking.patch (610 Bytes) Fabian Groffen, 02/28/2010 10:12 pm

History

Updated by Yui NARUSE almost 2 years ago

  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to Nobuyoshi Nakada
This also effects Ruby 1.9.

Updated by Yusuke Endoh over 1 year ago

  • Status changed from Assigned to Feedback
  • Priority changed from Normal to Low
Hi, Fabian

Sorry for late response.


2010/2/28 Fabian Groffen <redmine@ruby-lang.org>:
> Original bug:
> http://bugs.gentoo.org/show_bug.cgi?id=307159

I don't know gentoo's packaging system.
USE=threads means ./configure --enable-pthread, right?
Could you show all configure options?


> Ruby's configure tries to find the right way to link against pthread libs by itself. ?This fails amongst others on Solaris. ?

Works for me with i386-pc-solaris2.11 on VirtualBox.

  compiling bigdecimal
  gmake[1]: Entering directory `/export/home/mame/work/ruby18/ext/bigdecimal'
  gcc -I. -I../.. -I../../. -I../.././ext/bigdecimal -DBASE=10000UL -DBASE_FIG=4  -D_FILE_OFFSET_BITS=64  -fPIC -g -O2   -c bigdecimal.c
  gcc -shared -o ../../.ext/i386-solaris2.11/bigdecimal.so bigdecimal.o -L. -L../.. -L.     -lpthread -lrt -ldl -lcrypt -lm   -lc
  gmake[1]: Leaving directory `/export/home/mame/work/ruby18/ext/bigdecimal'


> GCC itself knows fairly well how to link against pthreads libs using -pthread.
*snip*
> When -lpthread is replaced by -pthread (hence letting GCC inject the right linker arguments -- and in the correct order) this compiles fine.  I created a patch to configure.in for this, but it is quite hacky, and only serves as an indication.

Unfortunately, gcc3 seems not to understand -pthread:

  compiling bigdecimal
  gmake[1]: Entering directory `/export/home/mame/work/ruby18/ext/bigdecimal'
  gcc -I. -I../.. -I../../. -I../.././ext/bigdecimal -DBASE=10000UL -DBASE_FIG=4  -D_FILE_OFFSET_BITS=64  -fPIC -g -O2   -c bigdecimal.c
  gcc -shared -o ../../.ext/i386-solaris2.11/bigdecimal.so bigdecimal.o -L. -L../.. -L.     -pthread -lrt -ldl -lcrypt -lm   -lc
  gcc: unrecognized option `-pthread'
  gmake[1]: Leaving directory `/export/home/mame/work/ruby18/ext/bigdecimal'

  $ gcc -v
  Reading specs from /usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/specs
  Configured with: /builds2/sfwnv-111a/usr/src/cmd/gcc/gcc-3.4.3/configure --prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++,f77,objc --enable-shared
  Thread model: posix
  gcc version 3.4.3 (csl-sol210-3_4-20050802)


By searching with the error message, this seems to be solaris10's
problem or binutils/ld's, not ruby's.

  http://sourceware.org/bugzilla/show_bug.cgi?id=6431

So I change priority to Low.
If you get something indicating ruby's bug and/or a better patch,
please inform us.  Thanks!

-- 
Yusuke Endoh <mame@tsg.ne.jp>

Also available in: Atom PDF