You copied the Doc URL to your clipboard.


Specifies the level of optimization to use when compiling source files.



Where level is one of the following:


Minimum optimization for the performance of the compiled binary. Turns off most optimizations. When debugging is enabled, this option gives the best possible debug view because the structure of the generated code directly corresponds to the source code.

This is the default optimization level.

Restricted optimization. When debugging is enabled, this option gives a generally satisfactory debug view with good code density.
High optimization. When debugging is enabled, the debug view might be less satisfactory because the mapping of object code to source code is not always clear. The compiler might perform optimizations that cannot be described by debug information.
Very high optimization. When debugging is enabled, this option typically gives a poor debug view. ARM recommends debugging at lower optimization levels.
Enables all the optimizations from level 3 including those performed with the -ffast-math armclang option. This level also performs other aggressive ​optimizations that might violate strict compliance with language standards.
Maximum optimization. Specifically targets performance optimization. Enables all the optimizations from level fast, together with other aggressive optimizations.

This option is not guaranteed to be fully standards-compliant for all code cases.

-Omax automatically enables the armclang -flto option and the generated object files are not suitable for creating static libraries. When -flto is enabled, you cannot build ROPI or RWPI images.


When using -Omax:

  • Code-size, build-time, and the debug view can each be adversely affected.
  • ARM cannot guarantee that the best performance optimization is achieved in all code cases.
  • It is not possible to output meaningful disassembly when the -flto option is enabled, which is turned on by default at -Omax, because this generates files containing bitcode.
  • ARM recommends that you also specify the armlink -Omax option if you invoke the linker separately from the compile step.


Link Time Optimization does not honor the armclang -mexecute-only option. If you use the armclang -flto or -Omax options, then the compiler cannot generate execute-only code.
Performs optimizations to reduce code size, balancing code size against code speed.
Performs optimizations to minimize image size.


If you do not specify -Olevel, the compiler assumes -O0. For debug view, ARM recommends -O1 rather than -O0 for best trade-off between image size, performance, and debug.

Was this page helpful? Yes No