From e37cb509995d230107b4f45fdbc9ced9b52ca325 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 30 Sep 2012 02:55:38 +0200 Subject: [PATCH] Use -of for object name when building executable with -singleobj. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is what DMD does, and arguably the expected behavior – otherwise, there would be no way other than using -od to prevent races if two compiler instances could ever compile the same file(s) at the same time (e.g. for debug/release configurations). Should we transition to assuming -singleobj by default? --- driver/main.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/driver/main.cpp b/driver/main.cpp index 7246db8d..af0abfba 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -1036,7 +1036,19 @@ int main(int argc, char** argv) { Module* m = static_cast(modules.data[0]); char* name = m->toChars(); - char* filename = m->objfile->name->str; + + char* oname; + char* filename; + if ((oname = global.params.exefile) || (oname = global.params.objname)) + { + filename = FileName::forceExt(oname, global.obj_ext)->toChars(); + if (global.params.objdir) + { + filename = FileName::combine(global.params.objdir, FileName::name(filename)); + } + } + else + filename = m->objfile->name->str; llvm::Linker linker(name, name, context);