This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Solaris Global Constructor Bug
- To: dholcomb at amlibs dot com
- Subject: Re: Solaris Global Constructor Bug
- From: Zack Weinberg <zack at rabi dot columbia dot edu>
- Date: Mon, 05 Apr 1999 17:20:02 -0400
- cc: egcs-bugs at egcs dot cygnus dot com
On Mon, 5 Apr 1999 15:06:46 -0600, dholcomb@amlibs.com wrote:
>There is an apparent "bug" in the code generated for Solaris
>platforms. When the following program (a simple shared-library test
>program) is compiled with the shared library being compiled with the
>"-nostdlib" switch, global constructors in the shared library are NOT
>being called when the library is (implicitly) being opened. If the
>"-nostdlib" compiler switch is removed from the compilation of the
>shared library, global constructors begin to work as expected.
It seems that on Solaris, -nostdlib implies -nostartfiles.
$ /opt/gnu/bin/gcc -shared -v test.o -o libt.so
Reading specs from /opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/collect2 -V -G
-dy -z text -Y P,/usr/ccs/lib:/usr/lib -Qy -o libt.so
/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/crti.o
/usr/ccs/lib/values-Xa.o
/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/crtbegin.o
-L/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57
-L/opt/gnu/sparc-sun-solaris2.6/lib -L/usr/ccs/bin -L/usr/ccs/lib
-L/opt/gnu/lib test.o -lgcc -lgcc
/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/crtend.o
/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/crtn.o
ld: Software Generation Utilities - Solaris/ELF (3.0)
$ /opt/gnu/bin/gcc -shared -v -nostdlib test.o -o libt.so
Reading specs from /opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/collect2 -V -G
-dy -z text -Y P,/usr/ccs/lib:/usr/lib -Qy -o libt.so
-L/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57
-L/opt/gnu/sparc-sun-solaris2.6/lib -L/usr/ccs/bin -L/usr/ccs/lib
-L/opt/gnu/lib test.o
This is not controlled by the specs file, so it is not easy to change.
I leave it to the Sparc gurus to say whether it is a bug or a feature.
What you wanted was to inhibit linking libc.so; -shared already does
that, so you can just not use -nostdlib on Solaris. You might not
need it on linux or HPUX either.
zw