[cfe-commits] r67529 - in /cfe/trunk/lib/Driver: Driver.cpp HostInfo.cpp ToolChains.cpp ToolChains.h

Daniel Dunbar daniel at zuster.org
Mon Mar 23 09:15:51 PDT 2009


Author: ddunbar
Date: Mon Mar 23 11:15:50 2009
New Revision: 67529

URL: http://llvm.org/viewvc/llvm-project?rev=67529&view=rev
Log:
Driver: Setup file and program search paths in tool chains.

Modified:
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/HostInfo.cpp
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/ToolChains.h

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=67529&r1=67528&r2=67529&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Mar 23 11:15:50 2009
@@ -920,15 +920,8 @@
       return P;
   }
 
-  // As a last resort, always search in our directory before pulling
-  // from the path.
-  llvm::sys::Path P(Dir);
-  P.appendComponent(Name);
-  if (P.exists())
-    return P;
-
-  // Search path to increase accuracy of logging output.
-  P = llvm::sys::Program::FindProgramByName(Name);
+  // If all else failed, search the path.
+  llvm::sys::Path P(llvm::sys::Program::FindProgramByName(Name));
   if (!P.empty())
     return P;
 

Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=67529&r1=67528&r2=67529&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Mon Mar 23 11:15:50 2009
@@ -159,7 +159,9 @@
     if (strcmp(ArchName, "i386") == 0 || strcmp(ArchName, "x86_64") == 0)
       TC = new toolchains::Darwin_X86(*this, ArchName, 
                                       getPlatformName().c_str(), 
-                                      getOSName().c_str());
+                                      getOSName().c_str(),
+                                      DarwinVersion,
+                                      GCCVersion);
     else
       TC = new toolchains::Darwin_GCC(*this, ArchName, 
                                       getPlatformName().c_str(), 

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=67529&r1=67528&r2=67529&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Mar 23 11:15:50 2009
@@ -9,11 +9,74 @@
 
 #include "ToolChains.h"
 
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/HostInfo.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/System/Path.h"
+
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
 
 /// Darwin_X86 - Darwin tool chain for i386 and x86_64.
 
+Darwin_X86::Darwin_X86(const HostInfo &Host, const char *Arch, 
+                       const char *Platform, const char *OS, 
+                       const unsigned (&_DarwinVersion)[3],
+                       const unsigned (&_GCCVersion)[3])
+  : ToolChain(Host, Arch, Platform, OS) 
+{
+  DarwinVersion[0] = _DarwinVersion[0];
+  DarwinVersion[1] = _DarwinVersion[1];
+  DarwinVersion[2] = _DarwinVersion[2];
+  GCCVersion[0] = _GCCVersion[0];
+  GCCVersion[1] = _GCCVersion[1];
+  GCCVersion[2] = _GCCVersion[2];
+
+  ToolChainDir = "i686-apple-darwin";
+  ToolChainDir += llvm::utostr(DarwinVersion[0]);
+  ToolChainDir += "/";
+  ToolChainDir += llvm::utostr(GCCVersion[0]);
+  ToolChainDir += '.';
+  ToolChainDir += llvm::utostr(GCCVersion[1]);
+  ToolChainDir += '.';
+  ToolChainDir += llvm::utostr(GCCVersion[2]);
+
+  std::string Path;
+  if (getArchName() == "x86_64") {
+    Path = getHost().getDriver().Dir;
+    Path += "/../lib/gcc/";
+    Path += getToolChainDir();
+    Path += "/x86_64";
+    getFilePaths().push_back(Path);
+
+    Path = "/usr/lib/gcc/";
+    Path += getToolChainDir();
+    Path += "/x86_64";
+    getFilePaths().push_back(Path);
+  }
+  
+  Path = getHost().getDriver().Dir;
+  Path += "/../lib/gcc/";
+  Path += getToolChainDir();
+  getFilePaths().push_back(Path);
+
+  Path = "/usr/lib/gcc/";
+  Path += getToolChainDir();
+  getFilePaths().push_back(Path);
+
+  Path = getHost().getDriver().Dir;
+  Path += "/../libexec/gcc/";
+  Path += getToolChainDir();
+  getProgramPaths().push_back(Path);
+
+  Path = "/usr/libexec/gcc/";
+  Path += getToolChainDir();
+  getProgramPaths().push_back(Path);
+
+  getProgramPaths().push_back(getHost().getDriver().Dir);
+}
+
 Darwin_X86::~Darwin_X86() {
   // Free tool implementations.
   for (llvm::DenseMap<unsigned, Tool*>::iterator
@@ -84,6 +147,13 @@
 /// all subcommands; this relies on gcc translating the majority of
 /// command line options.
 
+Generic_GCC::Generic_GCC(const HostInfo &Host, const char *Arch, 
+                         const char *Platform, const char *OS)
+  : ToolChain(Host, Arch, Platform, OS) 
+{
+  getProgramPaths().push_back(getHost().getDriver().Dir);  
+}
+
 Generic_GCC::~Generic_GCC() {
   // Free tool implementations.
   for (llvm::DenseMap<unsigned, Tool*>::iterator

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=67529&r1=67528&r2=67529&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Mon Mar 23 11:15:50 2009
@@ -30,7 +30,7 @@
 
 public:
   Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform, 
-              const char *OS) : ToolChain(Host, Arch, Platform, OS) {}
+              const char *OS);
   ~Generic_GCC();
 
   virtual ArgList *TranslateArgs(ArgList &Args) const { return &Args; }
@@ -47,9 +47,19 @@
 class VISIBILITY_HIDDEN Darwin_X86 : public ToolChain {
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
+  /// Darwin version of tool chain.
+  unsigned DarwinVersion[3];
+
+  /// GCC version to use.
+  unsigned GCCVersion[3];
+
+  /// The directory suffix for this tool chain.
+  std::string ToolChainDir;
+
 public:
   Darwin_X86(const HostInfo &Host, const char *Arch, const char *Platform, 
-             const char *OS) : ToolChain(Host, Arch, Platform, OS) {}
+             const char *OS, const unsigned (&DarwinVersion)[3],
+             const unsigned (&GCCVersion)[3]);
   ~Darwin_X86();
 
   virtual ArgList *TranslateArgs(ArgList &Args) const;
@@ -60,6 +70,9 @@
   virtual bool IsUnwindTablesDefault() const;
   virtual const char *GetDefaultRelocationModel() const;
   virtual const char *GetForcedPicModel() const;
+
+private:
+  const std::string &getToolChainDir() const { return ToolChainDir; }
 };
 
   /// Darwin_GCC - Generic Darwin tool chain using gcc.





More information about the cfe-commits mailing list