I am making an application on a ATMEGA168 so I have 16Kb of flash space. I added and added functionnalities and the size grows a lot with time.
This is the basic optimization there was in my Makefile (with -Os of course)
-funsigned-char -funsigned-bitfields -fshort-enums -fpack-struct
resulting in my application being 18030 bytes.
I then search a little bit on the net how to optimize for avr-gcc (I have version 4.3.0), what I did is try each parameter one by one with a "make clean all" to check the size result. Some parameters produce bigger size, some give a few bytes, some give hundreds, I took only the one that gave me a gain.
I ended with:
-funsigned-char -funsigned-bitfields -fshort-enums -fpack-struct -ffunction-sections -fdata-sections -fno-split-wide-types -Wl,--relax,--gc-sections -fno-inline-small-functions -mcall-prologues -morder1
and my application is now 15858 bytes
difference : 2172 bytes
So I just wanted to share my result if it can be useful for other people with limited flash :D