gcc optimization flags: rules of thumb
I've looked over some of the gcc optimization settings, such as -O2, -O3, etc., and tried to understand exactly what they do. What are some of the best settings to use? Are there any rules of thumb for what settings to use when compiling certain programs or kernels?
|
There's a good section on optimisation flags in the Gentoo docs, you could also try http://www.freehackers.org/gentoo/gc...flag_gcc3.html
|
I'm just a little wary of using the power of -O3, or maybe even -O2. What do slackware packages use by default?
[edit] I guess I should ask, what do the "official" slackware packages use by default? [/edit] I think they're all stripped, just try to find an ELF executable in /usr/bin that's not. |
i dont know how i can possibly explain it any more simply than the gcc man pages.. but anyways..
-O0 = no optimisation -O1 = perform optimisations that will not increace compile time significantly -O2 = perform optimisations that will not increace binary size significantly -O3 = apply all optimisations -Os = optimise binary size, (almost as optimised as -O2) rule of thumb.... if compile time is an issue, use -O1 if binary file size is an issue, but compile time is not, use -O2 if time, nor binary file size is an issue, use -O3 if file size IS an issue, use -Os if you get seg faults, or have bad hardware, recompile with a lover optimisation. |
All times are GMT -5. The time now is 07:56 PM. |