Link time affected by debug info?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Link time affected by debug info?

Pierre Sarrazin
Hi.  I work on a large C++ application that takes a lot more time
to link when I compile the sources with debugging information (-g
switch of g++ 3.4.2).  (The linking is static and produces an 20
meg executable file.)

Why does the presence of debugging information slow the linking
process so much?  It would seem like all the linker has to do
is to copy the debug info to the executable without caring about
its contents.  The complexity of the linking task does not seem
to depend on that info.  I'm trying to determine if the problem is
with the linker or with gcc.  Thanks.

--
Pierre Sarrazin <sarrazip at sympatico dot ca>
Reply | Threaded
Open this post in threaded view
|

Re: Link time affected by debug info?

Alan Modra
On Wed, Nov 16, 2005 at 06:03:11PM -0500, Pierre Sarrazin wrote:

> Hi.  I work on a large C++ application that takes a lot more time
> to link when I compile the sources with debugging information (-g
> switch of g++ 3.4.2).  (The linking is static and produces an 20
> meg executable file.)
>
> Why does the presence of debugging information slow the linking
> process so much?  It would seem like all the linker has to do
> is to copy the debug info to the executable without caring about
> its contents.  The complexity of the linking task does not seem
> to depend on that info.  I'm trying to determine if the problem is
> with the linker or with gcc.  Thanks.

The linker optimises the debug info.  You may find that the current cvs
linker is much faster than whatever you are currently using.

--
Alan Modra
IBM OzLabs - Linux Technology Centre
Reply | Threaded
Open this post in threaded view
|

Re: Link time affected by debug info?

Ravi Ramaseshan
Hi,

On 11/16/05, Alan Modra <[hidden email]> wrote:

> On Wed, Nov 16, 2005 at 06:03:11PM -0500, Pierre Sarrazin wrote:
> > Hi.  I work on a large C++ application that takes a lot more time
> > to link when I compile the sources with debugging information (-g
> > switch of g++ 3.4.2).  (The linking is static and produces an 20
> > meg executable file.)
> >
> > Why does the presence of debugging information slow the linking
> > process so much?  It would seem like all the linker has to do
> > is to copy the debug info to the executable without caring about
> > its contents.  The complexity of the linking task does not seem
> > to depend on that info.  I'm trying to determine if the problem is
> > with the linker or with gcc.  Thanks.
>
> The linker optimises the debug info.  You may find that the current cvs
> linker is much faster than whatever you are currently using.

Shouldn't one expect that since there would be lots of relocations to
be handled by the linker in the debugging sections ? Maybe the newer
linker may be faster than whatever you were using, but I would still
expect the linker to be slower when compiling your application with
debugging information.

Please correct me if I am wrong here.

Regards,
--
Ravi Ramaseshan
http://www.geocities.com/ramaseshan_ravi/

" Reality is only something we believe in strongly. "
Reply | Threaded
Open this post in threaded view
|

Re: Link time affected by debug info?

Alan Modra
On Fri, Nov 18, 2005 at 01:23:49AM -0800, Ravi Ramaseshan wrote:
[about debug info slowing down the linker]
> Shouldn't one expect that since there would be lots of relocations to
> be handled by the linker in the debugging sections ? Maybe the newer
> linker may be faster than whatever you were using, but I would still
> expect the linker to be slower when compiling your application with
> debugging information.

Yes, debug relocations will contribute to link time.  So will the mere
fact that the linker needs to copy more data around.  However, the
biggest time consumer is the optimisation.  Particularly with older
linkers, the string merging process takes a lot of time.  (Debug info
tends to have a lot of strings.)

--
Alan Modra
IBM OzLabs - Linux Technology Centre