The difference between O2 and Os seems to be minor:
Os does not align the variables at word boundaries, but otherwise applies practically all the other O2 optimizations.
http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
-Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.
-Os disables the following optimization flags:
-falign-functions -falign-jumps -falign-loops
-falign-labels -freorder-blocks -freorder-blocks-and-partition
-fprefetch-loop-arrays -ftree-vect-loop-version
And looking closely to those align-options, it looks to me that the user should probably specify the word size in the compiler options, or possibly the alignment happens at n=1 byte, meaning no alignment in practise. I am not sure if the machine-specific default is set to anything meaningful somewhere in the makefiles.
-O3 or even -Ofast might be correct ones to really get some effect.
Has any of the developers played around the optimization options recently?
I found the only real references to decisions related optimization options:
- from Nbd in 2009 as a comment to changeset 15821 ( https://dev.openwrt.org/changeset/15821 ) " turn off -Os by default for the kernel and stick to -O2. Repeated tests have shown the -O2 kernel to react much better to high cpu/network load situations", and
- the current kernel patches ( https://dev.openwrt.org/browser/trunk/t … tion.patch ). It is either "-Os -fno-caller-saves" for size or "-O2 -fno-reorder-blocks -fno-tree-ch -fno-caller-saves " for speed.
On the other hand, the ar71xx specific config files again sets the "CONFIG_CC_OPTIMIZE_FOR_SIZE=y" by default meaning -Os is applied to at least some of the code.