help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ld Linker extremely slow. Possible to optimze link time?


From: Bernd Strieder
Subject: Re: ld Linker extremely slow. Possible to optimze link time?
Date: Thu, 08 Feb 2007 15:50:38 +0100
User-agent: KNode/0.10.1

Hello,

Stephan Kuhagen wrote:

> Bernd Strieder wrote:
> 
>> When using templates a lot, a lot of functions are generated multiple
>> times and the duplicates have to be removed by the linker. There are
>> optimizations to improve that, some gcc make them possible, others
>> not, this is what I found out.
> 
> Are there possibly some command line options to tweak some of these
> optimizations?

I have not found any. That's why I had to ask. I have some keywords to
look for, I found a few references with google telling me what I wrote
before, but nothing specific, only a shade of the background.

> Using different compilers or self compiled versions of 
> gcc is not really an option for me, because I run a continuous build
> system here which compiles several millions LOCs in a loop, using
> ccache and distcc (which needs the same version of gcc on every
> compile host, and I'm only responsible for half of them).

You could just try a small example using a self-compiled gcc on one
machine, whether there is a difference for you. If you compile
gcc-4.1.2-20070129 and get slow links, then it could be something
depending on the platform, which either changes configuration of gcc,
or the compilation of the example. If you compile gcc-4.1.2-20070129
and get a fast link, as I do, then I think we have reduced it to the
gcc sources, where something has been changed between 4.1.0/4.1.1 and
4.1.2.


>> Perhaps you had less problems with FC<6, do you remember?
> 
> I skipped FC5 and used FC4 before. As far as I remember, link times
> did not change significantly between the versions. I think, the
> compiler version was 3.4.x (x=4?).

I cannot remember the exact circumstances I had the problems before,
too. I had it before, this is sure. Since SuSE switched from gcc-3.3
directly to 4.0, I never had a 3.4 system compiler, but self-compiled
ones. I think there have been a few self-compiled gccs with slow link
times as well. I wish I had taken some notes on this.

> 
> Maybe some improvements can be done by some template usage tricks, so
> the compiler/linker knows, which symbols/functions are needed?

If my guesses are valid, then the slow link problem is due to removing
duplicated template instantiations by comparison of the code byte by
byte. The only way to avoid this by adjusting sources would be turning
automatic instantiation off, i.e. not generating duplicates, which is
plainly impractical for any project with more than trivial template
use.

We basically can only hope, that somebody can tell us, what causes the
switch between the

        .section        .text.<some symbol>,comdat
        .section        .gnu.linkonce.t.<some symbol>,"ax",@progbits

Either a compiler patch, a platform setting, a compiler configuration
switch, or a compiler runtime switch. I've run out of keywords to
search with. I think I will turn to some gcc mailing lists next week,
if there is no answer here.

Kind regards,

Bernd



reply via email to

[Prev in Thread] Current Thread [Next in Thread]