Make the triple an explicit argument of FindTargetProgramPath.
Preserve the original triple in the NetBSD toolchain when using -m32 or
-m64 and the resulting effective target is different from the triple it
started with. This allows -m32 to use the same assembler/linking in
cross-compiling mode and avoids confusion about passing down target
specific flags in that case like --32.

llvm-svn: 131404
diff --git a/clang/lib/Driver/Tools.h b/clang/lib/Driver/Tools.h
index 93abf75..4a5a7e4 100644
--- a/clang/lib/Driver/Tools.h
+++ b/clang/lib/Driver/Tools.h
@@ -14,6 +14,7 @@
 #include "clang/Driver/Types.h"
 #include "clang/Driver/Util.h"
 
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/Compiler.h"
 
 namespace clang {
@@ -338,9 +339,12 @@
   /// 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) : Tool("netbsd::Assemble", "assembler",
-                                         TC) {}
+    Assemble(const ToolChain &TC, const llvm::Triple &ToolTriple)
+      : Tool("netbsd::Assemble", "assembler", TC), ToolTriple(ToolTriple) {}
 
     virtual bool hasIntegratedCPP() const { return false; }
 
@@ -351,8 +355,12 @@
                               const char *LinkingOutput) const;
   };
   class LLVM_LIBRARY_VISIBILITY Link : public Tool  {
+  private:
+    const llvm::Triple ToolTriple;
+
   public:
-    Link(const ToolChain &TC) : Tool("netbsd::Link", "linker", TC) {}
+    Link(const ToolChain &TC, const llvm::Triple &ToolTriple)
+      : Tool("netbsd::Ling", "linker", TC), ToolTriple(ToolTriple) {}
 
     virtual bool hasIntegratedCPP() const { return false; }