mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 01:07:04 +08:00
Add ToolChain support to get Clang to recognize Ubuntu/ppc and Gentoo/ppc64.
llvm-svn: 128944
This commit is contained in:
@@ -1148,6 +1148,7 @@ enum LinuxDistro {
|
||||
UbuntuKarmic,
|
||||
UbuntuLucid,
|
||||
UbuntuMaverick,
|
||||
UbuntuNatty,
|
||||
UnknownDistro
|
||||
};
|
||||
|
||||
@@ -1166,7 +1167,8 @@ static bool IsDebian(enum LinuxDistro Distro) {
|
||||
static bool IsUbuntu(enum LinuxDistro Distro) {
|
||||
return Distro == UbuntuHardy || Distro == UbuntuIntrepid ||
|
||||
Distro == UbuntuLucid || Distro == UbuntuMaverick ||
|
||||
Distro == UbuntuJaunty || Distro == UbuntuKarmic;
|
||||
Distro == UbuntuJaunty || Distro == UbuntuKarmic ||
|
||||
Distro == UbuntuNatty;
|
||||
}
|
||||
|
||||
static bool IsDebianBased(enum LinuxDistro Distro) {
|
||||
@@ -1182,7 +1184,9 @@ static bool HasMultilib(llvm::Triple::ArchType Arch, enum LinuxDistro Distro) {
|
||||
|
||||
return true;
|
||||
}
|
||||
if (Arch == llvm::Triple::x86 && IsDebianBased(Distro))
|
||||
if (Arch == llvm::Triple::ppc64)
|
||||
return true;
|
||||
if ((Arch == llvm::Triple::x86 || Arch == llvm::Triple::ppc) && IsDebianBased(Distro))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -1196,16 +1200,18 @@ static LinuxDistro DetectLinuxDistro(llvm::Triple::ArchType Arch) {
|
||||
for (unsigned int i = 0, s = Lines.size(); i < s; ++ i) {
|
||||
if (Lines[i] == "DISTRIB_CODENAME=hardy")
|
||||
return UbuntuHardy;
|
||||
if (Lines[i] == "DISTRIB_CODENAME=intrepid")
|
||||
return UbuntuIntrepid;
|
||||
if (Lines[i] == "DISTRIB_CODENAME=maverick")
|
||||
return UbuntuMaverick;
|
||||
else if (Lines[i] == "DISTRIB_CODENAME=lucid")
|
||||
return UbuntuLucid;
|
||||
else if (Lines[i] == "DISTRIB_CODENAME=intrepid")
|
||||
return UbuntuIntrepid;
|
||||
else if (Lines[i] == "DISTRIB_CODENAME=jaunty")
|
||||
return UbuntuJaunty;
|
||||
else if (Lines[i] == "DISTRIB_CODENAME=karmic")
|
||||
return UbuntuKarmic;
|
||||
else if (Lines[i] == "DISTRIB_CODENAME=lucid")
|
||||
return UbuntuLucid;
|
||||
else if (Lines[i] == "DISTRIB_CODENAME=maverick")
|
||||
return UbuntuMaverick;
|
||||
else if (Lines[i] == "DISTRIB_CODENAME=natty")
|
||||
return UbuntuNatty;
|
||||
}
|
||||
return UnknownDistro;
|
||||
}
|
||||
@@ -1255,7 +1261,7 @@ Linux::Linux(const HostInfo &Host, const llvm::Triple &Triple)
|
||||
Suffix32 = "/32";
|
||||
|
||||
std::string Suffix64 = "";
|
||||
if (Arch == llvm::Triple::x86)
|
||||
if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::ppc)
|
||||
Suffix64 = "/64";
|
||||
|
||||
std::string Lib32 = "lib";
|
||||
@@ -1309,6 +1315,16 @@ Linux::Linux(const HostInfo &Host, const llvm::Triple &Triple)
|
||||
else if (!llvm::sys::fs::exists("/usr/lib/gcc/i586-suse-linux", Exists) &&
|
||||
Exists)
|
||||
GccTriple = "i586-suse-linux";
|
||||
} else if (Arch == llvm::Triple::ppc) {
|
||||
if (!llvm::sys::fs::exists("/usr/lib/powerpc-linux-gnu", Exists) && Exists)
|
||||
GccTriple = "powerpc-linux-gnu";
|
||||
else if (!llvm::sys::fs::exists("/usr/lib/gcc/powerpc-unknown-linux-gnu", Exists) && Exists)
|
||||
GccTriple = "powerpc-unknown-linux-gnu";
|
||||
} else if (Arch == llvm::Triple::ppc64) {
|
||||
if (!llvm::sys::fs::exists("/usr/lib/gcc/powerpc64-unknown-linux-gnu", Exists) && Exists)
|
||||
GccTriple = "powerpc64-unknown-linux-gnu";
|
||||
else if (!llvm::sys::fs::exists("/usr/lib64/gcc/powerpc64-unknown-linux-gnu", Exists) && Exists)
|
||||
GccTriple = "powerpc64-unknown-linux-gnu";
|
||||
}
|
||||
|
||||
const char* GccVersions[] = {"4.5.2", "4.5.1", "4.5", "4.4.5", "4.4.4",
|
||||
@@ -1328,10 +1344,15 @@ Linux::Linux(const HostInfo &Host, const llvm::Triple &Triple)
|
||||
Base = t2;
|
||||
break;
|
||||
}
|
||||
std::string t3 = "/usr/lib/" + GccTriple + "/gcc/" + Suffix;
|
||||
if (!llvm::sys::fs::exists(t3 + "/crtbegin.o", Exists) && Exists) {
|
||||
Base = t3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
path_list &Paths = getFilePaths();
|
||||
bool Is32Bits = getArch() == llvm::Triple::x86;
|
||||
bool Is32Bits = (getArch() == llvm::Triple::x86 || getArch() == llvm::Triple::ppc);
|
||||
|
||||
std::string Suffix;
|
||||
std::string Lib;
|
||||
|
||||
@@ -3657,6 +3657,10 @@ void linuxtools::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
else if (ToolChain.getArch() == llvm::Triple::arm
|
||||
|| ToolChain.getArch() == llvm::Triple::thumb)
|
||||
CmdArgs.push_back("armelf_linux_eabi");
|
||||
else if (ToolChain.getArch() == llvm::Triple::ppc)
|
||||
CmdArgs.push_back("elf32ppclinux");
|
||||
else if (ToolChain.getArch() == llvm::Triple::ppc64)
|
||||
CmdArgs.push_back("elf64ppc");
|
||||
else
|
||||
CmdArgs.push_back("elf_x86_64");
|
||||
|
||||
@@ -3680,6 +3684,10 @@ void linuxtools::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
else if (ToolChain.getArch() == llvm::Triple::arm ||
|
||||
ToolChain.getArch() == llvm::Triple::thumb)
|
||||
CmdArgs.push_back("/lib/ld-linux.so.3");
|
||||
else if (ToolChain.getArch() == llvm::Triple::ppc)
|
||||
CmdArgs.push_back("/lib/ld.so");
|
||||
else if (ToolChain.getArch() == llvm::Triple::ppc64)
|
||||
CmdArgs.push_back("/lib64/ld64.so");
|
||||
else
|
||||
CmdArgs.push_back("/lib64/ld-linux-x86-64.so.2");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user