Executable size

Douglas Richardson douglas.richardson@gaussvip.com
Wed Sep 25 11:34:00 GMT 2002


Chris,

I noticed the same thing. Based on some test programs I wrote I believe that
the C++ STL is to blame.

I wrote two hello world programs that I compiled with g++, one including
<iostream> and using cout, the other one including <stdio.h> and using
printf. Both were statically linked with the runtime libraries and stripped.
The program that used cout was about 194k while the one that used printf was
about 4k.

I also wrote a small test program that only included <vector> and it was
about 32k.

I know the STL library that ships with g++ has changed since 2.95, that that
is probably why you have seen the growth in your program size.

The only ways I can think of to reduce your code size is to either use gcc
2.95 or replace the code that relies on STL. I know that isn't a very
satisfying answer, but it's all I got.

Douglas Richardson.

-----Original Message-----
From: Chris Croswhite [mailto:ccroswhite@get2chip.com]
Sent: Wednesday, September 25, 2002 11:06
To: Douglas Richardson
Subject: RE: Executable size


I am currently using 3.2, but I have watched from 2.95 to 3.03, 3.1 and
then 3.2 that the executable is growing by at least 30%.  I have tried
this across all optimizations - O,O2,O3,g.  In the case of -g, the
executable is 55% larger, in the case of O3 it is 31% larger (than using
2.953).


Here:

2.953:
-g = 30560264
-O = 8889831
-O2 = 8893383
-O3 = 9009271

3.2:
-g = 63274234
-O = 11198086
-O2 = 11458534
-O3 = 11252525

The code base is mixed c/c++ but I use g++ to compile everything.  I am
making a statically linked executable.

TIA,
Chris


On Wed, 2002-09-25 at 10:57, Douglas Richardson wrote:
> Chris,
> 
> Are you using any optimizations? How are you linking with the runtime
> libraries?
> 
> Send the output of gcc -v.
> 
> Douglas Richardson.
> 
> -----Original Message-----
> From: Chris Croswhite [mailto:ccroswhite@get2chip.com]
> Sent: Wednesday, September 25, 2002 10:55
> To: gcc-help@gcc.gnu.org
> Subject: Executable size
> 
> 
> Sirs,
> 
> I am trying to figure out how to reduce the size of my executable (that
> has grown with the increments of gcc upgrades even though the code base
> has not changed).  I would like to understand how I can reduce/cut out
> so that the executable to back down to the 2.953 size.  Can anyone give
> me some pointers?
> 
> TIA,
> Chris
> 



More information about the Gcc-help mailing list