-frepo trouble

Kevin Bailey noone@nowhere.com
Fri Jun 2 13:56:00 GMT 2000


I'm having trouble compiling a large library (ACE, to be specific)
using -frepo. The Makefiles are repo aware. What they do is
compile all the cpp files with -frepo then attempt to link them
together. This _should_ re-compile any needed template instantiations.
The new object files are then archived into a library.
My problem is that when I link against this library I get tons of
undefined template methods, etc. This implies that needed
instantiations are not getting created and, from what I've seen,
that looks like the case.

As I understand things, every .o file has a corresponding .rpo
file which lists the templates that the file has instantiated and
still needs instantiating. During the compile step, a line beginning
with O will be added to the .rpo file for each template member that
the file needs instantiated. Then, during the link phase, the files will get
re-compiled to instantiate the needed template methods, but each
needed template method will only get instantiated in one place. Every
template method that gets instantiated in a file gets the O changed to a C in
the .rpo file. Thus, by the end of the link, every O listing in any file should
have a corresponding C listing in one of the files.

I did some poking around to try to figure out why my linking
wasn't working and I found that there are several O listings
that don't have corresponding C listings. As far as I can see,
the only way for this to happen is that when a file was re-compiled
to instantiate a template, the template definition wasn't available
(perhaps due to a #define not being set the second time around)
or g++ didn't ask it to instantiate the template method for some
reason or some other bug in g++.

Another strange thing happened when I tried linking a small test
file against all the _object_ files. Every other link would have
a different number of undefined symbols. One time it would only
have 4, the next time it would have hundreds. Interestingly
the number of lines beginning with C in the .rpo files changed
too. I would have thought that g++ would preserve templates
instantiated in an object file. But it seems to be even worse
than this. It appears that when g++ links together a bunch of
files that already have template instantiations, that g++ records
that those instantiations exist but doesn't take into accont that
they go away when the object file is re-compiled (without being
told to re-instantiate).

For example, if a file test.cpp instantiated insertXXXlistXXXintXXX,
then, when re-linking, g++ would think, 'Good, someone instantiated
it. I don't need to ask test.cpp to instantiate it.' g++ would then
re-compile test.cpp without asking it to re-instantiate insertXXX...

Anyways, that's the only reason I can think of for C listings to
go away.

I'm using version 2.95.2 of g++ and version 2.9.5.0.37 of binutils
that I built myself (because the included one didn't come with
collect2.)

Is this a known problem ? Is there a work-around ? Does it
sound like I'm doing something wrong ?

If not, could someone explain how g++ decides which file will
instantiate a template method (the first file to need it ?) and how
it tells the file to instantiate just that one (if it can even do that.)
Also, how does it deal with object files that already include
instantiations ?

Thanks in advance for any help you can give.

P.S. Return address is garbage. Please reply to list.


More information about the Gcc-help mailing list