mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 15:40:55 +03:00
A bunch of updates to version identifiers and platform detection.
This commit is contained in:
parent
07888f95e4
commit
b5420eb22c
1 changed files with 61 additions and 10 deletions
|
@ -186,7 +186,7 @@ int main(int argc, char** argv)
|
|||
global.params.moduleDepsFile = NULL;
|
||||
|
||||
// Set predefined version identifiers
|
||||
VersionCondition::addPredefinedGlobalIdent("LLVM");
|
||||
VersionCondition::addPredefinedGlobalIdent("LLVM"); // For backwards compatibility.
|
||||
VersionCondition::addPredefinedGlobalIdent("LDC");
|
||||
VersionCondition::addPredefinedGlobalIdent("all");
|
||||
#if DMDV2
|
||||
|
@ -592,24 +592,57 @@ int main(int argc, char** argv)
|
|||
if (global.params.useInlineAsm) {
|
||||
VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86");
|
||||
}
|
||||
VersionCondition::addPredefinedGlobalIdent("D_HardFloat");
|
||||
break;
|
||||
case llvm::Triple::x86_64:
|
||||
VersionCondition::addPredefinedGlobalIdent("X86_64");
|
||||
if (global.params.useInlineAsm) {
|
||||
VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86_64");
|
||||
}
|
||||
VersionCondition::addPredefinedGlobalIdent("D_HardFloat");
|
||||
break;
|
||||
case llvm::Triple::ppc:
|
||||
// FIXME: Detect soft float (PPC_SoftFP/PPC_HardFP).
|
||||
VersionCondition::addPredefinedGlobalIdent("PPC");
|
||||
break;
|
||||
case llvm::Triple::ppc64:
|
||||
VersionCondition::addPredefinedGlobalIdent("PPC64");
|
||||
VersionCondition::addPredefinedGlobalIdent("D_HardFloat");
|
||||
break;
|
||||
case llvm::Triple::arm:
|
||||
// FIXME: Detect various FP ABIs (ARM_Soft, ARM_SoftFP, ARM_HardFP).
|
||||
VersionCondition::addPredefinedGlobalIdent("ARM");
|
||||
break;
|
||||
case llvm::Triple::thumb:
|
||||
VersionCondition::addPredefinedGlobalIdent("ARM");
|
||||
VersionCondition::addPredefinedGlobalIdent("Thumb");
|
||||
VersionCondition::addPredefinedGlobalIdent("Thumb"); // For backwards compatibility.
|
||||
VersionCondition::addPredefinedGlobalIdent("ARM_Thumb");
|
||||
VersionCondition::addPredefinedGlobalIdent("ARM_Soft");
|
||||
VersionCondition::addPredefinedGlobalIdent("D_SoftFloat");
|
||||
break;
|
||||
case llvm::Triple::alpha:
|
||||
// FIXME: Detect soft float (Alpha_SoftFP/Alpha_HardFP).
|
||||
VersionCondition::addPredefinedGlobalIdent("Alpha");
|
||||
break;
|
||||
case llvm::Triple::mips:
|
||||
case llvm::Triple::mipsel:
|
||||
// FIXME: Detect 64-bit MIPS (MIPS64).
|
||||
// FIXME: Detect O32/N32/N64 variants (MIPS[64]_{O32,N32,N64}[_SoftFP,_HardFP]).
|
||||
VersionCondition::addPredefinedGlobalIdent("MIPS");
|
||||
break;
|
||||
case llvm::Triple::sparc:
|
||||
// FIXME: Detect SPARC v8+ (SPARC_V8Plus).
|
||||
// FIXME: Detect soft float (SPARC_SoftFP/SPARC_HardFP).
|
||||
VersionCondition::addPredefinedGlobalIdent("SPARC");
|
||||
break;
|
||||
case llvm::Triple::sparcv9:
|
||||
VersionCondition::addPredefinedGlobalIdent("SPARC64");
|
||||
VersionCondition::addPredefinedGlobalIdent("D_HardFloat");
|
||||
break;
|
||||
case llvm::Triple::systemz:
|
||||
// FIXME: Detect S390 (S390) too.
|
||||
VersionCondition::addPredefinedGlobalIdent("S390X");
|
||||
VersionCondition::addPredefinedGlobalIdent("D_HardFloat");
|
||||
break;
|
||||
default:
|
||||
error("invalid cpu architecture specified: %s", global.params.targetTriple.getArchName().str().c_str());
|
||||
|
@ -626,8 +659,7 @@ int main(int argc, char** argv)
|
|||
|
||||
// a generic 64bit version
|
||||
if (global.params.is64bit) {
|
||||
VersionCondition::addPredefinedGlobalIdent("LLVM64");
|
||||
// FIXME: is this always correct?
|
||||
VersionCondition::addPredefinedGlobalIdent("LLVM64"); // For backwards compatibility.
|
||||
VersionCondition::addPredefinedGlobalIdent("D_LP64");
|
||||
}
|
||||
|
||||
|
@ -648,12 +680,13 @@ int main(int argc, char** argv)
|
|||
global.params.os = OSWindows; // FIXME: Check source for uses of MinGW32
|
||||
VersionCondition::addPredefinedGlobalIdent("Windows");
|
||||
VersionCondition::addPredefinedGlobalIdent(global.params.is64bit ? "Win64" : "Win32");
|
||||
VersionCondition::addPredefinedGlobalIdent("mingw32");
|
||||
VersionCondition::addPredefinedGlobalIdent("mingw32"); // For backwards compatibility.
|
||||
VersionCondition::addPredefinedGlobalIdent("MinGW");
|
||||
break;
|
||||
case llvm::Triple::Cygwin:
|
||||
error("CygWin is not yet supported");
|
||||
error("Cygwin is not yet supported");
|
||||
fatal();
|
||||
VersionCondition::addPredefinedGlobalIdent("Cygwin");
|
||||
break;
|
||||
case llvm::Triple::Linux:
|
||||
VersionCondition::addPredefinedGlobalIdent("linux");
|
||||
|
@ -664,21 +697,33 @@ int main(int argc, char** argv)
|
|||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
break;
|
||||
case llvm::Triple::Darwin:
|
||||
global.params.os = OSMacOSX; // FIXME: Do we need to distinguish between Darwin and MacOSX?
|
||||
global.params.os = OSMacOSX;
|
||||
VersionCondition::addPredefinedGlobalIdent("OSX");
|
||||
VersionCondition::addPredefinedGlobalIdent("darwin");
|
||||
VersionCondition::addPredefinedGlobalIdent("darwin"); // For backwards compatibility.
|
||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
break;
|
||||
case llvm::Triple::FreeBSD:
|
||||
VersionCondition::addPredefinedGlobalIdent("freebsd");
|
||||
VersionCondition::addPredefinedGlobalIdent("freebsd"); // For backwards compatibility.
|
||||
VersionCondition::addPredefinedGlobalIdent("FreeBSD");
|
||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
break;
|
||||
case llvm::Triple::Solaris:
|
||||
VersionCondition::addPredefinedGlobalIdent("solaris");
|
||||
VersionCondition::addPredefinedGlobalIdent("solaris"); // For backwards compatibility.
|
||||
VersionCondition::addPredefinedGlobalIdent("Solaris");
|
||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
break;
|
||||
case llvm::Triple::DragonFly:
|
||||
VersionCondition::addPredefinedGlobalIdent("DragonFlyBSD");
|
||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
break;
|
||||
case llvm::Triple::NetBSD:
|
||||
VersionCondition::addPredefinedGlobalIdent("NetBSD");
|
||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
break;
|
||||
case llvm::Triple::OpenBSD:
|
||||
VersionCondition::addPredefinedGlobalIdent("OpenBSD");
|
||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
break;
|
||||
default:
|
||||
error("target '%s' is not yet supported", global.params.targetTriple.str().c_str());
|
||||
fatal();
|
||||
|
@ -707,6 +752,12 @@ int main(int argc, char** argv)
|
|||
// unittests?
|
||||
if (global.params.useUnitTests)
|
||||
VersionCondition::addPredefinedGlobalIdent("unittest");
|
||||
|
||||
if (global.params.useAssert)
|
||||
VersionCondition::addPredefinedGlobalIdent("assert");
|
||||
|
||||
if (!global.params.useArrayBounds)
|
||||
VersionCondition::addPredefinedGlobalIdent("D_NoBoundsChecks");
|
||||
#endif
|
||||
|
||||
// Initialization
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue