gccclanglto

Does gcc have thin lto?


Clang allows to use a thin lto to speed up compilation time while still keeping most of the advantages of using lto with the option -flto=thin. Does gcc have an equivalent of clang's thin lto?


Solution

  • GCC has an equivalent to Thin LTO: WHOle Program optimizeR (WHOPR)

    WHOPR is an extension of the LTO feature of GCC. You can enable it with -fwhopr (added to the standard LTO options).

    The two stages are

    Now, in practice, GCC WHOPR needs significantly more memory and time than Clang Thin LTO, but the numbers have been improving recently.