mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 16:11:08 +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;
|
global.params.moduleDepsFile = NULL;
|
||||||
|
|
||||||
// Set predefined version identifiers
|
// Set predefined version identifiers
|
||||||
VersionCondition::addPredefinedGlobalIdent("LLVM");
|
VersionCondition::addPredefinedGlobalIdent("LLVM"); // For backwards compatibility.
|
||||||
VersionCondition::addPredefinedGlobalIdent("LDC");
|
VersionCondition::addPredefinedGlobalIdent("LDC");
|
||||||
VersionCondition::addPredefinedGlobalIdent("all");
|
VersionCondition::addPredefinedGlobalIdent("all");
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
|
@ -592,24 +592,57 @@ int main(int argc, char** argv)
|
||||||
if (global.params.useInlineAsm) {
|
if (global.params.useInlineAsm) {
|
||||||
VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86");
|
VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86");
|
||||||
}
|
}
|
||||||
|
VersionCondition::addPredefinedGlobalIdent("D_HardFloat");
|
||||||
break;
|
break;
|
||||||
case llvm::Triple::x86_64:
|
case llvm::Triple::x86_64:
|
||||||
VersionCondition::addPredefinedGlobalIdent("X86_64");
|
VersionCondition::addPredefinedGlobalIdent("X86_64");
|
||||||
if (global.params.useInlineAsm) {
|
if (global.params.useInlineAsm) {
|
||||||
VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86_64");
|
VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86_64");
|
||||||
}
|
}
|
||||||
|
VersionCondition::addPredefinedGlobalIdent("D_HardFloat");
|
||||||
break;
|
break;
|
||||||
case llvm::Triple::ppc:
|
case llvm::Triple::ppc:
|
||||||
|
// FIXME: Detect soft float (PPC_SoftFP/PPC_HardFP).
|
||||||
VersionCondition::addPredefinedGlobalIdent("PPC");
|
VersionCondition::addPredefinedGlobalIdent("PPC");
|
||||||
break;
|
break;
|
||||||
case llvm::Triple::ppc64:
|
case llvm::Triple::ppc64:
|
||||||
VersionCondition::addPredefinedGlobalIdent("PPC64");
|
VersionCondition::addPredefinedGlobalIdent("PPC64");
|
||||||
|
VersionCondition::addPredefinedGlobalIdent("D_HardFloat");
|
||||||
break;
|
break;
|
||||||
case llvm::Triple::arm:
|
case llvm::Triple::arm:
|
||||||
|
// FIXME: Detect various FP ABIs (ARM_Soft, ARM_SoftFP, ARM_HardFP).
|
||||||
VersionCondition::addPredefinedGlobalIdent("ARM");
|
VersionCondition::addPredefinedGlobalIdent("ARM");
|
||||||
|
break;
|
||||||
case llvm::Triple::thumb:
|
case llvm::Triple::thumb:
|
||||||
VersionCondition::addPredefinedGlobalIdent("ARM");
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
error("invalid cpu architecture specified: %s", global.params.targetTriple.getArchName().str().c_str());
|
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
|
// a generic 64bit version
|
||||||
if (global.params.is64bit) {
|
if (global.params.is64bit) {
|
||||||
VersionCondition::addPredefinedGlobalIdent("LLVM64");
|
VersionCondition::addPredefinedGlobalIdent("LLVM64"); // For backwards compatibility.
|
||||||
// FIXME: is this always correct?
|
|
||||||
VersionCondition::addPredefinedGlobalIdent("D_LP64");
|
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
|
global.params.os = OSWindows; // FIXME: Check source for uses of MinGW32
|
||||||
VersionCondition::addPredefinedGlobalIdent("Windows");
|
VersionCondition::addPredefinedGlobalIdent("Windows");
|
||||||
VersionCondition::addPredefinedGlobalIdent(global.params.is64bit ? "Win64" : "Win32");
|
VersionCondition::addPredefinedGlobalIdent(global.params.is64bit ? "Win64" : "Win32");
|
||||||
VersionCondition::addPredefinedGlobalIdent("mingw32");
|
VersionCondition::addPredefinedGlobalIdent("mingw32"); // For backwards compatibility.
|
||||||
VersionCondition::addPredefinedGlobalIdent("MinGW");
|
VersionCondition::addPredefinedGlobalIdent("MinGW");
|
||||||
break;
|
break;
|
||||||
case llvm::Triple::Cygwin:
|
case llvm::Triple::Cygwin:
|
||||||
error("CygWin is not yet supported");
|
error("Cygwin is not yet supported");
|
||||||
fatal();
|
fatal();
|
||||||
|
VersionCondition::addPredefinedGlobalIdent("Cygwin");
|
||||||
break;
|
break;
|
||||||
case llvm::Triple::Linux:
|
case llvm::Triple::Linux:
|
||||||
VersionCondition::addPredefinedGlobalIdent("linux");
|
VersionCondition::addPredefinedGlobalIdent("linux");
|
||||||
|
@ -664,21 +697,33 @@ int main(int argc, char** argv)
|
||||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||||
break;
|
break;
|
||||||
case llvm::Triple::Darwin:
|
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("OSX");
|
||||||
VersionCondition::addPredefinedGlobalIdent("darwin");
|
VersionCondition::addPredefinedGlobalIdent("darwin"); // For backwards compatibility.
|
||||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||||
break;
|
break;
|
||||||
case llvm::Triple::FreeBSD:
|
case llvm::Triple::FreeBSD:
|
||||||
VersionCondition::addPredefinedGlobalIdent("freebsd");
|
VersionCondition::addPredefinedGlobalIdent("freebsd"); // For backwards compatibility.
|
||||||
VersionCondition::addPredefinedGlobalIdent("FreeBSD");
|
VersionCondition::addPredefinedGlobalIdent("FreeBSD");
|
||||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||||
break;
|
break;
|
||||||
case llvm::Triple::Solaris:
|
case llvm::Triple::Solaris:
|
||||||
VersionCondition::addPredefinedGlobalIdent("solaris");
|
VersionCondition::addPredefinedGlobalIdent("solaris"); // For backwards compatibility.
|
||||||
VersionCondition::addPredefinedGlobalIdent("Solaris");
|
VersionCondition::addPredefinedGlobalIdent("Solaris");
|
||||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||||
break;
|
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:
|
default:
|
||||||
error("target '%s' is not yet supported", global.params.targetTriple.str().c_str());
|
error("target '%s' is not yet supported", global.params.targetTriple.str().c_str());
|
||||||
fatal();
|
fatal();
|
||||||
|
@ -707,6 +752,12 @@ int main(int argc, char** argv)
|
||||||
// unittests?
|
// unittests?
|
||||||
if (global.params.useUnitTests)
|
if (global.params.useUnitTests)
|
||||||
VersionCondition::addPredefinedGlobalIdent("unittest");
|
VersionCondition::addPredefinedGlobalIdent("unittest");
|
||||||
|
|
||||||
|
if (global.params.useAssert)
|
||||||
|
VersionCondition::addPredefinedGlobalIdent("assert");
|
||||||
|
|
||||||
|
if (!global.params.useArrayBounds)
|
||||||
|
VersionCondition::addPredefinedGlobalIdent("D_NoBoundsChecks");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue