diff --git a/gen/toobj.c b/gen/toobj.c index 061b5361..b4661feb 100644 --- a/gen/toobj.c +++ b/gen/toobj.c @@ -630,7 +630,7 @@ void FuncDeclaration::toObjFile() 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 @@ void FuncDeclaration::toObjFile() gIR->funcdecls.pop_back(); } + + // template instances should have weak linkage + if (parent->isTemplateInstance()) { + func->setLinkage(llvm::GlobalValue::WeakLinkage); + } } } diff --git a/lib/llvmdcore.bc b/lib/llvmdcore.bc deleted file mode 100644 index af91b154..00000000 Binary files a/lib/llvmdcore.bc and /dev/null differ diff --git a/lib/lphobos.bc b/lib/lphobos.bc deleted file mode 100644 index 90e9956d..00000000 Binary files a/lib/lphobos.bc and /dev/null differ diff --git a/test/imports2.d b/test/imports2.d index 678a5ded..ee271d21 100644 --- a/test/imports2.d +++ b/test/imports2.d @@ -1,6 +1,8 @@ -module test; +module imports2; import std.stdio; void main() { writefln("Hello world!"[]); + print(42); + printf("\n"); }