<p dir="ltr">Ultimately they probably shouldn't map to the same toolchain and we can use that as a key. Looks OK for now though. </p>
<br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 15, 2016, 5:48 PM Justin Lebar <<a href="mailto:jlebar@google.com">jlebar@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">jlebar created this revision.<br>
jlebar added a reviewer: tra.<br>
jlebar added subscribers: cfe-commits, beanz, echristo.<br>
Herald added a subscriber: aemerson.<br>
<br>
It's possible to BindArch without changing the toolchain at all.  For<br>
example, armv7 and armv7s have exactly the same triple.<br>
<br>
Therefore the code in the Driver that checks that we're not creating a<br>
job for the same Action twice needs to consider (Action, Toolchain,<br>
BoundArch) tuples.<br>
<br>
<a href="http://reviews.llvm.org/D16250" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16250</a><br>
<br>
Files:<br>
  include/clang/Driver/Driver.h<br>
  lib/Driver/Driver.cpp<br>
  test/Driver/darwin-multiarch-arm.c<br>
<br>
Index: test/Driver/darwin-multiarch-arm.c<br>
===================================================================<br>
--- /dev/null<br>
+++ test/Driver/darwin-multiarch-arm.c<br>
@@ -0,0 +1,18 @@<br>
+// Check that we compile correctly with multiple ARM -arch options.<br>
+//<br>
+// RUN: %clang -target arm7-apple-darwin10 -### \<br>
+// RUN:   -arch armv7 -arch armv7s %s 2>&1 | FileCheck %s<br>
+<br>
+// CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"<br>
+// CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"<br>
+// CHECK:ld<br>
+// CHECK-SAME: "-o" "[[LD_OUT1:[^"]*]]"<br>
+// CHECK-SAME: "[[CC_OUT1]]"<br>
+// CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"<br>
+// CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"<br>
+// CHECK:ld<br>
+// CHECK-SAME: "-o" "[[LD_OUT2:[^"]*]]"<br>
+// CHECK-SAME: "[[CC_OUT2]]"<br>
+// CHECK:lipo<br>
+// CHECK-DAG: "[[LD_OUT1]]"<br>
+// CHECK-DAG: "[[LD_OUT2]]"<br>
Index: lib/Driver/Driver.cpp<br>
===================================================================<br>
--- lib/Driver/Driver.cpp<br>
+++ lib/Driver/Driver.cpp<br>
@@ -1803,8 +1803,15 @@<br>
     bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,<br>
     std::map<std::pair<const Action *, std::string>, InputInfo> &CachedResults)<br>
     const {<br>
-  std::pair<const Action *, std::string> ActionTC = {<br>
-      A, TC->getTriple().normalize()};<br>
+  // The bound arch is not necessarily represented in the toolchain's triple --<br>
+  // for example, armv7 and armv7s both map to the same triple -- so we need<br>
+  // both in our map.<br>
+  std::string TriplePlusArch = TC->getTriple().normalize();<br>
+  if (BoundArch) {<br>
+    TriplePlusArch += "-";<br>
+    TriplePlusArch += BoundArch;<br>
+  }<br>
+  std::pair<const Action *, std::string> ActionTC = {A, TriplePlusArch};<br>
   auto CachedResult = CachedResults.find(ActionTC);<br>
   if (CachedResult != CachedResults.end()) {<br>
     return CachedResult->second;<br>
Index: include/clang/Driver/Driver.h<br>
===================================================================<br>
--- include/clang/Driver/Driver.h<br>
+++ include/clang/Driver/Driver.h<br>
@@ -380,9 +380,9 @@<br>
                                const llvm::opt::ArgList &Args, phases::ID Phase,<br>
                                Action *Input) const;<br>
<br>
-  /// BuildJobsForAction - Construct the jobs to perform for the<br>
-  /// action \p A and return an InputInfo for the result of running \p A.<br>
-  /// Will only construct jobs for a given (Action, ToolChain) pair once.<br>
+  /// BuildJobsForAction - Construct the jobs to perform for the action \p A and<br>
+  /// return an InputInfo for the result of running \p A.  Will only construct<br>
+  /// jobs for a given (Action, ToolChain, BoundArch) tuple once.<br>
   InputInfo BuildJobsForAction(Compilation &C, const Action *A,<br>
                                const ToolChain *TC, const char *BoundArch,<br>
                                bool AtTopLevel, bool MultipleArchs,<br>
<br>
<br>
</blockquote></div>