Project

General

Profile

Actions

Backport #2826

closed

pthreads compilation failure on Solaris

Added by grobian (Fabian Groffen) about 14 years ago. Updated over 4 years ago.


Description

=begin
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.
=end


Files

ruby-1.8.7_p249-pthread-linking.patch (610 Bytes) ruby-1.8.7_p249-pthread-linking.patch grobian (Fabian Groffen), 02/28/2010 10:12 PM
Actions #1

Updated by naruse (Yui NARUSE) about 14 years ago

  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

=begin
This also effects Ruby 1.9.
=end

Actions #2

Updated by mame (Yusuke Endoh) almost 14 years ago

  • Status changed from Assigned to Feedback
  • Priority changed from Normal to 3

=begin
Hi, Fabian

Sorry for late response.

2010/2/28 Fabian Groffen :

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
=end

Actions #3

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby 1.8 to Backport187
  • Description updated (diff)
  • Status changed from Feedback to Closed
  • ruby -v deleted (ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-solaris2.10])
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0