[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.
This commit is contained in:
Tomas Lindquist Olsen 2008-06-27 23:58:22 +02:00
parent 03d26e1178
commit a3c7b8b369
7 changed files with 28 additions and 15 deletions

4
bin/llvmdc.ini Normal file
View file

@ -0,0 +1,4 @@
[Environment]
DFLAGS=-I%@P%/../tango -L-L%@P%/../lib -R%@P%/../lib

View file

@ -1066,7 +1066,7 @@ int main(int argc, char *argv[])
{
if (global.params.link)
//status = runLINK();
linkExecutable();
linkExecutable(argv[0]);
if (global.params.run)
{

View file

@ -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;
}

View file

@ -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)

View file

@ -17,9 +17,10 @@ void linkModules(llvm::Module* dst, const std::vector<llvm::Module*>& 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.

View file

@ -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)
{

View file

@ -1,5 +1,5 @@
module arrays;
module arrays15;
extern(C) int printf(char*, ...);
void integer()