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

Chandler Carruth chandlerc at gmail.com
Wed Jan 25 03:18:20 PST 2012


Author: chandlerc
Date: Wed Jan 25 05:18:20 2012
New Revision: 148952

URL: http://llvm.org/viewvc/llvm-project?rev=148952&view=rev
Log:
Remove the 'ToolTriple' concept from the NetBSD toolchain along with my
gross hack to provide it from my previous patch removing HostInfo. This
was enshrining (and hiding from my searches) the concept of storing and
diff-ing the host and target triples. We don't have the host triple
reliably available, so we need to merely inspect the target system. I've
changed the logic in selecting library search paths for NetBSD to match
what I provided for FreeBSD -- we include both search paths, but put the
32-bit-on-64-bit-host path first so it trumps.

NetBSD maintainers, you may want to tweak this, or feel free to ask me
to tweak it. I've left a FIXME here about the challeng I see in fixing
this properly.

Modified:
    cfe/trunk/lib/Driver/Driver.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=148952&r1=148951&r2=148952&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Jan 25 05:18:20 2012
@@ -1654,7 +1654,7 @@
       TC = new toolchains::OpenBSD(*this, Target);
       break;
     case llvm::Triple::NetBSD:
-      TC = new toolchains::NetBSD(*this, Target, Target);
+      TC = new toolchains::NetBSD(*this, Target);
       break;
     case llvm::Triple::FreeBSD:
       TC = new toolchains::FreeBSD(*this, Target);

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=148952&r1=148951&r2=148952&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Jan 25 05:18:20 2012
@@ -1674,21 +1674,20 @@
 
 /// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly.
 
-NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple,
-               const llvm::Triple& ToolTriple)
-  : Generic_ELF(D, Triple), ToolTriple(ToolTriple) {
-
-  // Determine if we are compiling 32-bit code on an x86_64 platform.
-  bool Lib32 = false;
-  if (ToolTriple.getArch() == llvm::Triple::x86_64 &&
-      Triple.getArch() == llvm::Triple::x86)
-    Lib32 = true;
+NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple)
+  : Generic_ELF(D, Triple) {
 
   if (getDriver().UseStdLib) {
-    if (Lib32)
+    // When targeting a 32-bit platform, try the special directory used on
+    // 64-bit hosts, and only fall back to the main library directory if that
+    // doesn't work.
+    // FIXME: It'd be nicer to test if this directory exists, but I'm not sure
+    // what all logic is needed to emulate the '=' prefix here.
+    if (Triple.getArch() == llvm::Triple::x86 ||
+        Triple.getArch() == llvm::Triple::ppc)
       getFilePaths().push_back("=/usr/lib/i386");
-    else
-      getFilePaths().push_back("=/usr/lib");
+
+    getFilePaths().push_back("=/usr/lib");
   }
 }
 
@@ -1711,10 +1710,10 @@
       if (UseIntegratedAs)
         T = new tools::ClangAs(*this);
       else
-        T = new tools::netbsd::Assemble(*this, ToolTriple);
+        T = new tools::netbsd::Assemble(*this, getTriple());
       break;
     case Action::LinkJobClass:
-      T = new tools::netbsd::Link(*this, ToolTriple);
+      T = new tools::netbsd::Link(*this, getTriple());
       break;
     default:
       T = &Generic_GCC::SelectTool(C, JA, Inputs);

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=148952&r1=148951&r2=148952&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Wed Jan 25 05:18:20 2012
@@ -469,11 +469,8 @@
 };
 
 class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
-  const llvm::Triple ToolTriple;
-
 public:
-  NetBSD(const Driver &D, const llvm::Triple& Triple,
-         const llvm::Triple& ToolTriple);
+  NetBSD(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;





More information about the cfe-commits mailing list