Mercurial > projects > ldc
comparison 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 |
comparison
equal
deleted
inserted
replaced
305:2b72433d5c8c | 306:0baca2feb554 |
---|---|
1 #include "gen/llvm.h" | 1 #include "gen/llvm.h" |
2 #include "llvm/Linker.h" | 2 #include "llvm/Linker.h" |
3 #include "llvm/System/Program.h" | 3 #include "llvm/System/Program.h" |
4 #if _WIN32 | |
5 #include "llvm/Support/SystemUtils.h" | |
6 #endif | |
4 | 7 |
5 #include "root.h" | 8 #include "root.h" |
6 #include "mars.h" | 9 #include "mars.h" |
7 #include "module.h" | 10 #include "module.h" |
8 | 11 |
33 | 36 |
34 ////////////////////////////////////////////////////////////////////////////// | 37 ////////////////////////////////////////////////////////////////////////////// |
35 | 38 |
36 static llvm::sys::Path gExePath; | 39 static llvm::sys::Path gExePath; |
37 | 40 |
38 int linkExecutable() | 41 int linkExecutable(const char* argv0) |
39 { | 42 { |
40 Logger::println("*** Linking executable ***"); | 43 Logger::println("*** Linking executable ***"); |
41 | 44 |
42 // error string | 45 // error string |
43 std::string errstr; | 46 std::string errstr; |
44 | 47 |
45 // find the llvm-ld program | 48 // find the llvm-ld program |
46 llvm::sys::Path ldpath = llvm::sys::Program::FindProgramByName("llvm-ld"); | 49 llvm::sys::Path ldpath = llvm::sys::Program::FindProgramByName("llvm-ld"); |
47 if (ldpath.isEmpty()) | 50 if (ldpath.isEmpty()) |
48 { | 51 { |
49 error("linker program not found"); | 52 ldpath.set("llvm-ld"); |
50 fatal(); | |
51 } | 53 } |
52 | 54 |
53 // build arguments | 55 // build arguments |
54 std::vector<const char*> args; | 56 std::vector<const char*> args; |
55 | 57 |
81 assert(gExePath.isValid()); | 83 assert(gExePath.isValid()); |
82 | 84 |
83 // create path to exe | 85 // create path to exe |
84 llvm::sys::Path exedir(gExePath); | 86 llvm::sys::Path exedir(gExePath); |
85 exedir.set(gExePath.getDirname()); | 87 exedir.set(gExePath.getDirname()); |
86 exedir.createDirectoryOnDisk(true, &errstr); | 88 if (!exedir.exists()) |
87 if (!errstr.empty()) | 89 { |
88 { | 90 exedir.createDirectoryOnDisk(true, &errstr); |
89 error("failed to create path to linking output\n%s", errstr.c_str()); | 91 if (!errstr.empty()) |
90 fatal(); | 92 { |
91 } | 93 error("failed to create path to linking output: %s\n%s", exedir.c_str(), errstr.c_str()); |
94 fatal(); | |
95 } | |
96 } | |
92 | 97 |
93 // strip debug info | 98 // strip debug info |
94 if (!global.params.symdebug) | 99 if (!global.params.symdebug) |
95 args.push_back("-strip-debug"); | 100 args.push_back("-strip-debug"); |
96 | 101 |