From f8bf67dc6e0a99b92a6ccf11ccc988cefdf5d838 Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Tue, 14 Dec 2010 14:35:52 +0300 Subject: [PATCH] Fixed a crash when compiling multiple files in one object file --- gen/todebug.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gen/todebug.cpp b/gen/todebug.cpp index cd69b861..393197a6 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -422,6 +422,8 @@ llvm::DICompileUnit DtoDwarfCompileUnit(Module* m) Logger::println("D to dwarf compile_unit"); LOG_SCOPE; + static bool mainUnitCreated = false; + // we might be generating for an import IrModule* irmod = getIrModule(m); @@ -442,15 +444,18 @@ llvm::DICompileUnit DtoDwarfCompileUnit(Module* m) srcpath = srcpath + '/'; } + bool isMain = !mainUnitCreated && gIR->dmodule == m; // make compile unit irmod->diCompileUnit = gIR->difactory.CreateCompileUnit( global.params.symdebug == 2 ? DW_LANG_C : DW_LANG_D, m->srcfile->name->toChars(), srcpath, "LDC (http://www.dsource.org/projects/ldc)", - gIR->dmodule == m, // isMain, + isMain, // isMain, false // isOptimized ); + if (isMain) + mainUnitCreated = true; return irmod->diCompileUnit; }