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?
Asked
Active
Viewed 2,987 times
1 Answers
4
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.

Baptiste Wicht
- 7,472
- 7
- 45
- 110
-
I'm using gcc 11.2 and I don't think it supports `-fwhopr` – imba-tjd Jan 27 '22 at 13:45
-
2Indeed, it does not exist anymore. It seems like `-flto=n` should be fairly similar, but not entirely sure. – Baptiste Wicht Jan 27 '22 at 17:27