[cfe-commits] r128944 - in /cfe/trunk/lib/Driver: ToolChains.cpp Tools.cpp

Ted Kremenek kremenek at apple.com
Tue Apr 5 15:04:27 PDT 2011


Author: kremenek
Date: Tue Apr  5 17:04:27 2011
New Revision: 128944

URL: http://llvm.org/viewvc/llvm-project?rev=128944&view=rev
Log:
Add ToolChain support to get Clang to recognize Ubuntu/ppc and Gentoo/ppc64.

Modified:
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=128944&r1=128943&r2=128944&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Apr  5 17:04:27 2011
@@ -1148,6 +1148,7 @@
   UbuntuKarmic,
   UbuntuLucid,
   UbuntuMaverick,
+  UbuntuNatty,
   UnknownDistro
 };
 
@@ -1166,7 +1167,8 @@
 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 @@
 
     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 @@
     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 @@
     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 @@
     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 @@
       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;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=128944&r1=128943&r2=128944&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Apr  5 17:04:27 2011
@@ -3657,6 +3657,10 @@
   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 @@
     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");
   }





More information about the cfe-commits mailing list