This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: Why does my executable size not change?


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


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