Re: GCC 10 LTO documentation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 21 Jun 2021 at 14:42, Chris S wrote:
> Is it possible to build static libraries that have LTO optimizations
> applied to the object code they contain (that is, all the code in that
> library is optimized together with LTO), but when built together into a
> final binary, no additional LTO is performed?  We have several large,
> static libraries that are mostly unrelated, and are looking for ways to
> reduce a massive increase in build times after moving to g++10, where
> almost 80% of the time is spent in LTO.  Having optimized individual
> libraries but not a global optimized binary might be a reasonable
> tradeoff.  Is this possible?

A static library is just an archive file containing object files. No
LTO is done "between" those files, they're just added to the archive.
That's because creating a static library is not "linking".

If you do not use -flto when doing the final link, you might as well
not use -flto when compiling the objects that go into your static
library, because otherwise you're adding all the extra LTO information
to the objects and then ignoring it when linking.

If you use dynamic libraries, they can be LTO-optimized internally,
and you get partial benefits of LTO even if you don't use LTO when
linking the final binary.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux