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

断了今生、忘了曾经 提交于 2019-12-04 18:56:41

问题


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


回答1:


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 inovke 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.




回答2:


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.



来源:https://stackoverflow.com/questions/13799452/what-is-the-difference-in-gcc-between-lto-and-fat-lto-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!