What is the difference in gcc between lto and fat-lto-objects

Laser picture Laser · Dec 10, 2012 · Viewed 9.2k times · Source

I have tried to compile to assembler my source code with next flags:
1. -flto
2. -flto -ffat-lto-objects
3. -flto -fno-fat-lto-objects

Third one provides optimized slim LTO code as written in documentation, but I don't see any difference in the output assembly file between first and second, why?

OS: linux
Compiler: GCC 4.7

Answer

Jan Hubička picture Jan Hubička · Mar 29, 2015

The difference between fat and non-fat object files is that fat object files contains both intermediate language as well as the normally compiled code. At linktime, if you invoke compiler without -flto, fat objects will be handled as normal object files (and LTO information discarded), while slim objects will invoke LTO optimizers because there is no way to handle them without it.

If you both compile and link with -flto, both fat and slim objects ought to give you the same binary, just slim objects will be smaller and faster to compile, because you will avoid the redundant code generation.