]> granicus.if.org Git - clang/commitdiff
Respect bound archs, even when they don't alter the toolchain.
authorJustin Lebar <jlebar@google.com>
Sat, 16 Jan 2016 03:30:08 +0000 (03:30 +0000)
committerJustin Lebar <jlebar@google.com>
Sat, 16 Jan 2016 03:30:08 +0000 (03:30 +0000)
Summary:
It's possible to BindArch without changing the toolchain at all.  For
example, armv7 and armv7s have exactly the same toolchain triple.

Therefore the code in the Driver that checks that we're not creating a
job for the same Action twice needs to consider (Action, Toolchain,
BoundArch) tuples.

Reviewers: tra

Subscribers: aemerson, echristo, beanz, cfe-commits

Differential Revision: http://reviews.llvm.org/D16250

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257983 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Driver.h
lib/Driver/Driver.cpp
test/Driver/darwin-multiarch-arm.c [new file with mode: 0644]

index 8e4fd3416d3ad346cae699a6e2aa34c251f6e86d..250211c9cff248fe5464431b547e6a169f7ba87e 100644 (file)
@@ -380,9 +380,9 @@ public:
                                const llvm::opt::ArgList &Args, phases::ID Phase,
                                Action *Input) const;
 
-  /// BuildJobsForAction - Construct the jobs to perform for the
-  /// action \p A and return an InputInfo for the result of running \p A.
-  /// Will only construct jobs for a given (Action, ToolChain) pair once.
+  /// BuildJobsForAction - Construct the jobs to perform for the action \p A and
+  /// return an InputInfo for the result of running \p A.  Will only construct
+  /// jobs for a given (Action, ToolChain, BoundArch) tuple once.
   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
                                const ToolChain *TC, const char *BoundArch,
                                bool AtTopLevel, bool MultipleArchs,
index 0cdfb4fe1059be06e327110a8b65ed7c7967e093..5c01ef0bba7c132c786afb3ac71eb48ec7efa5ad 100644 (file)
@@ -1803,8 +1803,15 @@ InputInfo Driver::BuildJobsForAction(
     bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
     std::map<std::pair<const Action *, std::string>, InputInfo> &CachedResults)
     const {
-  std::pair<const Action *, std::string> ActionTC = {
-      A, TC->getTriple().normalize()};
+  // The bound arch is not necessarily represented in the toolchain's triple --
+  // for example, armv7 and armv7s both map to the same triple -- so we need
+  // both in our map.
+  std::string TriplePlusArch = TC->getTriple().normalize();
+  if (BoundArch) {
+    TriplePlusArch += "-";
+    TriplePlusArch += BoundArch;
+  }
+  std::pair<const Action *, std::string> ActionTC = {A, TriplePlusArch};
   auto CachedResult = CachedResults.find(ActionTC);
   if (CachedResult != CachedResults.end()) {
     return CachedResult->second;
diff --git a/test/Driver/darwin-multiarch-arm.c b/test/Driver/darwin-multiarch-arm.c
new file mode 100644 (file)
index 0000000..813f1f2
--- /dev/null
@@ -0,0 +1,18 @@
+// Check that we compile correctly with multiple ARM -arch options.
+//
+// RUN: %clang -target arm7-apple-darwin10 -### \
+// RUN:   -arch armv7 -arch armv7s %s 2>&1 | FileCheck %s
+
+// CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT1:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT1]]"
+// CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT2:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT2]]"
+// CHECK:lipo
+// CHECK-DAG: "[[LD_OUT1]]"
+// CHECK-DAG: "[[LD_OUT2]]"