Export (0) Print
Expand All
Expand Minimize

/GL (Whole Program Optimization)

/GL[-]

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.

.obj files produced with /GL will not be available to such linker utilities as EDITBIN and DUMPBIN.

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

  1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
  2. Click the Configuration Properties folder.
  3. Click the General property page.
  4. Modify the Whole Program Optimization property.

To set this compiler option programmatically

See WholeProgramOptimization Property.

See Also

Compiler Options | Setting Compiler Options

Show:
© 2014 Microsoft