This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Oddities with gcc/g++ linkage
- To: alex dot buell at tahallah dot demon dot co dot uk
- Subject: Re: Oddities with gcc/g++ linkage
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Sun, 20 Sep 1998 21:37:38 +0200
- CC: egcs at cygnus dot com
- References: <Pine.LNX.4.02.9809200154050.10942-100000@tahallah.demon.co.uk>
[g++]
> On my machine that gives a binary executable size of 44k!
[gcc]
> On my machine this gives me a binary executable size of 3k!!
[...]
> Can anyone explain such variances in binary size?
I get the same results, probably because I'm using the same
configuration (i386-pc-linux-gnu). To investigate, I run
g++ -o a a.cc -v --save-temps
This tells me that input, preprocessor output, assembler code, and
object file are about the same size in both cases. So it must be the
linking. Therefore, I run
g++ -o a a.cc -Wl,--verbose
(assuming a GNU linker). The difference becomes quite clear, now:
libstdc++ is linked as well. ld takes the objects
stdstrbufs.o streambuf.o filebuf.o stdstreams.o
from this library, and needs some more libgcc objects in turn.
I'm not entirely sure *why* this is happening. I believe it is a libio
feature, where libio comes from libstdc++ in this case, instead of
libc. Adding -lc doesn't help, because libstdc++ is searched first.
Regards,
Martin