Pyd on Linux building woes
Lars Ivar Igesund
larsivar at igesund.net
Tue Aug 8 12:46:11 PDT 2006
Kirk McDonald wrote:
> This is a lengthy one, for which I apologize. I've tried to lay the
> problem out as best I can, but I am not sure exactly where the problem
> lies. I am reasonably certain that it is a compilation or linkage
> problem, and not a problem with the code.
> It is possible that this is a problem with gdc? Or am I making some
> stupid mistake?
No, you don't make any stupid mistakes. I call this a rather bad bug in the
DMD frontend (which is why it is possible to see it with both compilers).
The problem is that the template instances usually don't belong in the
object/source file of the template itself, but in the client code. Thus the
same instance (that is, the template is instantiated with the same
type/parameters), might be needed in several object files. AFAIK, this is
not handled (or definately not handled correctly) when compiling one by one
object file, and which is why you won't see any D libs (that is, foo.lib,
or libfoo.a files) with templates around. However, DMD is able to process
all the input .d files at once and in this mode it obviously operate
differently, and when producing the executable, it know everything it needs
to know about the template instance, and thus it is no longer a problem.
So, there a couple of non-perfect options, and the least perfect is not
generating the symbols at all :P The other is duplicating them over the
object files that needs the instance, but then the linker usually don't
know which one to choose. Similar problems can be found with the moduleinfo
symbols in some cases and when used with libraries. The problems seems to
be worse on linux, probably because Walter knows better how to use the OMF
format to the fullest compared to the ELF format.
There should be quite a few bug reports around concerning both of these
Lars Ivar Igesund
blog at http://larsivi.net
DSource & #D: larsivi
More information about the Digitalmars-d