fixup abi for uclibc (#2606)

This commit is contained in:
Radu Racariu 2018-03-24 17:19:23 +02:00 committed by Martin Kinkelin
parent d9517374f0
commit 42ef1dd676

View file

@ -165,6 +165,9 @@ void printVersionStdout() {
namespace {
// True when target triple has an uClibc environment
bool isUClibc = false;
// Helper function to handle -d-debug=* and -d-version=*
void processVersions(std::vector<std::string> &list, const char *type,
unsigned &globalLevel, Strings *&globalIDs) {
@ -642,6 +645,19 @@ static void registerMipsABI() {
}
}
// Check if triple environment name starts with "uclibc" and change it to "gnu"
void fixupUClibcEnv()
{
llvm::Triple triple(mTargetTriple);
if (triple.getEnvironmentName().find("uclibc") != 0)
return;
std::string envName = triple.getEnvironmentName();
envName.replace(0, 6, "gnu");
triple.setEnvironmentName(envName);
mTargetTriple = triple.normalize();
isUClibc = true;
}
/// Register the float ABI.
/// Also defines D_HardFloat or D_SoftFloat depending if FPU should be used
void registerPredefinedFloatABI(const char *soft, const char *hard,
@ -829,7 +845,7 @@ void registerPredefinedTargetVersions() {
VersionCondition::addPredefinedGlobalIdent("CRuntime_Bionic");
} else if (isMusl()) {
VersionCondition::addPredefinedGlobalIdent("CRuntime_Musl");
} else if (triple.getEnvironmentName() == "uclibc") {
} else if (isUClibc) {
VersionCondition::addPredefinedGlobalIdent("CRuntime_UClibc");
} else {
VersionCondition::addPredefinedGlobalIdent("CRuntime_Glibc");
@ -1016,6 +1032,9 @@ int cppmain(int argc, char **argv) {
relocModel = llvm::Reloc::PIC_;
}
// check and fix environment for uClibc
fixupUClibcEnv();
gTargetMachine = createTargetMachine(
mTargetTriple, arch, opts::getCPUStr(), opts::getFeaturesStr(), bitness,
floatABI, relocModel, opts::getCodeModel(), codeGenOptLevel(),