This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ld on sparc-solaris: linkage order
- To: "H . J . Lu" <hjl at lucon dot org>
- Subject: Re: ld on sparc-solaris: linkage order
- From: Volker Boerchers <boercher at kidata dot de>
- Date: Thu, 13 Jul 2000 18:22:35 +0200 (CEST)
- cc: gcc at gcc dot gnu dot org
On Thu, 13 Jul 2000, H . J . Lu wrote:
> On Thu, Jul 13, 2000 at 12:33:53PM +0200, Volker Boerchers wrote:
> > On Wed, 12 Jul 2000, H . J . Lu wrote:
> > > On Wed, Jul 12, 2000 at 01:11:56PM +0200, Volker Boerchers wrote:
> > > > Hi,
> > > >
> > > > we are having problems getting a multithreaded application to run on
> > > > sparc-solaris7 (gcc-2.95.2, ld version 2.10 (with BFD 2.10)).
> > > >
> > > > we found in the sun docs
> > > > (http://docs.sun.com:80/ab2/coll.45.10/MTP/@Ab2PageView/14940?DwebQuery=thread&Ab2Lang=C&Ab2Enc=iso-8859-1),
> > > > that the linkage order of libc and libthread has to be -lpthread -lc.
> > > >
> > > > So we are fixing now the link line in the makefiles to see if this helps.
> > > >
> > > > The sunpro linker has an option `-mt' to ensure this order automatically.
> > >
> > > If you use gcc, you can modify the specs file.
> >
> > thank you for this hint. By looking into the file (for the first time...)
> > i get a slight idea how it could be done. Is there a documentation of the
> > syntax of this file?
> >
> > Wouldn't it be good to have an appropriate change in the spec file (or
> > whereever) _by default_ on solaris?
> >
>
> I think gcc should take -mt on Solaris. Could you please send me a
> simple testcase so that I can verify it on my Solaris?
Hopefully the attached (trivial) test is sufficient. I can not provide a
test program that crashes on solaris. - Our problems are not gone after
changing the link order.
I'm not sure about some details: Linking with libpthread leads
to linking with libthreads also - this way the sequence may also be
libpthread - libc - libthread
Don't know if this is a problem. I don't have the sun compiler so i can't
check what the `-mt' really does.
Regards,
Volker
--
Volker Börchers, kidata AG, Königswinter, Germany
GCC = gcc
#GCC = gcc -mt
LDD = ldd
CHECK_SEQ = check_seq
SRC = t.c
PRG = t
check: $(PRG)
@$(CHECK_SEQ) $(PRG)
$(PRG)::
echo "int main() { return 0; }" > $(SRC)
$(GCC) -lc -lpthread -o $(PRG) $(SRC)
$(LDD) $(PRG)
clean:
$(RM) $(PRG) $(SRC)
#!/bin/bash
f=$1
# the perl script checks if libc is linked before *any* of
# libthread or libpthread (only the last occurence of lib.?thread
# is remembered)
ldd $f 2>/dev/null \
| perl -nale '
if($F[0] =~ /libc\./) { $c = $.; }
elsif($F[0] =~ /libp?thread\./) { $t = $.; }
END{
if($c && $t && $c < $t) {
print "'$f': wrong linkage";
1;
} else {
print "'$f': OK";
0;
}
}'