Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is GCC lto wrapper?

I am using buildroot to prepare images for embedded system. I want to export buildroots internal cross compiler so others can use same version, After command checking GCC version: arm-linux-gcc -vI see configured COLLECT_LTO_WRAPPER to static location on my HDD

 COLLECT_LTO_WRAPPER=/home/user/arm/buildroot/output/host/usr/libexec/gcc/arm-unknown-linux-uclibcgnueabi/4.7.1/lto-wrapper

It will not be correct on another system.

I was only able to find that LTO means Link Time Optimization. Can you please explain what is lto wrapper used for and when is needed?

like image 564
Mihalko Avatar asked Nov 06 '13 08:11

Mihalko


People also ask

What is LTO in GCC?

Link Time Optimization, or LTO, is a GCC-compatible feature that allows the compiler to retain its internal representation of a program or module and use it later with different compilation units to perform optimizations during linking. Also see Link Time Optimization on the GCC wiki.

What is LTO c++?

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.

What is LTO programming?

Link Time Optimization (LTO) refers to program optimization during linking. The linker pulls all object files together and combines them into one program. The linker can see the whole of the program, and can therefore do whole-program analysis and optimization.

Does LTO improve performance?

LTO provides a performance boost for all the compilers.


1 Answers

‫Whe‬n you compile an executable, gcc will optimize and merge same constants only for the current file. Normally, it can't analyze the whole program since the .o files are linked with ld.

‭‫That's the purpose of Interprocedural optimization: Compile the whole executable as if it was a single source file, allowing to make the code more static.

There's a problem with this, LD can't really recognize the exported GIMPLES.
‫‫For this purpose ld use the lto plugin(liblto_plugin.so.0.0.0) which calls make or thelto-wrapper directly which calls lto1 where each lto1 launch is responsible for producing a 'partition' (see the -flto-partition option and the lto-partitions parameter in gcc’s documentation).

like image 88
user2284570 Avatar answered Sep 18 '22 16:09

user2284570