User: Password:
|
|
Subscribe / Log in / New account

What's new in GCC 4.5?

What's new in GCC 4.5?

Posted May 12, 2010 17:55 UTC (Wed) by arekm (subscriber, #4846)
Parent article: What's new in GCC 4.5?

Why these optimizations (like lto) aren't default on?


(Log in to post comments)

What's new in GCC 4.5?

Posted May 12, 2010 21:26 UTC (Wed) by nix (subscriber, #2304) [Link]

Among other things, LTO doubles the size of object files and .a files, increases the time taken to compile (as the individual object files are driven all the way to assembler in case they're linked *without* -flto), and in 4.5 at least interacts badly with debugging information, so distros might not be able to use it for most of their packages (as these are normally built with debugging information which is then separated). Perhaps only speed-critical mathematical stuff and things like the compiler itself will see -fltoing immediately.

What's new in GCC 4.5?

Posted May 14, 2010 18:13 UTC (Fri) by giraffedata (subscriber, #1954) [Link]

Explaining why LTO increases compile time:
the individual object files are driven all the way to assembler

What does that mean?

What's new in GCC 4.5?

Posted May 14, 2010 19:21 UTC (Fri) by nix (subscriber, #2304) [Link]

When compiling a source file with -flto, GCC outputs *two* things; the traditional object file format, run all the way through the target assembler, and (in a single ELF section in the .o) the serialized representation of the GIMPLE tree that gave rise to it (and associated stuff). IIRC, both these outputs come from the same run (so parsing is only done once), but still this is more work and more data to write out than if we could *rely* on -flto being used at link time, because we could stop at the GIMPLE stage and not write out all the native code.

When linking with -flto, only the GIMPLE form is used and the native code in the .o files (and .a files if gold(1) is in use) is thrown away; when linking without it, only the non-GIMPLE form is used, and the GIMPLE in the .o files is thrown away.

(IIRC, of course. I haven't been paying enough attention to GCC development for the last year or so for this to be more authoritative than the ramblings of any passing madman. I should really have waited for jwakely to answer more authoritatively...)

What's new in GCC 4.5?

Posted May 14, 2010 21:18 UTC (Fri) by giraffedata (subscriber, #1954) [Link]

Thanks for the explanation.

I suppose the objective is not just to let someone choose a non-LTO link, but for the .o file to be useful by a linker that doesn't even know what LTO is.

I was going to say the time to write the GIMPLE shouldn't be enough to be a consideration against using -lto, but then I remembered that I once avoided compiling with debugging information because I was using NFS and writing the .o files took significantly longer with -g.

What's new in GCC 4.5?

Posted May 14, 2010 21:45 UTC (Fri) by nix (subscriber, #2304) [Link]

The linker doesn't have to know what LTO is for -flto to work (at least, not unless you put such .o files into .a files); all that needs to know is collect2, and collect2 is part of GCC so it always knows.

What's new in GCC 4.5?

Posted May 14, 2010 22:51 UTC (Fri) by giraffedata (subscriber, #1954) [Link]

First, to be clear, I'm using the term "linker" in the same sense as the phrase "link time" in the name LTO, which means the linker is GCC. GCC is the program to which you feed .o files and get an executable out.

If instead of using GCC to link my .o files I use GNU 'ld', it will still work, right? And it looks like 'ld' doesn't know what LTO is.

Even GCC doesn't always know what LTO is. GCC 3 doesn't.

LTO could have been designed so that 'ld' and GCC 3 could not link the .o files created by gcc -flto, but it looks to me like it was a design objective that they be able to.

What's new in GCC 4.5?

Posted May 14, 2010 22:43 UTC (Fri) by stevenb (guest, #11536) [Link]

What you were going to say would have been true. Writing GIMPLE doesn't cost much time. The problem is that after writing GIMPLE, the code is pushed through the entire compiler pipeline to write the rest of the assembler output too.

So the GIMPLE goes through the compiler pipeline twice: during compilation to an object file, and during link time optimizations. That is where the extra cost comes from.

We have our smartest people working on a solution for this... ;-)

What's new in GCC 4.5?

Posted May 15, 2010 2:13 UTC (Sat) by jwakely (guest, #60262) [Link]

> I should really have waited for jwakely to answer more authoritatively...

I only focus on the C++ library so I'm not up to speed on LTO either, but stevenb is :-)


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds