For C/C++ applications, with the IBM XL compilers, use at least -O2; with GCC use -O3. These options enable significant performance gains. For IBM COBOL for AIX compilers, consider using the OPTIMIZE directive or -qOPTIMIZE. If debugging the optimized code is a concern, see "Enable production debug" below.
While it is possible to build a single executable that will run on a variety of Power systems, that executable may not be able to exploit features added to newer processors. If you know the range of processors you need to support, use compiler options to specifically target those processors. For the IBM XL compilers, use -qarch to name the oldest architecture you need to support, and -qtune to control what architecture or architectures are most important. With GCC, use the -mcpu and -mtune options.
Turn on debug information with -g even if you are also enabling optimization. Debugging optimized code presents some challenges; if using the the IBM XL v12 or later compiler you can trade ease of debugging for some performance using different levels of -g, for example -g8. See Debug compiler options for more information.
If you do not wish to deploy an executable with debug information for size or other reasons, build with -g, save a copy of the executable with the debug information, and run the strip command on the executable to be deployed. The unstripped executable can be used by the debugger or for performance analysis of the deployed, stripped version. See Production Debug options for more information.
See Production Debug support for more information on how to set up a situation similar to Production Debug in Performance Advisor.
Even if you are not intending to profile your application immediately, enabling the options for Performance Advisor is recommended. The Performance Advisor requires some debugging information, so turn on -g as described in above. If you are using the IBM XL compilers, also enable the option -qlistfmt=xml=all. See Compiler versions and options for more information.