Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 353
Laser Avatar asked Dec 10 '12 10:12

Laser


People also ask

What is GCC LTO?

Background. Link Time Optimization (LTO) gives GCC the capability of dumping its internal representation (GIMPLE) to disk, so that all the different compilation units that make up a single executable can be optimized as a single module.

What is LTO mode?

LTO mode, in which the whole program is read into the compiler at link-time and optimized in a similar way as if it were a single source-level compilation unit. WHOPR or partitioned mode, designed to utilize multiple CPUs and/or a distributed compilation environment to quickly link large applications.

What is LTO link time optimization?

What is Link Time Optimization (LTO) Link Time Optimization is a form of interprocedural optimization that is performed at the time of linking application code. Without LTO, Arm® Compiler for Linux compiles and optimizes each source file independently of one another, then links them to form the executable.


2 Answers

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.

like image 104
Jan Hubička Avatar answered Oct 02 '22 22:10

Jan Hubička


Probably it will be helpful to someone:
Here wrote next:

The current implementation only produces “fat” objects, effectively doubling compilation time and increasing file sizes up to 5x the original size

So as I think it's the main reason.

like image 21
Laser Avatar answered Oct 03 '22 00:10

Laser