Getting started with LTO, could use some material on linking/loading

Hadrien Grasland grasland@lal.in2p3.fr
Tue Oct 9 16:25:00 GMT 2018


Hi everyone,

I'm currently experimenting with LTO on a rather big C++ project, which 
looks like it could benefit from it (aggressive use of separate 
compilation brings very deep stack traces in the profile of what should 
be a loop with rather short iterations, which potentially means 
significant function call / return overhead...). Sadly, as I enable LTO, 
many linker errors ensue.

My understanding is that this stems from the fact that LTO allows the 
compiler + linker duo to prune unused symbols more aggressively from 
generated libraries, whereas some external code happened to accidentally 
link to those "unused" symbols. If so, the answer will likely reside in 
either instructing the compiler and linker to keep these symbols around 
and expose them to the outside world, or in telling the client to 
generate its own version of the symbols (the problematic ones are always 
template instantiations).

But in trying to do so, I'm quickly reaching the limits of my limited 
knowledge of how linking and loading precisely works, and need to learn 
more about this part (which anyway keeps biting me periodically for 
other reasons). Can you suggest some learning material that you like on 
this kind of topic ? Specific areas of interest to me include...

  * A good introduction to the general principles of linking and
    loading, of the static and dynamic kind
  * The C++-on-Linux-on-x86 linking environment in particular (e.g. ABI
    & mangling considerations, what's in an ELF file, how to make sense
    of linking errors using binutils...)
  * What GCC's LTO implementation changes in the picture with respect to
    the classic compilation model

For an example of what I'm looking for, I'm currently reading through 
the "Linkers and Loaders" book by John Levine. It's pretty solid, but 
shows its age in places (somewhat wordy style and dated technological 
discussions), so if anyone went through the exercise of writing an 
updated textbook on that topic, I'm interested in that.

Cheers,
Hadrien



More information about the Gcc-help mailing list