3.6.6.19 Whole-program Optimizations Option

The -fwhole-program option runs more aggressive interprocedural optimizations.

The option assumes that the current compilation unit represents the whole program being compiled. All public functions and variables, with the exception of main() and those merged by attribute externally_visible, become static functions and in effect are optimized more aggressively by interprocedural optimizers. While this option is equivalent to proper use of the static keyword for programs consisting of a single file, in combination with option -flto, this flag can be used to compile many smaller scale programs since the functions and variables become local for the whole combined compilation unit, not for the single source file itself.

Whole-program optimizations should not be used with the -fuse-linker-plugin link time optimizations option.

The -fno-whole-program form of this option disables these optimizations and this is the default action if no option is specified.