This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Why does my executable size not change?
- From: Ian Lance Taylor <iant at google dot com>
- To: richardcavell at mail dot com
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 26 Mar 2011 11:09:09 -0700
- Subject: Re: Why does my executable size not change?
- References: <8CDB9AD5159F5D7-11D4-DF1@web-mmc-d02.sysops.aol.com>
richardcavell@mail.com writes:
> I'm compiling using gcc -std=c99 -pedantic -Wall -Wextra, no
> optimization, on Ubuntu 10.10 32-bit. Currently my executable size is
> 54956 bytes.
>
> Occasionally I change a small bit of code, and recompile. My
> executable file size doesn't change, even when the code definitely
> does something different. However, I would like to know what changes
> are made. Occasionally I could code thing one way or another, and if
> I could shave off a few bytes doing it the other way, I'd like to do
> it.
>
> Why does the executable size not change? Is there some type of
> rounding-up going on?
How are you measuring the size? If you are using ls -l, then, yes,
there are various sorts of rounding to page boundaries going on. Since
you are interested in code size, a better approach would be to run the
"size" program and look at the "text" field.
I don't know what you care about, but note that as a general rule the
size of a program running on GNU/Linux does not correlate very well to
runtime performance.
If you just want to see what changed, use objdump -d and examine the
generated assembler code. Or use the --save-temps option with gcc and
examine the generated .s file.
You can ask gcc to optimize for reduced code size using the -Os option.
Ian