On Wed, Jan 25, 2012 at 02:46:59PM +0100, Dimitry Andric wrote:
> Ergo, we really need to figure out what the 'target' architecture is,
> and base the decision to use /usr/lib or /usr/lib32 on that.  Basically,
> always use /usr/lib, unless arch==i386.

Attached patch allows that and fixes a related regression for the
$triple-$tool handling. It's a bit longer due to the change in the
constructor interface.

Look for "=/usr/lib/i386" for NetBSD's handling of the equivalent.

Joerg
Index: include/clang/Driver/ToolChain.h
===================================================================
--- include/clang/Driver/ToolChain.h	(revision 148956)
+++ include/clang/Driver/ToolChain.h	(working copy)
@@ -45,6 +45,8 @@
 
 private:
   const Driver &D;
+  std::string UserTripleString;
+  const llvm::Triple ToolTriple;
   const llvm::Triple Triple;
 
   /// The list of toolchain specific path prefixes to search for
@@ -56,7 +58,8 @@
   path_list ProgramPaths;
 
 protected:
-  ToolChain(const Driver &D, const llvm::Triple &T);
+  ToolChain(const Driver &D, std::string UserTripleString,
+            const llvm::Triple &ToolTriple, const llvm::Triple &T);
 
   /// \name Utilities for implementing subclasses.
   ///@{
@@ -78,6 +81,7 @@
 
   const Driver &getDriver() const;
   const llvm::Triple &getTriple() const { return Triple; }
+  const llvm::Triple &getToolTriple() const { return ToolTriple; }
 
   llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
   StringRef getArchName() const { return Triple.getArchName(); }
@@ -88,6 +92,10 @@
     return Triple.getTriple();
   }
 
+  std::string getUserTripleString() const {
+    return UserTripleString;
+  }
+
   path_list &getFilePaths() { return FilePaths; }
   const path_list &getFilePaths() const { return FilePaths; }
 
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 148956)
+++ lib/Driver/Tools.cpp	(working copy)
@@ -4531,7 +4531,7 @@
 
   // When building 32-bit code on NetBSD/amd64, we have to explicitly
   // instruct as in the base system to assemble 32-bit code.
-  if (ToolTriple.getArch() == llvm::Triple::x86_64 &&
+  if (getToolChain().getToolTriple().getArch() == llvm::Triple::x86_64 &&
       getToolChain().getArch() == llvm::Triple::x86)
     CmdArgs.push_back("--32");
 
@@ -4585,7 +4585,7 @@
 
   // When building 32-bit code on NetBSD/amd64, we have to explicitly
   // instruct ld in the base system to link 32-bit code.
-  if (ToolTriple.getArch() == llvm::Triple::x86_64 &&
+  if (getToolChain().getToolTriple().getArch() == llvm::Triple::x86_64 &&
       getToolChain().getArch() == llvm::Triple::x86) {
     CmdArgs.push_back("-m");
     CmdArgs.push_back("elf_i386");
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp	(revision 148956)
+++ lib/Driver/ToolChains.cpp	(working copy)
@@ -45,9 +45,10 @@
 
 /// Darwin - Darwin tool chain for i386 and x86_64.
 
-Darwin::Darwin(const Driver &D, const llvm::Triple& Triple)
-  : ToolChain(D, Triple), TargetInitialized(false),
-    ARCRuntimeForSimulator(ARCSimulator_None),
+Darwin::Darwin(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : ToolChain(D, UserTripleString, ToolTriple, Triple),
+    TargetInitialized(false), ARCRuntimeForSimulator(ARCSimulator_None),
     LibCXXForSimulator(LibCXXSimulator_None)
 {
   // Compute the initial Darwin version based on the host.
@@ -250,8 +251,9 @@
 }
 
 
-DarwinClang::DarwinClang(const Driver &D, const llvm::Triple& Triple)
-  : Darwin(D, Triple)
+DarwinClang::DarwinClang(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : Darwin(D, UserTripleString, ToolTriple, Triple)
 {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
@@ -1390,8 +1392,10 @@
   }
 }
 
-Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple& Triple)
-  : ToolChain(D, Triple), GCCInstallation(getDriver(), Triple) {
+Generic_GCC::Generic_GCC(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : ToolChain(D, UserTripleString, ToolTriple, Triple),
+    GCCInstallation(getDriver(), Triple) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
     getProgramPaths().push_back(getDriver().Dir);
@@ -1461,8 +1465,9 @@
 }
 /// Hexagon Toolchain
 
-Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple& Triple)
-  : ToolChain(D, Triple) {
+Hexagon_TC::Hexagon_TC(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : ToolChain(D, UserTripleString, ToolTriple, Triple) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir.c_str())
     getProgramPaths().push_back(getDriver().Dir);
@@ -1531,8 +1536,9 @@
 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
 /// Currently does not support anything else but compilation.
 
-TCEToolChain::TCEToolChain(const Driver &D, const llvm::Triple& Triple)
-  : ToolChain(D, Triple) {
+TCEToolChain::TCEToolChain(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : ToolChain(D, UserTripleString, ToolTriple, Triple) {
   // Path mangling to find libexec
   std::string Path(getDriver().Dir);
 
@@ -1584,8 +1590,9 @@
 
 /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
 
-OpenBSD::OpenBSD(const Driver &D, const llvm::Triple& Triple)
-  : Generic_ELF(D, Triple) {
+OpenBSD::OpenBSD(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : Generic_ELF(D, UserTripleString, ToolTriple, Triple) {
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
 }
@@ -1624,8 +1631,9 @@
 
 /// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly.
 
-FreeBSD::FreeBSD(const Driver &D, const llvm::Triple& Triple)
-  : Generic_ELF(D, Triple) {
+FreeBSD::FreeBSD(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : Generic_ELF(D, UserTripleString, ToolTriple, Triple) {
 
   // When targeting 32-bit platforms, look for '/usr/lib32' first and fall back
   // to '/usr/lib' for the remaining cases.
@@ -1670,20 +1678,16 @@
 
 /// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly.
 
-NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple)
-  : Generic_ELF(D, Triple) {
+NetBSD::NetBSD(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : Generic_ELF(D, UserTripleString, ToolTriple, Triple) {
 
   if (getDriver().UseStdLib) {
-    // 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)
+    if (ToolTriple.getArch() == llvm::Triple::x86_64 &&
+        Triple.getArch() == llvm::Triple::x86)
       getFilePaths().push_back("=/usr/lib/i386");
-
-    getFilePaths().push_back("=/usr/lib");
+    else
+      getFilePaths().push_back("=/usr/lib");
   }
 }
 
@@ -1706,10 +1710,10 @@
       if (UseIntegratedAs)
         T = new tools::ClangAs(*this);
       else
-        T = new tools::netbsd::Assemble(*this, getTriple());
+        T = new tools::netbsd::Assemble(*this);
       break;
     case Action::LinkJobClass:
-      T = new tools::netbsd::Link(*this, getTriple());
+      T = new tools::netbsd::Link(*this);
       break;
     default:
       T = &Generic_GCC::SelectTool(C, JA, Inputs);
@@ -1721,8 +1725,9 @@
 
 /// Minix - Minix tool chain which can call as(1) and ld(1) directly.
 
-Minix::Minix(const Driver &D, const llvm::Triple& Triple)
-  : Generic_ELF(D, Triple) {
+Minix::Minix(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : Generic_ELF(D, UserTripleString, ToolTriple, Triple) {
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
 }
@@ -1752,8 +1757,9 @@
 
 /// AuroraUX - AuroraUX tool chain which can call as(1) and ld(1) directly.
 
-AuroraUX::AuroraUX(const Driver &D, const llvm::Triple& Triple)
-  : Generic_GCC(D, Triple) {
+AuroraUX::AuroraUX(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : Generic_GCC(D, UserTripleString, ToolTriple, Triple) {
 
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
@@ -1968,8 +1974,9 @@
   if (llvm::sys::fs::exists(Path)) Paths.push_back(Path.str());
 }
 
-Linux::Linux(const Driver &D, const llvm::Triple &Triple)
-  : Generic_ELF(D, Triple) {
+Linux::Linux(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : Generic_ELF(D, UserTripleString, ToolTriple, Triple) {
   llvm::Triple::ArchType Arch = Triple.getArch();
   const std::string &SysRoot = getDriver().SysRoot;
 
@@ -2277,8 +2284,9 @@
 
 /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
 
-DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple)
-  : Generic_ELF(D, Triple) {
+DragonFly::DragonFly(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : Generic_ELF(D, UserTripleString, ToolTriple, Triple) {
 
   // Path mangling to find libexec
   getProgramPaths().push_back(getDriver().getInstalledDir());
Index: lib/Driver/Tools.h
===================================================================
--- lib/Driver/Tools.h	(revision 148956)
+++ lib/Driver/Tools.h	(working copy)
@@ -396,12 +396,9 @@
   /// netbsd -- Directly call GNU Binutils assembler and linker
 namespace netbsd {
   class LLVM_LIBRARY_VISIBILITY Assemble : public Tool  {
-  private:
-    const llvm::Triple ToolTriple;
-
   public:
-    Assemble(const ToolChain &TC, const llvm::Triple &ToolTriple)
-      : Tool("netbsd::Assemble", "assembler", TC), ToolTriple(ToolTriple) {}
+    Assemble(const ToolChain &TC)
+      : Tool("netbsd::Assemble", "assembler", TC) {}
 
     virtual bool hasIntegratedCPP() const { return false; }
 
@@ -412,12 +409,9 @@
                               const char *LinkingOutput) const;
   };
   class LLVM_LIBRARY_VISIBILITY Link : public Tool  {
-  private:
-    const llvm::Triple ToolTriple;
-
   public:
-    Link(const ToolChain &TC, const llvm::Triple &ToolTriple)
-      : Tool("netbsd::Link", "linker", TC), ToolTriple(ToolTriple) {}
+    Link(const ToolChain &TC)
+      : Tool("netbsd::Link", "linker", TC) {}
 
     virtual bool hasIntegratedCPP() const { return false; }
 
Index: lib/Driver/ToolChains.h
===================================================================
--- lib/Driver/ToolChains.h	(revision 148956)
+++ lib/Driver/ToolChains.h	(working copy)
@@ -119,7 +119,8 @@
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
 public:
-  Generic_GCC(const Driver &D, const llvm::Triple& Triple);
+  Generic_GCC(const Driver &D, std::string UserTripleString,
+              const llvm::Triple &ToolTriple, const llvm::Triple &T);
   ~Generic_GCC();
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -150,7 +151,8 @@
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
 public:
-  Hexagon_TC(const Driver &D, const llvm::Triple& Triple);
+  Hexagon_TC(const Driver &D, std::string UserTripleString,
+             const llvm::Triple &ToolTriple, const llvm::Triple &T);
   ~Hexagon_TC();
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -212,7 +214,8 @@
   void AddDeploymentTarget(DerivedArgList &Args) const;
 
 public:
-  Darwin(const Driver &D, const llvm::Triple& Triple);
+  Darwin(const Driver &D, std::string UserTripleString,
+         const llvm::Triple &ToolTriple, const llvm::Triple &T);
   ~Darwin();
 
   std::string ComputeEffectiveClangTriple(const ArgList &Args,
@@ -395,7 +398,8 @@
   void AddGCCLibexecPath(unsigned darwinVersion);
 
 public:
-  DarwinClang(const Driver &D, const llvm::Triple& Triple);
+  DarwinClang(const Driver &D, std::string UserTripleString,
+              const llvm::Triple &ToolTriple, const llvm::Triple &T);
 
   /// @name Darwin ToolChain Implementation
   /// {
@@ -422,8 +426,9 @@
 /// Darwin_Generic_GCC - Generic Darwin tool chain using gcc.
 class LLVM_LIBRARY_VISIBILITY Darwin_Generic_GCC : public Generic_GCC {
 public:
-  Darwin_Generic_GCC(const Driver &D, const llvm::Triple& Triple)
-    : Generic_GCC(D, Triple) {}
+  Darwin_Generic_GCC(const Driver &D, std::string UserTripleString,
+              const llvm::Triple &ToolTriple, const llvm::Triple &T)
+    : Generic_GCC(D, UserTripleString, ToolTriple, T) {}
 
   std::string ComputeEffectiveClangTriple(const ArgList &Args,
                                           types::ID InputType) const;
@@ -434,8 +439,9 @@
 class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC {
   virtual void anchor();
 public:
-  Generic_ELF(const Driver &D, const llvm::Triple& Triple)
-    : Generic_GCC(D, Triple) {}
+  Generic_ELF(const Driver &D, std::string UserTripleString,
+              const llvm::Triple &ToolTriple, const llvm::Triple &T)
+    : Generic_GCC(D, UserTripleString, ToolTriple, T) {}
 
   virtual bool IsIntegratedAssemblerDefault() const {
     // Default integrated assembler to on for x86.
@@ -446,7 +452,8 @@
 
 class LLVM_LIBRARY_VISIBILITY AuroraUX : public Generic_GCC {
 public:
-  AuroraUX(const Driver &D, const llvm::Triple& Triple);
+  AuroraUX(const Driver &D, std::string UserTripleString,
+           const llvm::Triple &ToolTriple, const llvm::Triple &T);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -454,7 +461,8 @@
 
 class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
 public:
-  OpenBSD(const Driver &D, const llvm::Triple& Triple);
+  OpenBSD(const Driver &D, std::string UserTripleString,
+          const llvm::Triple &ToolTriple, const llvm::Triple &T);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -462,7 +470,8 @@
 
 class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
 public:
-  FreeBSD(const Driver &D, const llvm::Triple& Triple);
+  FreeBSD(const Driver &D, std::string UserTripleString,
+          const llvm::Triple &ToolTriple, const llvm::Triple &T);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -470,7 +479,8 @@
 
 class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
 public:
-  NetBSD(const Driver &D, const llvm::Triple& Triple);
+  NetBSD(const Driver &D, std::string UserTripleString,
+          const llvm::Triple &ToolTriple, const llvm::Triple &T);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -478,7 +488,8 @@
 
 class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF {
 public:
-  Minix(const Driver &D, const llvm::Triple& Triple);
+  Minix(const Driver &D, std::string UserTripleString,
+        const llvm::Triple &ToolTriple, const llvm::Triple &T);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -486,7 +497,8 @@
 
 class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
 public:
-  DragonFly(const Driver &D, const llvm::Triple& Triple);
+  DragonFly(const Driver &D, std::string UserTripleString,
+            const llvm::Triple &ToolTriple, const llvm::Triple &T);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -494,7 +506,8 @@
 
 class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
 public:
-  Linux(const Driver &D, const llvm::Triple& Triple);
+  Linux(const Driver &D, std::string UserTripleString,
+        const llvm::Triple &ToolTriple, const llvm::Triple &T);
 
   virtual bool HasNativeLLVMSupport() const;
 
@@ -520,7 +533,8 @@
 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
 class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
 public:
-  TCEToolChain(const Driver &D, const llvm::Triple& Triple);
+  TCEToolChain(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &T);
   ~TCEToolChain();
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -539,7 +553,8 @@
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
 public:
-  Windows(const Driver &D, const llvm::Triple& Triple);
+  Windows(const Driver &D, std::string UserTripleString,
+          const llvm::Triple &ToolTriple, const llvm::Triple &T);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
Index: lib/Driver/ToolChain.cpp
===================================================================
--- lib/Driver/ToolChain.cpp	(revision 148956)
+++ lib/Driver/ToolChain.cpp	(working copy)
@@ -20,8 +20,10 @@
 using namespace clang::driver;
 using namespace clang;
 
-ToolChain::ToolChain(const Driver &D, const llvm::Triple &T)
-  : D(D), Triple(T) {
+ToolChain::ToolChain(const Driver &D, std::string UserTripleString,
+        const llvm::Triple &ToolTriple, const llvm::Triple &T)
+  : D(D), UserTripleString(UserTripleString), ToolTriple(ToolTriple),
+    Triple(T) {
 }
 
 ToolChain::~ToolChain() {
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp	(revision 148956)
+++ lib/Driver/Driver.cpp	(working copy)
@@ -1507,7 +1507,7 @@
 
 std::string Driver::GetProgramPath(const char *Name, const ToolChain &TC,
                                    bool WantFile) const {
-  std::string TargetSpecificExecutable(DefaultTargetTriple + "-" + Name);
+  std::string TargetSpecificExecutable(TC.getUserTripleString() + "-" + Name);
   // Respect a limited subset of the '-Bprefix' functionality in GCC by
   // attempting to use this prefix when lokup up program paths.
   for (Driver::prefix_list::const_iterator it = PrefixDirs.begin(),
@@ -1570,25 +1570,21 @@
   return P.str();
 }
 
-/// \brief Compute target triple from args.
+/// \brief Compute target triple for code generation from args.
 ///
-/// This routine provides the logic to compute a target triple from various
-/// args passed to the driver and the default triple string.
-static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple,
-                                        const ArgList &Args,
-                                        StringRef DarwinArchName) {
-  if (const Arg *A = Args.getLastArg(options::OPT_target))
-    DefaultTargetTriple = A->getValue(Args);
+/// This routine updates the default target triple based on various
+/// args passed to the driver.
+static void updateTargetTriple(llvm::Triple &Target,
+                               const ArgList &Args,
+                               StringRef DarwinArchName) {
 
-  llvm::Triple Target(llvm::Triple::normalize(DefaultTargetTriple));
-
   // Handle Darwin-specific options available here.
   if (Target.isOSDarwin()) {
     // If an explict Darwin arch name is given, that trumps all.
     if (!DarwinArchName.empty()) {
       Target.setArch(
         llvm::Triple::getArchTypeForDarwinArchName(DarwinArchName));
-      return Target;
+      return;
     }
 
     // Handle the Darwin '-arch' flag.
@@ -1604,7 +1600,7 @@
   if (Target.getArchName() == "tce" ||
       Target.getOS() == llvm::Triple::AuroraUX ||
       Target.getOS() == llvm::Triple::Minix)
-    return Target;
+    return;
 
   // Handle pseudo-target flags '-m32' and '-m64'.
   // FIXME: Should this information be in llvm::Triple?
@@ -1621,20 +1617,24 @@
         Target.setArch(llvm::Triple::ppc64);
     }
   }
-
-  return Target;
 }
 
 const ToolChain &Driver::getToolChain(const ArgList &Args,
                                       StringRef DarwinArchName) const {
-  llvm::Triple Target = computeTargetTriple(DefaultTargetTriple, Args,
-                                            DarwinArchName);
+  StringRef TargetTriple(DefaultTargetTriple);
+  if (const Arg *A = Args.getLastArg(options::OPT_target))
+    TargetTriple = A->getValue(Args);
 
-  ToolChain *&TC = ToolChains[Target.str()];
+  llvm::Triple ToolTarget(llvm::Triple::normalize(TargetTriple));
+  llvm::Triple Target(ToolTarget);
+  updateTargetTriple(Target, Args, DarwinArchName);
+  std::string ToolChainsIndex = std::string(TargetTriple) + "::" + Target.str();
+
+  ToolChain *&TC = ToolChains[ToolChainsIndex];
   if (!TC) {
     switch (Target.getOS()) {
     case llvm::Triple::AuroraUX:
-      TC = new toolchains::AuroraUX(*this, Target);
+      TC = new toolchains::AuroraUX(*this, TargetTriple, ToolTarget, Target);
       break;
     case llvm::Triple::Darwin:
     case llvm::Triple::MacOSX:
@@ -1643,41 +1643,44 @@
           Target.getArch() == llvm::Triple::x86_64 ||
           Target.getArch() == llvm::Triple::arm ||
           Target.getArch() == llvm::Triple::thumb)
-        TC = new toolchains::DarwinClang(*this, Target);
+        TC = new toolchains::DarwinClang(*this, TargetTriple,
+                                         ToolTarget, Target);
       else
-        TC = new toolchains::Darwin_Generic_GCC(*this, Target);
+        TC = new toolchains::Darwin_Generic_GCC(*this, TargetTriple,
+                                                ToolTarget, Target);
       break;
     case llvm::Triple::DragonFly:
-      TC = new toolchains::DragonFly(*this, Target);
+      TC = new toolchains::DragonFly(*this, TargetTriple, ToolTarget, Target);
       break;
     case llvm::Triple::OpenBSD:
-      TC = new toolchains::OpenBSD(*this, Target);
+      TC = new toolchains::OpenBSD(*this, TargetTriple, ToolTarget, Target);
       break;
     case llvm::Triple::NetBSD:
-      TC = new toolchains::NetBSD(*this, Target);
+      TC = new toolchains::NetBSD(*this, TargetTriple, ToolTarget, Target);
       break;
     case llvm::Triple::FreeBSD:
-      TC = new toolchains::FreeBSD(*this, Target);
+      TC = new toolchains::FreeBSD(*this, TargetTriple, ToolTarget, Target);
       break;
     case llvm::Triple::Minix:
-      TC = new toolchains::Minix(*this, Target);
+      TC = new toolchains::Minix(*this, TargetTriple, ToolTarget, Target);
       break;
     case llvm::Triple::Linux:
-      TC = new toolchains::Linux(*this, Target);
+      TC = new toolchains::Linux(*this, TargetTriple, ToolTarget, Target);
       break;
     case llvm::Triple::Win32:
-      TC = new toolchains::Windows(*this, Target);
+      TC = new toolchains::Windows(*this, TargetTriple, ToolTarget, Target);
       break;
     case llvm::Triple::MinGW32:
       // FIXME: We need a MinGW toolchain. Fallthrough for now.
     default:
       // TCE is an OSless target
       if (Target.getArchName() == "tce") {
-        TC = new toolchains::TCEToolChain(*this, Target);
+        TC = new toolchains::TCEToolChain(*this, TargetTriple,
+                                          ToolTarget, Target);
         break;
       }
 
-      TC = new toolchains::Generic_GCC(*this, Target);
+      TC = new toolchains::Generic_GCC(*this, TargetTriple, ToolTarget, Target);
       break;
     }
   }
Index: lib/Driver/WindowsToolChain.cpp
===================================================================
--- lib/Driver/WindowsToolChain.cpp	(revision 148956)
+++ lib/Driver/WindowsToolChain.cpp	(working copy)
@@ -35,8 +35,9 @@
 using namespace clang::driver::toolchains;
 using namespace clang;
 
-Windows::Windows(const Driver &D, const llvm::Triple& Triple)
-  : ToolChain(D, Triple) {
+Windows::Windows(const Driver &D, std::string UserTripleString,
+               const llvm::Triple &ToolTriple, const llvm::Triple &Triple)
+  : ToolChain(D, UserTripleString, ToolTriple, Triple) {
 }
 
 Tool &Windows::SelectTool(const Compilation &C, const JobAction &JA,
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to