diff gen/linker.cpp @ 306:0baca2feb554 trunk

[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.
author lindquist
date Fri, 27 Jun 2008 23:58:22 +0200
parents 30941d8ee320
children 3c8c58c24aa8
line wrap: on
line diff
--- a/gen/linker.cpp	Fri Jun 27 22:04:35 2008 +0200
+++ b/gen/linker.cpp	Fri Jun 27 23:58:22 2008 +0200
@@ -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 @@
 
 static llvm::sys::Path gExePath;
 
-int linkExecutable()
+int linkExecutable(const char* argv0)
 {
     Logger::println("*** Linking executable ***");
 
@@ -43,11 +46,10 @@
     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 @@
     // 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)