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

Eli Friedman eli.friedman at gmail.com
Tue May 26 00:52:27 PDT 2009


Author: efriedma
Date: Tue May 26 02:52:18 2009
New Revision: 72412

URL: http://llvm.org/viewvc/llvm-project?rev=72412&view=rev
Log:
Fix for PR4140: Add the start of a Linux toolchain (basically, just 
barely enough to get the given usage of -print-file-name working).


Modified:
    cfe/trunk/include/clang/Driver/HostInfo.h
    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/include/clang/Driver/HostInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/HostInfo.h?rev=72412&r1=72411&r2=72412&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/HostInfo.h (original)
+++ cfe/trunk/include/clang/Driver/HostInfo.h Tue May 26 02:52:18 2009
@@ -73,6 +73,8 @@
                                       const llvm::Triple& Triple);
 const HostInfo *createDragonFlyHostInfo(const Driver &D, 
                                         const llvm::Triple& Triple);
+const HostInfo *createLinuxHostInfo(const Driver &D, 
+                                    const llvm::Triple& Triple);
 const HostInfo *createUnknownHostInfo(const Driver &D, 
                                       const llvm::Triple& Triple);
 

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

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue May 26 02:52:18 2009
@@ -1161,6 +1161,8 @@
     return createDragonFlyHostInfo(*this, Triple);
   case llvm::Triple::FreeBSD:
     return createFreeBSDHostInfo(*this, Triple);
+  case llvm::Triple::Linux:
+    return createLinuxHostInfo(*this, Triple);
   default:
     return createUnknownHostInfo(*this, Triple);
   }

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

==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Tue May 26 02:52:18 2009
@@ -322,6 +322,58 @@
   return TC;
 }
 
+// Linux Host Info
+
+/// LinuxHostInfo -  Linux host information implementation.
+class LinuxHostInfo : public HostInfo {
+  /// Cache of tool chains we have created.
+  mutable llvm::StringMap<ToolChain*> ToolChains;
+
+public:
+  LinuxHostInfo(const Driver &D, const llvm::Triple& Triple)
+    : HostInfo(D, Triple) {}
+  ~LinuxHostInfo();
+
+  virtual bool useDriverDriver() const;
+
+  virtual types::ID lookupTypeForExtension(const char *Ext) const {
+    return types::lookupTypeForExtension(Ext);
+  }
+
+  virtual ToolChain *getToolChain(const ArgList &Args, 
+                                  const char *ArchName) const;
+};
+
+LinuxHostInfo::~LinuxHostInfo() {
+  for (llvm::StringMap<ToolChain*>::iterator
+         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
+    delete it->second;
+}
+
+bool LinuxHostInfo::useDriverDriver() const { 
+  return false;
+}
+
+ToolChain *LinuxHostInfo::getToolChain(const ArgList &Args, 
+                                       const char *ArchName) const {
+
+  assert(!ArchName && 
+         "Unexpected arch name on platform without driver driver support.");
+
+  ArchName = getArchName().c_str();
+  
+  ToolChain *&TC = ToolChains[ArchName];
+
+  if (!TC) {
+    llvm::Triple TCTriple(getTriple());
+    TCTriple.setArchName(getArchName());
+
+    TC = new toolchains::Linux(*this, TCTriple);
+  }
+
+  return TC;
+}
+
 }
 
 const HostInfo *
@@ -343,6 +395,12 @@
 }
 
 const HostInfo *
+clang::driver::createLinuxHostInfo(const Driver &D,
+                                   const llvm::Triple& Triple) {
+  return new LinuxHostInfo(D, Triple);
+}
+
+const HostInfo *
 clang::driver::createUnknownHostInfo(const Driver &D,
                                      const llvm::Triple& Triple) {
   return new UnknownHostInfo(D, Triple);

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

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue May 26 02:52:18 2009
@@ -419,6 +419,22 @@
   return *T;
 }
 
+/// Linux toolchain (very bare-bones at the moment).
+
+Linux::Linux(const HostInfo &Host, const llvm::Triple& Triple)
+  : Generic_GCC(Host, Triple) {
+  getFilePaths().push_back(getHost().getDriver().Dir + "/../lib/clang/1.0/");
+  getFilePaths().push_back("/lib/");
+  getFilePaths().push_back("/usr/lib/");
+  // FIXME: Figure out some way to get gcc's libdir
+  // (e.g. /usr/lib/gcc/i486-linux-gnu/4.3/ for Ubuntu 32-bit); we need
+  // crtbegin.o/crtend.o/etc., and want static versions of various
+  // libraries. If we had our own crtbegin.o/crtend.o/etc, we could probably
+  // get away with using shared versions in /usr/lib, though.
+  // We could fall back to the approach we used for includes (a massive
+  // list), but that's messy at best.
+}
+
 /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
 
 DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple)

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

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Tue May 26 02:52:18 2009
@@ -121,6 +121,12 @@
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
 };
 
+class VISIBILITY_HIDDEN Linux : public Generic_GCC {
+public:
+  Linux(const HostInfo &Host, const llvm::Triple& Triple);
+};
+
+
 } // end namespace toolchains
 } // end namespace driver
 } // end namespace clang





More information about the cfe-commits mailing list