This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Resolving LTO symbols for static library boundary
- From: Allan Sandfeld Jensen <linux at carewolf dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 05 Feb 2018 12:26:58 +0100
- Subject: Resolving LTO symbols for static library boundary
- Authentication-results: sourceware.org; auth=none
Hello GCC
In trying to make it possible to use LTO for distro-builds of Qt, I have again
hit the problem of static libraries. In Qt in general we for LTO rely on a
library boundary, where LTO gets resolved when generating the library but no
LTO-symbols are exported in the shared library. This ensure the library has a
well defined binary compatible interface and gets LTO optimizations within
each library. For some private libraries we use static libraries however,
because we don't need binary compatibility, but though we don't need BC
between Qt versions, the libraries should still be linkable with different gcc
versions (and with different compilers). However when LTO is enabled the
static libraries will contain definitions that depend on a single gcc version
making it unsuitable for distribution.
One solution is to enable fat-lto object files for static libraries but that
is both a waste of space and compile time, and disables any LTO optimization
within the library. Ideally I would like to have the static library do LTO
optimizations internally just like a shared library, but then exported as
static library.
I suspect this is more of gcc task than ar/ld task, as it basically boils down
to gcc doing for a static library what it does for shared library, but maybe
export the result as a single combined .o file, that can then be ar'ed into a
compatible static library.
Is this possible?
Best regards
'Allan Jensen