Bug 6431

Summary: ld says: invalid version 3 (max 0)
Product: binutils Reporter: Niki W. Waibel <niki.waibel>
Component: ldAssignee: unassigned
Status: RESOLVED DUPLICATE    
Severity: critical CC: bug-binutils, deisner
Priority: P2    
Version: 2.18   
Target Milestone: ---   
Host: sparc-sun-solaris2.10 Target: sparc-sun-solaris2.10
Build: sparc-sun-solaris2.10 Last reconfirmed:
Attachments: ld producing pthread_mutex_unlock: invalid version 3 (max 0)
"different message"

Description Niki W. Waibel 2008-04-18 02:10:49 UTC
linking fails during compilation of glib-2.16.3 with the following message:
===
/misc/sparc-sun-solaris2.10/bin/ld: ../../gthread/.libs/libgthread-2.0.so:
pthread_mutex_unlock: invalid version 3 (max 0)
../../gthread/.libs/libgthread-2.0.so: could not read symbols: Bad value
collect2: ld returned 1 exit status
===
gcc-4.3.0
binutils 2.18.50.0.6.20080403
SunOS m5000 5.10 Generic_127111-02 sun4u sparc SUNW,SPARC-Enterprise Solaris

compiling some other sw works fine. i remember that this issue is there since
quite a while (2.17?) in binutils on solaris. i thought that this is going to be
fixed after a while -- as it has been reported here:
http://osdir.com/ml/gnu.binutils.bugs/2006-04/msg00049.html
Comment 1 Niki W. Waibel 2008-04-18 02:28:00 UTC
gcc was compiled to produce static versions of it's own libraries only.

will attach the gcc -v output of the glib link error.
Comment 2 Niki W. Waibel 2008-04-18 02:35:51 UTC
Created attachment 2708 [details]
ld producing pthread_mutex_unlock: invalid version 3 (max 0)
Comment 3 Niki W. Waibel 2008-04-22 20:28:29 UTC
similar error reported here:
http://osdir.com/ml/package-management.openpkg.user/2006-06/msg00046.html
Comment 5 David Eisner 2008-06-24 15:18:08 UTC
I'm running into this problem, too (Solaris 10 11/06 s10x_u3wos_10 X86, ld
2.18), trying to build glib-2.15.4 with gcc 4.3.1.
Comment 6 Niki W. Waibel 2008-06-24 21:51:06 UTC
still the same issue, using:
===
gcc-4.3.1
binutils-2.18.50.0.7.20080502
SunOS m5000-1.dev.nlatlu.wipro.com 5.10 Generic_127111-02 sun4u sparc
SUNW,SPARC-Enterprise Solaris
===
Comment 7 Niki W. Waibel 2008-06-25 12:45:43 UTC
couple of other tests...
===
binutils-2.17.50.0.1: fails (like reported)
binutils-2.16.91.0.7: fails (like reported)
binutils-2.16.91.0.2: fails (like reported)
binutils-2.16.91.0.1: fails (different message)
binutils-2.16.90.0.3: fails (different message)
binutils-2.16.90.0.1: fails (different message)
binutils-2.15.94.0.2.2: fails (different message)
binutils-2.15.90.0.1: fails (different message)
binutils-2.14.90.0.1: fails (different message)
===
will attach this "different message".
Comment 8 Niki W. Waibel 2008-06-25 14:30:00 UTC
Created attachment 2798 [details]
"different message"
Comment 9 Niki W. Waibel 2008-07-12 03:48:37 UTC
same using 2.18.50.0.8.20080709
Comment 10 Niki W. Waibel 2008-07-17 13:43:33 UTC
by the way, glib compiles file (same gcc/binutils) on:
===
SunOS e450-1.dev.nlatlu.wipro.com 5.8 Generic_117350-24 sun4u sparc SUNW,Ultra-4
Solaris
SunOS blade1000-2.dev.nlatlu.wipro.com 5.9 Generic_117171-12 sun4u sparc
SUNW,Sun-Blade-1000 Solaris
Linux amdlnx-1.newlogic.at 2.4.21-52.ELsmp #1 SMP Tue Sep 25 15:11:20 EDT 2007
x86_64 GNU/Linux
Linux pcxeon-1.newlogic.at 2.6.12-1.1381_FC3smp #1 SMP Fri Oct 21 04:03:26 EDT
2005 i686 GNU/Linux
===
so this bug seems to be related to changed from solaris9 -> solaris10 (in sparc
and x86)
Comment 11 Niki W. Waibel 2008-07-17 13:44:25 UTC
file = fine
Comment 12 Niki W. Waibel 2008-07-17 13:58:21 UTC
more details on the different platforms:

$ uname -s -m -r -p; nm  /lib/libpthread.so.0 | grep pthread_mutex_unlock
Linux 2.4.21-52.ELsmp x86_64 unknown
00007690 t __GI___pthread_mutex_unlock
00007690 T __pthread_mutex_unlock
00007690 T pthread_mutex_unlock

$ uname -s -m -r -p; nm  /lib/libpthread.so.0 | grep pthread_mutex_unlock
Linux 2.6.12-1.1381_FC3smp i686 unknown
00007530 t __GI___pthread_mutex_unlock
00007530 T __pthread_mutex_unlock
00007530 T pthread_mutex_unlock

$ uname -s -m -r -p; nm  /lib/libpthread.so.1 | grep pthread_mutex_unlock
SunOS 5.8 sun4u sparc
00003d84 T _pthread_mutex_unlock
00003d84 W pthread_mutex_unlock

$ uname -s -m -r -p; nm  /lib/libpthread.so.1 | grep pthread_mutex_unlock
SunOS 5.9 sun4u sparc
00003b8c T _pthread_mutex_unlock
00003b8c W pthread_mutex_unlock

$ uname -s -m -r -p; nm  /lib/libpthread.so.1 | grep pthread_mutex_unlock
SunOS 5.10 sun4u sparc
00000000 A _pthread_mutex_unlock
00000000 A pthread_mutex_unlock
Comment 13 Niki W. Waibel 2008-07-17 14:29:06 UTC
found a workaround!!! ... it seems that on sol10, all pthread_XXX stuff is now
in libc.so. if you remove the -lpthread -thread options when glib compiles,
everything looks good.

for me (not a binutils/linker expert) it looks as /lib/libpthread.so.1 on
solaris10 only contains references, but /lib/libc.so.1 contains the real code:
===
$ nm /lib/libc.so.1 | grep pthread_mutex_unlock
000bdf98 W _pthread_mutex_unlock
000bdf98 W pthread_mutex_unlock
===
maybe ld should just skip those
===
$ nm  /lib/libpthread.so.1 | grep pthread_mutex_unlock
SunOS 5.10 sun4u sparc
00000000 A _pthread_mutex_unlock
00000000 A pthread_mutex_unlock
===
"empty" functions in /lib/libpthread.so.1 and check/use the other libraries ...

anyone out there who hack this is?
Comment 14 Niki W. Waibel 2008-07-17 18:32:34 UTC
sorry, i meant: anyone out there who can hack this in?
Comment 15 Nick Clifton 2008-07-21 15:28:17 UTC
Subject: Re:  ld says: invalid version 3 (max 0)

Hi niki,

> found a workaround!!! ... it seems that on sol10, all pthread_XXX stuff is now
> in libc.so. if you remove the -lpthread -thread options when glib compiles,
> everything looks good.

Hmm, so to me this sounds like it is a glib problem - ie its build 
makefile needs to be altered to remove the thread library when building 
on Solaris 10.  Have you tried asking about this on their email list ?

Cheers
   Nick


Comment 16 Niki W. Waibel 2008-07-21 17:02:10 UTC
well -- as a workaround, you can remove -lpthread -thread options from gcc.

but binutils/ld should also be able to handle this case. exiting with a message
like "invalid version 3 (max 0)" is meaningless, especially, if it means that
you should remove some gcc options (and everything works ok, for some magic
reason) ...

the right way to fix this is binutils/ld, and not glib (and possibly every other
package using pthreads on solaris10).
Comment 17 Andrew Stormont 2009-10-07 07:37:06 UTC
(In reply to comment #13)
> found a workaround!!! ... it seems that on sol10, all pthread_XXX stuff is now
> in libc.so. if you remove the -lpthread -thread options when glib compiles,
> everything looks good.
> 
> for me (not a binutils/linker expert) it looks as /lib/libpthread.so.1 on
> solaris10 only contains references, but /lib/libc.so.1 contains the real code:
> ===
> $ nm /lib/libc.so.1 | grep pthread_mutex_unlock
> 000bdf98 W _pthread_mutex_unlock
> 000bdf98 W pthread_mutex_unlock
> ===
> maybe ld should just skip those
> ===
> $ nm  /lib/libpthread.so.1 | grep pthread_mutex_unlock
> SunOS 5.10 sun4u sparc
> 00000000 A _pthread_mutex_unlock
> 00000000 A pthread_mutex_unlock
> ===
> "empty" functions in /lib/libpthread.so.1 and check/use the other libraries ...
> 
> anyone out there who hack this is?

That doesn't really help if you are using glibc, in that case moving -lpthread
to the front does the trick.

The real problem is still there though.
Comment 18 Andrew Stormont 2010-08-21 20:56:37 UTC
This problem is not SPARC specific. I see it on i386-pc-solaris2.11.  I also
suspect that it is not Solaris specific either as it seems to be caused by
filter symbols not being interpreted correctly by binutils.
Comment 19 Andrew Stormont 2010-08-21 20:59:53 UTC

*** This bug has been marked as a duplicate of 2524 ***
Comment 20 Jackie Rosen 2014-02-16 17:45:24 UTC Comment hidden (spam)