Mail Archives: djgpp-workers/1999/08/29/14:16:48
On Sun, 29 Aug 1999, Eli Zaretskii wrote:
> But this would disable collect2 unconditionally, right?
AFAIK: Yes.
> What is collect2 *really* needed for?
Essentially, it's for handling of 'template instantiation'. That's a C++
feature where the compiler cannot know, by it's own, which special cases
of a code template have to be compiled into a particular .o file, because
it doesn't know what gets compiled into other .o files of the project.
There are three principal solutions to this:
1) If in doubt, don't compile them in. This will generate error messages
from the linker because of undefined references. That's where 'collect2'
jumps in. It collects these error message (thus the name), and calls the
compiler again to generate the missing code.
2) If in doubt, compile it in. This can generate linker errors because of
multiple definitions of these templated symbols. To get around that,
'weak' symbols are needed to be supported by the binutils, which are
allowed to be defined multiply. Up to now (binutils-2.9.1), this was not
the case for COFF format files, but 2.10 will change that situation.
3) Careful explicit instantiation is forced into the programmers' hands.
That's the '#pragma interface'/'#pragma implementation' stuff used in
gcc-2.7. Problem with it is that this method is an unportable change of
the programming language, effectively. It was also very cumbersome to use,
or so it seems from reading the docs.
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -