Add predefined version CRuntime_Musl

This commit is contained in:
Martin 2017-10-20 19:46:54 +02:00
parent 5ccb46baf2
commit 5d68cd1627
2 changed files with 22 additions and 18 deletions

View file

@ -426,10 +426,12 @@ void ArgsBuilder::addUserSwitches() {
void ArgsBuilder::addDefaultLibs() { void ArgsBuilder::addDefaultLibs() {
bool addSoname = false; bool addSoname = false;
switch (global.params.targetTriple->getOS()) { const auto &triple = *global.params.targetTriple;
switch (triple.getOS()) {
case llvm::Triple::Linux: case llvm::Triple::Linux:
addSoname = true; addSoname = true;
if (global.params.targetTriple->getEnvironment() == llvm::Triple::Android) { if (triple.getEnvironment() == llvm::Triple::Android) {
args.push_back("-ldl"); args.push_back("-ldl");
args.push_back("-lm"); args.push_back("-lm");
break; break;
@ -462,7 +464,7 @@ void ArgsBuilder::addDefaultLibs() {
break; break;
} }
if (global.params.targetTriple->isWindowsGNUEnvironment()) { if (triple.isWindowsGNUEnvironment()) {
// This is really more of a kludge, as linking in the Winsock functions // This is really more of a kludge, as linking in the Winsock functions
// should be handled by the pragma(lib, ...) in std.socket, but it // should be handled by the pragma(lib, ...) in std.socket, but it
// makes LDC behave as expected for now. // makes LDC behave as expected for now.

View file

@ -667,7 +667,8 @@ void registerPredefinedFloatABI(const char *soft, const char *hard,
/// Registers the predefined versions specific to the current target triple /// Registers the predefined versions specific to the current target triple
/// and other target specific options with VersionCondition. /// and other target specific options with VersionCondition.
void registerPredefinedTargetVersions() { void registerPredefinedTargetVersions() {
const auto arch = global.params.targetTriple->getArch(); const auto &triple = *global.params.targetTriple;
const auto arch = triple.getArch();
switch (arch) { switch (arch) {
case llvm::Triple::x86: case llvm::Triple::x86:
@ -692,11 +693,9 @@ void registerPredefinedTargetVersions() {
case llvm::Triple::ppc64le: case llvm::Triple::ppc64le:
VersionCondition::addPredefinedGlobalIdent("PPC64"); VersionCondition::addPredefinedGlobalIdent("PPC64");
registerPredefinedFloatABI("PPC_SoftFloat", "PPC_HardFloat"); registerPredefinedFloatABI("PPC_SoftFloat", "PPC_HardFloat");
if (global.params.targetTriple->getOS() == llvm::Triple::Linux) { if (triple.getOS() == llvm::Triple::Linux) {
VersionCondition::addPredefinedGlobalIdent( VersionCondition::addPredefinedGlobalIdent(
global.params.targetTriple->getArch() == llvm::Triple::ppc64 triple.getArch() == llvm::Triple::ppc64 ? "ELFv1" : "ELFv2");
? "ELFv1"
: "ELFv2");
} }
break; break;
case llvm::Triple::arm: case llvm::Triple::arm:
@ -768,7 +767,7 @@ void registerPredefinedTargetVersions() {
break; break;
default: default:
error(Loc(), "invalid cpu architecture specified: %s", error(Loc(), "invalid cpu architecture specified: %s",
global.params.targetTriple->getArchName().str().c_str()); triple.getArchName().str().c_str());
fatal(); fatal();
} }
@ -782,7 +781,7 @@ void registerPredefinedTargetVersions() {
// Set versions for arch bitwidth // Set versions for arch bitwidth
if (global.params.isLP64) { if (global.params.isLP64) {
VersionCondition::addPredefinedGlobalIdent("D_LP64"); VersionCondition::addPredefinedGlobalIdent("D_LP64");
} else if (global.params.targetTriple->isArch16Bit()) { } else if (triple.isArch16Bit()) {
VersionCondition::addPredefinedGlobalIdent("D_P16"); VersionCondition::addPredefinedGlobalIdent("D_P16");
} }
@ -802,20 +801,20 @@ void registerPredefinedTargetVersions() {
// parse the OS out of the target triple // parse the OS out of the target triple
// see http://gcc.gnu.org/install/specific.html for details // see http://gcc.gnu.org/install/specific.html for details
// also llvm's different SubTargets have useful information // also llvm's different SubTargets have useful information
switch (global.params.targetTriple->getOS()) { switch (triple.getOS()) {
case llvm::Triple::Win32: case llvm::Triple::Win32:
VersionCondition::addPredefinedGlobalIdent("Windows"); VersionCondition::addPredefinedGlobalIdent("Windows");
VersionCondition::addPredefinedGlobalIdent(global.params.is64bit ? "Win64" VersionCondition::addPredefinedGlobalIdent(global.params.is64bit ? "Win64"
: "Win32"); : "Win32");
if (global.params.targetTriple->isWindowsMSVCEnvironment()) { if (triple.isWindowsMSVCEnvironment()) {
VersionCondition::addPredefinedGlobalIdent("CRuntime_Microsoft"); VersionCondition::addPredefinedGlobalIdent("CRuntime_Microsoft");
} }
if (global.params.targetTriple->isWindowsGNUEnvironment()) { if (triple.isWindowsGNUEnvironment()) {
VersionCondition::addPredefinedGlobalIdent( VersionCondition::addPredefinedGlobalIdent(
"mingw32"); // For backwards compatibility. "mingw32"); // For backwards compatibility.
VersionCondition::addPredefinedGlobalIdent("MinGW"); VersionCondition::addPredefinedGlobalIdent("MinGW");
} }
if (global.params.targetTriple->isWindowsCygwinEnvironment()) { if (triple.isWindowsCygwinEnvironment()) {
error(Loc(), "Cygwin is not yet supported"); error(Loc(), "Cygwin is not yet supported");
fatal(); fatal();
VersionCondition::addPredefinedGlobalIdent("Cygwin"); VersionCondition::addPredefinedGlobalIdent("Cygwin");
@ -824,9 +823,13 @@ void registerPredefinedTargetVersions() {
case llvm::Triple::Linux: case llvm::Triple::Linux:
VersionCondition::addPredefinedGlobalIdent("linux"); VersionCondition::addPredefinedGlobalIdent("linux");
VersionCondition::addPredefinedGlobalIdent("Posix"); VersionCondition::addPredefinedGlobalIdent("Posix");
if (global.params.targetTriple->getEnvironment() == llvm::Triple::Android) { if (triple.getEnvironment() == llvm::Triple::Android) {
VersionCondition::addPredefinedGlobalIdent("Android"); VersionCondition::addPredefinedGlobalIdent("Android");
VersionCondition::addPredefinedGlobalIdent("CRuntime_Bionic"); VersionCondition::addPredefinedGlobalIdent("CRuntime_Bionic");
#if LDC_LLVM_VER >= 309
} else if (triple.isMusl()) {
VersionCondition::addPredefinedGlobalIdent("CRuntime_Musl");
#endif
} else { } else {
VersionCondition::addPredefinedGlobalIdent("CRuntime_Glibc"); VersionCondition::addPredefinedGlobalIdent("CRuntime_Glibc");
} }
@ -871,13 +874,12 @@ void registerPredefinedTargetVersions() {
break; break;
// fallthrough // fallthrough
default: default:
switch (global.params.targetTriple->getEnvironment()) { switch (triple.getEnvironment()) {
case llvm::Triple::Android: case llvm::Triple::Android:
VersionCondition::addPredefinedGlobalIdent("Android"); VersionCondition::addPredefinedGlobalIdent("Android");
break; break;
default: default:
error(Loc(), "target '%s' is not yet supported", error(Loc(), "target '%s' is not yet supported", triple.str().c_str());
global.params.targetTriple->str().c_str());
fatal(); fatal();
} }
} }