Specifies the level of optimization to use when compiling source files.
is one of the following:
Minimum optimization for the performance of the compiled binary. Turns off most optimizations. When debugging is enabled, this option generates code that directly corresponds to the source code. Therefore, this optimization might result in a significantly larger image.
This optimization is the default optimization level.
- Restricted optimization. When debugging is enabled, this option selects a good compromise between image size, performance, and quality of debug view.
- 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 the debug information cannot describe.
- 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
3including those optimizations that are performed with the
-ffp-mode=fastarmclang 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.
CautionThis option is not guaranteed to be fully standards-compliant for all code cases.
-Omaxautomatically enables the
-fltooption and the generated object files are not suitable for creating static libraries. When
-fltois enabled, you cannot build ROPI or RWPI images.
- 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
-fltooption is enabled. The reason is because the
-fltooption is turned on by default at
-Omax, and that option generates files containing bitcode.
- If you are trying to compile at
-Omaxand have separate compile and link steps, then also include
-Omaxon your armlink command line.
NoteLink Time Optimization does not honor the
armclang -mexecute-onlyoption. If you use the
-Omaxoptions, then the compiler cannot generate execute-only code and produces a warning.
- Performs optimizations to reduce code size, balancing code size against code speed.
- Performs optimizations to minimize image size.
If you do not specify
-O, the compiler assumes
-O0. For the best debug view, Arm recommends
-O1 rather than
for the best trade-off between image size, performance, and debug.