[llvm-dev] intra vs inter module LTO

A. Ilchinger via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 31 09:55:13 PST 2018


It is quite common for larger project to split the source tree into
multiple libraries, which are built statically and linked together at
the end. This practise also has advantages building tests, because only
the library for the classes under test has to be linked.

When it comes to LTO, I understand that it works when multiple .o files
are linked together, doing its magic hopefully optimizing the resulting
binary, be it a library or an executable. This is great for optimizing
the different parts of a larger project individually. I don't know if
there is an official term for that, but I'd call it intra-module LTO,
where module basically means a binary target, be it the only one or
just an intermediate.

I'd like to know if LTO also works in the second step, when multiple .a
libraries and potentially other .o files are linked together to the
final binary. So can LTO also work successfully between modules (being
inter-module).

And if it is possible, do I have to pay attention to some compiler
flags, linker options, etc., or does it work out-of-the-bos with -flto?

Kind regards


More information about the llvm-dev mailing list