This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Oddities with gcc/g++ linkage


[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]