# HG changeset patch # User lindquist # Date 1191384881 -7200 # Node ID 6c6cd097bcdfde8d016ad0587592ed39995674ab # Parent 8605242766084bcf1634b611b8ebea04c67cae6d [svn r21] * Fixed local instances of imported templates diff -r 860524276608 -r 6c6cd097bcdf gen/toobj.c --- a/gen/toobj.c Wed Oct 03 05:41:15 2007 +0200 +++ b/gen/toobj.c Wed Oct 03 06:14:41 2007 +0200 @@ -630,7 +630,7 @@ const llvm::FunctionType* functype = llvm::cast(llvmValue->getType()->getContainedType(0)); // only members of the current module maybe be defined - if (getModule() == gIR->dmodule) + if (getModule() == gIR->dmodule || parent->isTemplateInstance()) { llvmDModule = gIR->dmodule; @@ -730,5 +730,10 @@ gIR->funcdecls.pop_back(); } + + // template instances should have weak linkage + if (parent->isTemplateInstance()) { + func->setLinkage(llvm::GlobalValue::WeakLinkage); + } } } diff -r 860524276608 -r 6c6cd097bcdf lib/llvmdcore.bc Binary file lib/llvmdcore.bc has changed diff -r 860524276608 -r 6c6cd097bcdf lib/lphobos.bc Binary file lib/lphobos.bc has changed diff -r 860524276608 -r 6c6cd097bcdf test/imports2.d --- a/test/imports2.d Wed Oct 03 05:41:15 2007 +0200 +++ b/test/imports2.d Wed Oct 03 06:14:41 2007 +0200 @@ -1,6 +1,8 @@ -module test; +module imports2; import std.stdio; void main() { writefln("Hello world!"[]); + print(42); + printf("\n"); }