# HG changeset patch # User Christian Kamm # Date 1219587778 -7200 # Node ID 7e2867ed70d99812c37e71984afb35944714ee0b # Parent 0beebf923322eb8e6e00bddb2b3027ab96b31c35 Get rid of isLinux and isWindows in favor of global.params.os. diff -r 0beebf923322 -r 7e2867ed70d9 dmd/mars.c --- a/dmd/mars.c Thu Aug 21 15:35:39 2008 +0200 +++ b/dmd/mars.c Sun Aug 24 16:22:58 2008 +0200 @@ -231,9 +231,6 @@ Module *m; int status = EXIT_SUCCESS; int argcstart = argc; - char* tt_arch = 0; - char* tt_os = 0; - char* data_layout = 0; bool very_verbose = false; // Check for malformed input @@ -312,24 +309,15 @@ VersionCondition::addPredefinedGlobalIdent("LLVMDC"); #endif + // setup default target os to be build os #if _WIN32 - VersionCondition::addPredefinedGlobalIdent("Windows"); - VersionCondition::addPredefinedGlobalIdent("Win32"); - VersionCondition::addPredefinedGlobalIdent("mingw32"); - global.params.isWindows = 1; - tt_os = "-pc-mingw32"; + global.params.os = OSWindows; #elif linux - VersionCondition::addPredefinedGlobalIdent("linux"); - global.params.isLinux = 1; - tt_os = "-pc-linux-gnu"; + global.params.os = OSLinux; #else #error #endif /* linux */ - // !win32 == posix for now - if (!global.params.isWindows) - VersionCondition::addPredefinedGlobalIdent("Posix"); - //VersionCondition::addPredefinedGlobalIdent("D_Bits"); VersionCondition::addPredefinedGlobalIdent("all"); @@ -700,8 +688,8 @@ global.params.isLE = true; global.params.is64bit = false; global.params.cpu = ARCHx86; - tt_arch = "i686"; - data_layout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-f80:32:32-v64:64:64-v128:128:128-a0:0:64"; + global.params.tt_arch = "i686"; + global.params.data_layout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-f80:32:32-v64:64:64-v128:128:128-a0:0:64"; if (global.params.useInlineAsm) { VersionCondition::addPredefinedGlobalIdent("D_InlineAsm"); VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86"); @@ -712,24 +700,24 @@ global.params.isLE = true; global.params.is64bit = true; global.params.cpu = ARCHx86_64; - tt_arch = "x86_64"; - data_layout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"; + global.params.tt_arch = "x86_64"; + global.params.data_layout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"; } else if (strcmp(global.params.llvmArch,"ppc32")==0) { VersionCondition::addPredefinedGlobalIdent("PPC"); global.params.isLE = false; global.params.is64bit = false; global.params.cpu = ARCHppc; - tt_arch = "powerpc"; - data_layout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"; + global.params.tt_arch = "powerpc"; + global.params.data_layout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"; } else if (strcmp(global.params.llvmArch,"ppc64")==0) { VersionCondition::addPredefinedGlobalIdent("PPC64"); global.params.isLE = false; global.params.is64bit = true; global.params.cpu = ARCHppc_64; - tt_arch = "powerpc64"; - data_layout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"; + global.params.tt_arch = "powerpc64"; + global.params.data_layout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"; } else { assert(0 && "Invalid arch"); @@ -750,12 +738,27 @@ VersionCondition::addPredefinedGlobalIdent("LLVM64"); } - assert(tt_arch != 0); - assert(tt_os != 0); - assert(data_layout != 0); - global.params.tt_arch = tt_arch; - global.params.tt_os = tt_os; - global.params.data_layout = data_layout; + + // setup version idents and tt_os for chosen target os + switch(global.params.os) + { + case OSWindows: + VersionCondition::addPredefinedGlobalIdent("Windows"); + VersionCondition::addPredefinedGlobalIdent("Win32"); + VersionCondition::addPredefinedGlobalIdent("mingw32"); + global.params.tt_os = "-pc-mingw32"; + break; + + case OSLinux: + VersionCondition::addPredefinedGlobalIdent("linux"); + VersionCondition::addPredefinedGlobalIdent("Posix"); + global.params.tt_os = "-pc-linux-gnu"; + break; + + default: + assert(false && "Target OS not supported"); + } + // Initialization Type::init(); diff -r 0beebf923322 -r 7e2867ed70d9 dmd/mars.h --- a/dmd/mars.h Thu Aug 21 15:35:39 2008 +0200 +++ b/dmd/mars.h Sun Aug 24 16:22:58 2008 +0200 @@ -37,6 +37,22 @@ struct Array; +// LLVMDC +enum ARCH +{ + ARCHx86, + ARCHx86_64, + ARCHppc, + ARCHppc_64 +}; + +enum OS +{ + OSLinux, + OSWindows, + OSMacOSX +}; + // Put command line switches in here struct Param { @@ -48,11 +64,10 @@ char symdebug; // insert debug symbolic information char optimize; // run optimizer char optimizeLevel; // optimization level - char cpu; // target CPU + ARCH cpu; // target CPU + OS os; // target OS char is64bit; // generate 64 bit code char isLE; // generate little endian code - char isLinux; // generate code for linux - char isWindows; // generate code for Windows char scheduler; // which scheduler to use char useDeprecated; // allow use of deprecated features char useAssert; // generate runtime code for assert()'s @@ -305,15 +320,6 @@ MATCHexact // exact match }; -// LLVMDC -enum ARCH -{ - ARCHx86, - ARCHx86_64, - ARCHppc, - ARCHppc_64 -}; - void error(Loc loc, const char *format, ...); void verror(Loc loc, const char *format, va_list); void fatal(); diff -r 0beebf923322 -r 7e2867ed70d9 gen/linker.cpp --- a/gen/linker.cpp Thu Aug 21 15:35:39 2008 +0200 +++ b/gen/linker.cpp Sun Aug 24 16:22:58 2008 +0200 @@ -72,7 +72,7 @@ else exestr = "a.out"; } - if (global.params.isWindows) + if (global.params.os == OSWindows) exestr.append(".exe"); std::string outopt = "-o=" + exestr; @@ -151,13 +151,13 @@ } // default libs - if(global.params.isLinux) + if(global.params.os == OSLinux) { args.push_back("-lpthread"); args.push_back("-ldl"); args.push_back("-lm"); } - else if (global.params.isWindows) + else if (global.params.os == OSWindows) { // FIXME: I'd assume kernel32 etc } @@ -174,12 +174,11 @@ std::string runtime_path(global.params.runtimePath); // path seperator can be \ on windows, but we check for / - if (global.params.isWindows) - { - int i=0; - while ((i = runtime_path.find("\\", i)) > 0) - runtime_path.replace(i, 1, "/"); - } +#if _WIN32 + int i=0; + while ((i = runtime_path.find("\\", i)) > 0) + runtime_path.replace(i, 1, "/"); +#endif if (*runtime_path.rbegin() != '/') runtime_path.append("/"); diff -r 0beebf923322 -r 7e2867ed70d9 gen/tollvm.cpp --- a/gen/tollvm.cpp Thu Aug 21 15:35:39 2008 +0200 +++ b/gen/tollvm.cpp Sun Aug 24 16:22:58 2008 +0200 @@ -705,7 +705,7 @@ return gIR->mutexType; // win32 - if (global.params.isWindows) + if (global.params.os == OSWindows) { // CRITICAL_SECTION.sizeof == 68 std::vector types(17, LLType::Int32Ty);