changeset 1066:186d44690036

Give compile units LinkOnceLinkage to circumvent duplicate symbols with LLVM linking.
author Christian Kamm <kamm incasoftware de>
date Sun, 08 Mar 2009 16:21:11 +0100
parents 7f0e5ae75fcc
children 7ce8355fbcc6
files gen/todebug.cpp
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gen/todebug.cpp	Sun Mar 08 04:23:44 2009 +0100
+++ b/gen/todebug.cpp	Sun Mar 08 16:21:11 2009 +0100
@@ -500,6 +500,12 @@
         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;
 }