From 43ac2978291bf1471e2c916a88c7f1c1e170dc19 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 5 Apr 2011 22:04:27 +0000 Subject: [PATCH] Add ToolChain support to get Clang to recognize Ubuntu/ppc and Gentoo/ppc64. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128944 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains.cpp | 41 +++++++++++++++++++++++++++++---------- lib/Driver/Tools.cpp | 8 ++++++++ 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 6127d45fa3..f7bace0ed3 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -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; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 5c986486d6..e7228229ea 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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"); } -- 2.40.0