|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
/GL (Whole Program Optimization)
Whole program optimization allows the compiler to perform optimizations with information on all modules in the program. Without whole program optimization, optimizations are performed on a per module (compiland) basis.
Whole program optimization is off by default and must be explicitly enabled. However, it is also possible to explicitly disable it with /GL-.
With information on all modules, the compiler can:
- Optimize the use of registers across function boundaries.
- Inline a function in a module even when the function is defined in another module.
If you compile your program with /GL and /c, you should use the /LTCG linker option to create the output file.
The following compiler options cannot be used with /GL:
The format of files produced with /GL in the current version may not be readable by subsequent versions of Visual C++. You should not ship a .lib file comprised of .obj files that were produced with /GL unless you are willing to ship copies of the .lib file for all versions of Visual C++ you expect your users to use, now and in the future.
.obj files produced with /GL and precompiled header files should not be used to build a .lib file unless the .lib file will be linked on the same machine that produced the /GL .obj file. Information from the .obj file's precompiled header file will be needed at link time.
For more information on the optimizations available with and the limitations of whole program optimization, see /LTCG.
To set this compiler option in the Visual Studio development environment
- Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
- Click the Configuration Properties folder.
- Click the General property page.
- Modify the Whole Program Optimization property.
To set this compiler option programmatically