From 5647598da9622abdba3a2b16c59d59940f411d8f Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Sat, 21 Jun 2008 03:14:49 +0200 Subject: [PATCH] [svn r306] Fixed: it's now possible to compile and link llvmdc with MinGW32 and msys on Win32 :D I tried it myself ;) Building the runtime still needs some work, but it's a step in the right direction. --- dmd/array.c | 2 +- dmd/expression.c | 6 ++++++ dmd/inifile.c | 4 ++++ dmd/mars.c | 3 +-- dmd/module.c | 2 +- dmd/mtype.c | 5 +++++ dmd/root.c | 2 +- dmd/template.c | 12 ++++++++---- gen/classes.cpp | 6 +++--- gen/todebug.cpp | 8 +++----- premake.lua | 6 +++++- 11 files changed, 38 insertions(+), 18 deletions(-) diff --git a/dmd/array.c b/dmd/array.c index 2d494b5c..35586f2f 100644 --- a/dmd/array.c +++ b/dmd/array.c @@ -13,7 +13,7 @@ #include #include -#if _MSC_VER +#if _MSC_VER || __MINGW32__ #include #endif diff --git a/dmd/expression.c b/dmd/expression.c index 8dc0f3e5..7a73dca6 100644 --- a/dmd/expression.c +++ b/dmd/expression.c @@ -19,6 +19,12 @@ extern "C" char * __cdecl __locale_decpoint; #endif +#if __MINGW32__ +#ifndef isnan +#define isnan _isnan +#endif +#endif + #if IN_GCC // Issues with using -include total.h (defines integer_t) and then complex.h fails... #undef integer_t diff --git a/dmd/inifile.c b/dmd/inifile.c index 0100e61e..d0186624 100644 --- a/dmd/inifile.c +++ b/dmd/inifile.c @@ -13,6 +13,10 @@ #include "root.h" #include "mem.h" +#ifdef __MINGW32__ +#include +#endif + #define LOG 0 char *skipspace(const char *p); diff --git a/dmd/mars.c b/dmd/mars.c index 08e7391a..0fadb961 100644 --- a/dmd/mars.c +++ b/dmd/mars.c @@ -328,8 +328,7 @@ int main(int argc, char *argv[]) #if _WIN32 inifile(argv[0], "llvmdc.ini"); -#endif -#if linux +#elif linux inifile(argv[0], "llvmdc.conf"); #else #error diff --git a/dmd/module.c b/dmd/module.c index 2cbdd3da..e39f7156 100644 --- a/dmd/module.c +++ b/dmd/module.c @@ -12,7 +12,7 @@ #include #include -#ifdef _MSC_VER +#if _MSC_VER || __MINGW32__ #include #endif diff --git a/dmd/mtype.c b/dmd/mtype.c index 698d019b..743acca5 100644 --- a/dmd/mtype.c +++ b/dmd/mtype.c @@ -25,6 +25,8 @@ #include #elif __DMC__ #include +#elif __MINGW32__ +#include #else //#define signbit 56 #endif @@ -32,6 +34,9 @@ #if __APPLE__ #include static double zero = 0; +#elif __MINGW32__ +#include +static double zero = 0; #elif __GNUC__ #include #include diff --git a/dmd/root.c b/dmd/root.c index c7a358f6..f7336e6e 100644 --- a/dmd/root.c +++ b/dmd/root.c @@ -14,7 +14,7 @@ #include #include -#if _MSC_VER +#if _MSC_VER ||__MINGW32__ #include #endif diff --git a/dmd/template.c b/dmd/template.c index 52604018..4138f94b 100644 --- a/dmd/template.c +++ b/dmd/template.c @@ -13,15 +13,18 @@ #include #include +#if !IN_LLVM #if _WIN32 #include long __cdecl __ehfilter(LPEXCEPTION_POINTERS ep); #endif +#endif #include "root.h" #include "mem.h" #include "stringtable.h" - +#include "mars.h" +#include "identifier.h" #include "mtype.h" #include "template.h" #include "init.h" @@ -31,9 +34,6 @@ long __cdecl __ehfilter(LPEXCEPTION_POINTERS ep); #include "aggregate.h" #include "declaration.h" #include "dsymbol.h" -#include "mars.h" -#include "dsymbol.h" -#include "identifier.h" #include "hdrgen.h" #define LOG 0 @@ -2944,9 +2944,11 @@ void TemplateInstance::semantic(Scope *sc) //printf("isnested = %d, sc->parent = %s\n", isnested, sc->parent->toChars()); sc2->parent = /*isnested ? sc->parent :*/ this; +#if !IN_LLVM #if _WIN32 __try { +#endif #endif for (int i = 0; i < members->dim; i++) { @@ -2960,6 +2962,7 @@ void TemplateInstance::semantic(Scope *sc) //printf("test4: isnested = %d, s->parent = %s\n", isnested, s->parent->toChars()); sc2->module->runDeferredSemantic(); } +#if !IN_LLVM #if _WIN32 } __except (__ehfilter(GetExceptionInformation())) @@ -2968,6 +2971,7 @@ void TemplateInstance::semantic(Scope *sc) error("recursive expansion"); fatal(); } +#endif #endif /* If any of the instantiation members didn't get semantic() run diff --git a/gen/classes.cpp b/gen/classes.cpp index 9137e01e..95e93a0e 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -1388,10 +1388,10 @@ static LLConstant* build_class_dtor(ClassDeclaration* cd) #endif } -static uint build_classinfo_flags(ClassDeclaration* cd) +static unsigned build_classinfo_flags(ClassDeclaration* cd) { // adapted from original dmd code - uint flags = 0; + unsigned flags = 0; //flags |= isCOMclass(); // IUnknown bool hasOffTi = false; if (cd->ctor) flags |= 8; @@ -1563,7 +1563,7 @@ void DtoDefineClassInfo(ClassDeclaration* cd) c = defc->getOperand(9); } else { - uint flags = build_classinfo_flags(cd); + unsigned flags = build_classinfo_flags(cd); c = DtoConstUint(flags); } inits.push_back(c); diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 9b8b161b..30b0eb79 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -1,6 +1,7 @@ #include "gen/llvm.h" #include "llvm/Support/Dwarf.h" #include "llvm/CodeGen/MachineModuleInfo.h" +#include "llvm/System/Path.h" #include "declaration.h" #include "module.h" @@ -136,11 +137,8 @@ static LLGlobalVariable* dwarfCompileUnit(Module* m) vals[2] = DtoConstUint(DW_LANG_C);// _D)); // doesn't seem to work vals[3] = DtoConstStringPtr(m->srcfile->name->toChars(), "llvm.metadata"); std::string srcpath(FileName::path(m->srcfile->name->toChars())); - if (srcpath.empty()) { - const char* str = get_current_dir_name(); - assert(str != NULL); - srcpath = str; - } + if (srcpath.empty()) + srcpath = llvm::sys::Path::GetCurrentDirectory().toString(); vals[4] = DtoConstStringPtr(srcpath.c_str(), "llvm.metadata"); vals[5] = DtoConstStringPtr("LLVMDC (http://www.dsource.org/projects/llvmdc)", "llvm.metadata"); diff --git a/premake.lua b/premake.lua index 2853195e..a0ea5ae5 100644 --- a/premake.lua +++ b/premake.lua @@ -2,7 +2,11 @@ project.name = llvmdc -- options OPAQUE_VTBLS = 1 -USE_BOEHM_GC = 1 +if OS == "windows" then + USE_BOEHM_GC = 0 +else + USE_BOEHM_GC = 1 +end -- idgen package = newpackage()