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

2

21

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

Unlicensed answered 10/12, 2012 at 10:50 Comment(1)
It doesn't really make sense to ask for assembler output and -fno-fat-lto-objects at the same time.Elouise
P
26

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.

Profound answered 29/3, 2015 at 6:38 Comment(1)
And nowadays - unlike back when the question was asked - slim mode is the default, right? (btw I've been reading about LTO and see your name a lot :-)Fastigium
U
3

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.

Unlicensed answered 10/12, 2012 at 11:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.