From 520bc229eaad5a506af0326668716883a97bc686 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sun, 8 Mar 2009 16:21:11 +0100 Subject: [PATCH] Give compile units LinkOnceLinkage to circumvent duplicate symbols with LLVM linking. --- gen/todebug.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 9b969b87..f856d703 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -500,6 +500,12 @@ llvm::DICompileUnit DtoDwarfCompileUnit(Module* m) false, // isMain, false // isOptimized ); + + // if the linkage stays internal, we can't llvm-link the generated modules together: + // llvm's DwarfWriter uses path and filename to determine the symbol name and we'd + // end up with duplicate symbols + m->ir.irModule->diCompileUnit.getGV()->setLinkage(llvm::GlobalValue::LinkOnceLinkage); + m->ir.irModule->diCompileUnit.getGV()->setName(std::string("llvm.dbg.compile_unit_") + srcpath + m->srcfile->name->toChars()); return m->ir.irModule->diCompileUnit; }