From 8d7f0bf0eb088b9278009cf09ea818859e55c81d Mon Sep 17 00:00:00 2001 From: kai Date: Sun, 3 Nov 2013 22:06:49 +0100 Subject: [PATCH] Fix for issue #535. The symbols must have weak_odr linkage if they result from a template instantiation. --- gen/tollvm.cpp | 4 ++-- gen/tollvm.h | 2 +- ir/irclass.cpp | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 9bbaceaf..10241e71 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -454,11 +454,11 @@ llvm::GlobalValue::LinkageTypes DtoInternalLinkage(Dsymbol* sym) return llvm::GlobalValue::InternalLinkage; } -llvm::GlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym) +llvm::GlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym, bool checkInline) { if (DtoIsTemplateInstance(sym)) return templateLinkage; - else if (isAvailableExternally(sym)) + else if (checkInline && isAvailableExternally(sym)) return llvm::GlobalValue::AvailableExternallyLinkage; else return llvm::GlobalValue::ExternalLinkage; diff --git a/gen/tollvm.h b/gen/tollvm.h index 6c72d954..e1eb9492 100644 --- a/gen/tollvm.h +++ b/gen/tollvm.h @@ -58,7 +58,7 @@ LLValue* DtoDelegateEquals(TOK op, LLValue* lhs, LLValue* rhs); // return linkage type for symbol using the current ir state for context LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym); LLGlobalValue::LinkageTypes DtoInternalLinkage(Dsymbol* sym); -LLGlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym); +LLGlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym, bool checkInline = true); // some types LLIntegerType* DtoSize_t(); diff --git a/ir/irclass.cpp b/ir/irclass.cpp index a9618298..001623b9 100644 --- a/ir/irclass.cpp +++ b/ir/irclass.cpp @@ -293,8 +293,10 @@ llvm::GlobalVariable * IrAggr::getInterfaceVtbl(BaseClass * b, bool new_instance DtoConstSize_t(interfaces_index) }; + llvm::GlobalVariable* interfaceInfosZ = getInterfaceArraySymbol(); + interfaceInfosZ->setLinkage(DtoExternalLinkage(cd, false)); llvm::Constant* c = llvm::ConstantExpr::getGetElementPtr( - getInterfaceArraySymbol(), idxs, true); + interfaceInfosZ, idxs, true); constants.push_back(c); } @@ -389,7 +391,7 @@ llvm::GlobalVariable * IrAggr::getInterfaceVtbl(BaseClass * b, bool new_instance *gIR->module, vtbl_constant->getType(), true, - llvm::GlobalValue::ExternalLinkage, + DtoExternalLinkage(cd, false), vtbl_constant, mangle );