You copied the Doc URL to your clipboard.

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:

-O0

Minimum 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.

-O1

Restricted optimization.

When debugging is enabled, this option gives a generally satisfactory debug view with good code density.

-O2

High optimization. This is the default optimization level.

When debugging is enabled, this option might give a less satisfactory debug view.

-O3

Maximum 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 required. 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.

Was this page helpful? Yes No