This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
collect2 bug in 3.3.2 on Tru64 UNIX 5.1
- From: Albert Chin <gcc at lists dot thewrittenword dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 7 Apr 2004 00:48:23 -0500
- Subject: collect2 bug in 3.3.2 on Tru64 UNIX 5.1
- Reply-to: gcc at gcc dot gnu dot org
While building sip-3.10.1 using GCC on Tru64 UNIX 5.1, I encountered
an odd bug, most likely with collect2:
$ gcc -v
gcc version 3.3.2 (TWW)
$ g++ -v -Wl,-v -shared -Wl,-expect_unresolved,'*' \
-Wl,-soname,libsip.so -o libsip.so moc_sipQt.o ...
...
/opt/TWWfsw/gcc332/lib/gcc-lib/alphaev67-dec-osf5.1/3.3.2/collect2 \
-G 8 -O1 -S -shared -hidden_symbol _GLOBAL_* -o libsip.so \
-L/opt/TWWfsw/gcc332/lib/gcc-lib/alphaev67-dec-osf5.1/3.3.2 \
-L/usr/lib/cmplrs/cc \
-L/opt/TWWfsw/gcc332/lib/gcc-lib/alphaev67-dec-osf5.1/3.3.2/../../.. \
-v -expect_unresolved * -soname libsip.so moc_sipQt.o -lstdc++ -lm \
-lgcc_s -lc -lgcc_s
collect2 version 3.3.2 (TWW)
[first call to /bin/ld]
/bin/ld -G 8 -O1 -S -shared -hidden_symbol _GLOBAL_* -o libsip.so \
-L/opt/TWWfsw/gcc332/lib/gcc-lib/alphaev67-dec-osf5.1/3.3.2 \
-L/usr/lib/cmplrs/cc \
-L/opt/TWWfsw/gcc332/lib/gcc-lib/alphaev67-dec-osf5.1/3.3.2/../../.. \
-v -expect_unresolved * -soname libsip.so moc_sipQt.o -lstdc++ -lm \
-lgcc_s -lc -lgcc_s
...
/opt/TWWfsw/gcc332/bin/g++ -x c -c -o /tmp//ccOKHfbi.o \
-fno-exceptions -w /tmp//ccbArUnr.c
[second call to /bin/ld with rewritten command-line]
/bin/ld -G 8 -O1 -S -shared -hidden_symbol _GLOBAL_* -o libsip.so \
-L/opt/TWWfsw/gcc332/lib/gcc-lib/alphaev67-dec-osf5.1/3.3.2 \
-L/usr/lib/cmplrs/cc \
-L/opt/TWWfsw/gcc332/lib/gcc-lib/alphaev67-dec-osf5.1/3.3.2/../../.. \
-v -expect_unresolved * -soname /tmp//ccOKHfbi.o libsip.so \
moc_sipQt.o -lstdc++ -lm -lgcc_s -lc -lgcc_s \
-init _GLOBAL__FI_libsip_so -fini _GLOBAL__FD_libsip_so
...
Notice that inbetween the two calls to /bin/ld, collect2 runs g++ to
generate /tmp//ccbArUnr.o and adds this to the command line. However,
it adds it _between_ '-soname' and 'libsip.so'. Clearly this is wrong.
Looking at gcc/collect2.c I find:
else if ((p = strrchr (arg, '.')) != (char *) 0
&& (strcmp (p, ".o") == 0 || strcmp (p, ".a") == 0
|| strcmp (p, ".so") == 0 || strcmp (p, ".lo") == 0
|| strcmp (p, ".obj") == 0))
{
if (first_file)
{
first_file = 0;
if (p[1] == 'o')
*ld2++ = o_file;
else
{
/* place o_file BEFORE this argument! */
ld2--;
*ld2++ = o_file;
*ld2++ = arg;
^^^^^^^^^^^^^^^^
}
}
I believe this is the culprit. How should I try to fix this? Should I
check if p == '.so' and *(ld2-2) == '-soname'? Or maybe add o_file to
*ld2++ when p == '.so' just like when p == '.o' || p == '.obj'?
--
albert chin (china@thewrittenword.com)