/OPT (Optimizations)
| Overview | How Do I | Linker Options
Syntax
/OPT:{REF|NOREF|ICF[,iterations]|NOICF}
This option controls the optimizations that LINK performs during a build. Optimizations generally decrease the image size and increase the program speed, at a cost of increased link time.
Use /OPT:REF to eliminate functions and/or data that is never referenced.
Use /OPT:NOREF to keep functions and/or data that is never referenced.
Use /OPT:ICF[,iterations] to perform identical COMDAT folding. Redundant COMDATs can be removed from the linker output. Iterations specifies the number of times to traverse the symbols for duplicates. The default number of iterations is two. Additional iterations may locate more duplicates uncovered through folding in the previous iteration.
By default, LINK removes unreferenced packaged functions. An object contains packaged functions (COMDATs) if it has been compiled with the /Gy option. This optimization is called transitive COMDAT elimination. To override this default and keep unreferenced COMDATs in the program, specify /OPT:NOREF. You can use the /INCLUDE option to override the removal of a specific symbol.
If /OPT:REF is specified, /OPT:ICF is on by default. If you want /OPT:REF but not /OPT:ICF, you must specify the following:
link /opt:ref /opt:noicf
Specifying /OPT:ICF does not turn on the /OPT:REF option.
If the /DEBUG option is specified, the default for /OPT changes from REF****to NOREF, and all functions are preserved in the image. To override this default and optimize a debugging build, specify /OPT:REF. The /OPT:REF option disables incremental linking.