Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

flto

Enables whole program link time optimization (LTO).

Syntax

Linux:

-flto[=arg]

-fno-lto

Windows:

-flto[=arg]

-fno-lto

Arguments

arg

Is the link time optimization to perform. Possible values are:

full

Tells the compiler to merge all input into a single module before performing link time optimization (LTO).

This is the default if you specify -flto with no argument.

thin

Tells the compiler to read the information from a summary and then do LTO in parallel. This form of LTO (also called ThinLTO) is scalable and incremental.

For more information about thin LTO, see https://clang.llvm.org/docs/ThinLTO.html.

Default

-fno-lto

No link time optimization is performed.

Description

This option enables whole program link time optimization (LTO).

If you specify option -fno-lto, it disables whole program link time optimization.

If you specify -flto or -flto=full, compilation time may increase because of the additional optimizations.

Linux:

You can specify option -ipo as an alias for -flto. -ipo is equivalent to -flto.

If you want to specify a non-default linker, you must also specify option fuse-ld. Otherwise, the default linker ld will be used.

Windows:

You can specify /Qipo as an alias for -flto.

/Qipo is the same as -flto during the compile step. During the link step, the compiler automatically adds -fuse-ld=lld so the proper linker (lld) will be picked up to perform the expected optimizations. This automatic inclusion is only performed for /Qipo; it is not performed for -flto on Windows.

CAUTION:

Files compiled with option -flto should also be linked with the same option, or the link step may fail.

NOTE:

This option only applies to host compilation. When offloading is enabled, it does not impact device-specific compilation.

IDE Equivalent

None

Alternate Options

None

See Also