Does gcc have thin lto?

3.6k views Asked by At

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?

1

There are 1 answers

2
Baptiste Wicht On BEST ANSWER

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 standard LTO is fully monolithic (like standard LTO in clang)
  • The WHOPR is a two-stage LTO (like clang Thin LTO)

The two stages are

  • WPA: The serial part that does some global optimizations and partitions the IR
  • LTRANS: Parallel backends to do the optimizations in each partition

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