From a3c7b8b369a75d8344b08c2b35b90f9e22130145 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Fri, 27 Jun 2008 23:58:22 +0200 Subject: [PATCH] [svn r327] Fixed some more MinGW32 issues. It's now very close to working. Fixed problems with inline asm like: mov EAX, FS:4 , which incidentally is used in the runtime to get the stack bottom, on Windows. --- bin/llvmdc.ini | 4 ++++ dmd/mars.c | 2 +- gen/d-asm-i386.h | 2 +- gen/linker.cpp | 23 ++++++++++++++--------- gen/linker.h | 3 ++- tango/lib/gc/basic/gcx.d | 5 ++++- test/arrays15.d | 4 ++-- 7 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 bin/llvmdc.ini diff --git a/bin/llvmdc.ini b/bin/llvmdc.ini new file mode 100644 index 00000000..5434415f --- /dev/null +++ b/bin/llvmdc.ini @@ -0,0 +1,4 @@ + +[Environment] + +DFLAGS=-I%@P%/../tango -L-L%@P%/../lib -R%@P%/../lib diff --git a/dmd/mars.c b/dmd/mars.c index 0fadb961..ffb6557a 100644 --- a/dmd/mars.c +++ b/dmd/mars.c @@ -1066,7 +1066,7 @@ int main(int argc, char *argv[]) { if (global.params.link) //status = runLINK(); - linkExecutable(); + linkExecutable(argv[0]); if (global.params.run) { diff --git a/gen/d-asm-i386.h b/gen/d-asm-i386.h index 4214021f..be611119 100644 --- a/gen/d-asm-i386.h +++ b/gen/d-asm-i386.h @@ -1929,7 +1929,7 @@ struct AsmProcessor if (operand->constDisplacement) { if (operand->symbolDisplacement.dim) insnTemplate->writebyte('+'); - addOperand2("${",":a}", Arg_Integer, newIntExp(operand->constDisplacement), asmcode); + addOperand(fmt, Arg_Integer, newIntExp(operand->constDisplacement), asmcode); if (opInfo->operands[i] & Opr_Dest) asmcode->clobbersMemory = 1; } diff --git a/gen/linker.cpp b/gen/linker.cpp index df8488a8..34b7536a 100644 --- a/gen/linker.cpp +++ b/gen/linker.cpp @@ -1,6 +1,9 @@ #include "gen/llvm.h" #include "llvm/Linker.h" #include "llvm/System/Program.h" +#if _WIN32 +#include "llvm/Support/SystemUtils.h" +#endif #include "root.h" #include "mars.h" @@ -35,7 +38,7 @@ void linkModules(llvm::Module* dst, const Module_vector& MV) static llvm::sys::Path gExePath; -int linkExecutable() +int linkExecutable(const char* argv0) { Logger::println("*** Linking executable ***"); @@ -43,11 +46,10 @@ int linkExecutable() std::string errstr; // find the llvm-ld program - llvm::sys::Path ldpath = llvm::sys::Program::FindProgramByName("llvm-ld"); + llvm::sys::Path ldpath = llvm::sys::Program::FindProgramByName("llvm-ld"); if (ldpath.isEmpty()) { - error("linker program not found"); - fatal(); + ldpath.set("llvm-ld"); } // build arguments @@ -83,12 +85,15 @@ int linkExecutable() // create path to exe llvm::sys::Path exedir(gExePath); exedir.set(gExePath.getDirname()); - exedir.createDirectoryOnDisk(true, &errstr); - if (!errstr.empty()) + if (!exedir.exists()) { - error("failed to create path to linking output\n%s", errstr.c_str()); - fatal(); - } + exedir.createDirectoryOnDisk(true, &errstr); + if (!errstr.empty()) + { + error("failed to create path to linking output: %s\n%s", exedir.c_str(), errstr.c_str()); + fatal(); + } + } // strip debug info if (!global.params.symdebug) diff --git a/gen/linker.h b/gen/linker.h index 6b619b94..3b1f3573 100644 --- a/gen/linker.h +++ b/gen/linker.h @@ -17,9 +17,10 @@ void linkModules(llvm::Module* dst, const std::vector& MV); /** * Link an executable. + * @param argv0 the argv[0] value as passed to main * @return 0 on success. */ -int linkExecutable(); +int linkExecutable(const char* argv0); /** * Delete the executable that was previously linked with linkExecutable. diff --git a/tango/lib/gc/basic/gcx.d b/tango/lib/gc/basic/gcx.d index 4d6d7ec4..236688de 100644 --- a/tango/lib/gc/basic/gcx.d +++ b/tango/lib/gc/basic/gcx.d @@ -54,7 +54,10 @@ private import cstdlib = tango.stdc.stdlib : calloc, free, malloc, realloc; private import cstring = tango.stdc.string : memcpy, memmove, memset; private import tango.stdc.stdio; -private import tango.stdc.posix.pthread; +version(Posix) +{ + private import tango.stdc.posix.pthread; +} version (GNU) { diff --git a/test/arrays15.d b/test/arrays15.d index 0435615f..91cf6dc6 100644 --- a/test/arrays15.d +++ b/test/arrays15.d @@ -1,5 +1,5 @@ -module arrays; - +module arrays15; + extern(C) int printf(char*, ...); void integer()