help-gplusplus
[Top][All Lists]
Advanced

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

Re: GCC 2.95.2 -frepo option


From: Bernd Strieder
Subject: Re: GCC 2.95.2 -frepo option
Date: Mon, 23 May 2005 12:14:42 +0200
User-agent: KNode/0.9.0

Hello,

kaedeRukawa_jp@hotmail.com wrote:

> I try to used -frepo to create a repository for my template classes.
> But I got an undefine reference all the time.  The following are the
> code snipplet:

For -frepo to work you have to link with the compiler driver. I'm not
even sure that it is supported on all platforms.

The repository is used at link-time to find out the missing instances of
templates, to decide which object file to recompile with the missing
instance included, and finally running the compiler to recompile the
object files in question.

With -frepo you can save time when repeatedly compiling code with small
changes. With larger changes it can take some time, because there might
be quite a loop before all missing instances are known. If some
instance needs other instances not used before, then this will not be
recognized before trying to link the next round. Once I had a file
which had to be recompiled about 20 times during the initial link with
-frepo. That file combined a lot of templates in the project, it was by
far the biggest one in object code size and, naturally in compile time.
The initial build was almost 3 times the time without -frepo. On
successive builds with only small changes (i.e. not creating new
instances) this was not necessary, and build times were some percents
below those without -frepo. Using -frepo you can save compile-time, the
killer might be the repeated link-times to resolve the missing
instances.

So in the end you can save some time in quite some cases, but not overly
much by using -frepo, but you might even lose a lot of time in
unexpected situations with template-heavy code. This is probably the
reason it has never been used a lot. If you look for the famous
"export" keyword, you will find, that this was supposed to provide
something similar to -frepo. There is only one compiler implementing
it, AFAIK, and there is still a lot discussion about it, not just HOW
TO, but also WHETHER. All repository solutions create problems with
optimizations, e.g. inlining template code (which is crucial in many
situations) becomes difficult.

My conclusion is, that I have no real measurable, and guaranteed total
advantage from -frepo compared to the "instantiate everywhere" solution
used now. I have some doubt that any comparable automatic technique
will provide an advantage under all circumstances.

> 
> -- a.h --
> #ifndef A_H
> #define A_H
> 
> #incldue <map>

The code you posted is not compileable. Please, post the exact code and
the exact commands you used to compile and link to reproduce the
problem, and the output of "gcc -v". Otherwise, all answers you can get
are guesswork.

Bernd Strieder



reply via email to

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