Vincent Rivière a wrote:
The best compiler options to get small executables are : gcc -O2 -fomit-frame-pointer -s
Sorry, it is wrong, I typed that options too much times. The above options are the "normal" ones for production executables.Use -Os instead of -O2 to get the smallest program size (but maybe slower). Some people prefer to use -Os to maximize the amount of code inside the CPU caches, thus providing more speed.
Use -O3 instead of -O2 to enable hardcore optimizations like automatic function inlining, loops unrolling... In some cases this provide a big performance gain, but the size of the executable usually increases significantly.
There are also individual optimization settings starting with -f, in some particular cases they can be useful.
-- Vincent Rivière