| |||
| Home > Compiler Coding Practices > Compiler optimization levels and the debug view | |||
The precise optimizations performed by the compiler depend both on the level of optimization chosen, and whether you are optimizing for performance or code size.
The compiler supports the following optimization levels:
-O0Minimum optimization. The compiler performs simple optimizations that do not impair the debug view.
When debugging is enabled, this option gives the best possible debug view.
-O1Restricted optimization.
When debugging is enabled, this option gives a generally satisfactory debug view with good code density.
-O2High optimization. This is the default optimization level.
When debugging is enabled, this option might give a less satisfactory debug view.
-O3Maximum optimization. This is the most aggressive form of optimization available. Specifying this option enables multifile compilation by default where multiple files are specified on the command line.
When debugging is enabled, this option typically gives a poor debug view.
Because optimization affects the mapping of object code to
source code, the choice of optimization level with -Ospace and -Otime generally
impacts the debug view.
The option -O0 is the best option to use
if a simple debug view is needed. Selecting -O0 typically increases
the size of the ELF image by 7 to 15%. To reduce the size of your
debug tables, use the --remove_unneeded_entities option.
ARM ELF File Formathttp://infocenter.arm.com/help/topic/com.arm.doc.dui0101-/index.html