Search code examples
gccmingwmingw-w64

What is lto1.exe?


when you inspect mingw you will find the c compiler cc1.exe (funny growing in size in 9.2 it is almost 25 MB ) cc1plus.exe is c++ compiler (same sizes) collect2.exe is linker (afiak) nut what is lto1.exe?

i googled for it more than hour but not found info on this.. is there some good info on this avaliable to read? tnx

ps. i suspect that it may be related to link time optimisation but found nothing more about it and i would like to know better

there is also a question what is gcc.exe g++.exe and mingw32-gcc.exe mingw32-g++.exe then

i need more informatin, the most the better , tnx


Solution

  • This is not mingw / Windos specific; it's a feature / component of GCC.

    what is lto1.exe?

    It's the lto compiler :o). lto is basically byte code written when compiled with -flto where "lto" or "LTO" stands for "link-time optimization".

    These optimizations are not performed by the linker but by the compiler at link time to perform global optimizations when (byte-)code from all the modules is available. The flow is as follows:

    1. The C/C++ compiler (cc1 for C or cc1plus for C++) compiles C/C++ to byte-code and writes it to the assembly file *.s.
    2. Assembly is assembled by the assembler to object code *.o as usual. lto-code is shipped in dedicated sections.
    3. At link time, the linker (plugin) calls back the compiler and supplies all the objects and libraries as requested. byte-code is extracted, and the lto1 compiler compiles it to final machine code.
    4. The final machine code is assembled by the assembler to object code.
    5. The linker links / locates these objects to final executable code.

    You see the byte-code in the lto sections with -save-temps and having a look at the saved *.s files. Recent versions of GCC don't even bother with writing assembly code; they are just writing lto code. To see the assembly code, specify -ffat-lto-objects. Notice however that this is not the final code.

    funny growing in size in 9.2 it is almost 25 MB

    The sizes of GCC executables depend not only on the GCC major version, but also highly on how well the compiler used to build GCC is optimizing.

    [Edit] Some information on LTO can be found on the GCC wiki for LTO. Notice however that this page is no more active. One goto place for gory GCC internals is the gcc-help@gcc.gnu.org mailing list where all the developers are. There is also a section about LTO in the GCC internals.