[cfe-commits] r167571 - in /cfe/trunk: include/clang/Driver/ToolChain.h lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp test/Driver/darwin-arch-default.c

Daniel Dunbar daniel at zuster.org
Wed Nov 7 19:38:27 PST 2012


Author: ddunbar
Date: Wed Nov  7 21:38:26 2012
New Revision: 167571

URL: http://llvm.org/viewvc/llvm-project?rev=167571&view=rev
Log:
Driver/Darwin: The -arch argument values aren't exactly the arch names from a
triple.

 - Translate the special case of powerpc to its expected -arch name.

Added:
    cfe/trunk/test/Driver/darwin-arch-default.c
Modified:
    cfe/trunk/include/clang/Driver/ToolChain.h
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/ToolChain.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=167571&r1=167570&r2=167571&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Nov  7 21:38:26 2012
@@ -85,6 +85,10 @@
   StringRef getPlatform() const { return Triple.getVendorName(); }
   StringRef getOS() const { return Triple.getOSName(); }
 
+  /// \brief Provide the default architecture name (as expected by -arch) for
+  /// this toolchain. Note t
+  std::string getDefaultUniversalArchName() const;
+
   std::string getTripleString() const {
     return Triple.getTriple();
   }

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=167571&r1=167570&r2=167571&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Nov  7 21:38:26 2012
@@ -806,7 +806,7 @@
   // When there is no explicit arch for this platform, make sure we still bind
   // the architecture (to the default) so that -Xarch_ is handled correctly.
   if (!Archs.size())
-    Archs.push_back(Args.MakeArgString(TC.getArchName()));
+    Archs.push_back(Args.MakeArgString(TC.getDefaultUniversalArchName()));
 
   // FIXME: We killed off some others but these aren't yet detected in a
   // functional manner. If we added information to jobs about which "auxiliary"

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=167571&r1=167570&r2=167571&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Nov  7 21:38:26 2012
@@ -33,6 +33,21 @@
  return D;
 }
 
+std::string ToolChain::getDefaultUniversalArchName() const {
+  // In universal driver terms, the arch name accepted by -arch isn't exactly
+  // the same as the ones that appear in the triple. Roughly speaking, this is
+  // an inverse of the darwin::getArchTypeForDarwinArchName() function, but the
+  // only interesting special case is powerpc.
+  switch (Triple.getArch()) {
+  case llvm::Triple::ppc:
+    return "ppc";
+  case llvm::Triple::ppc64:
+    return "ppc64";
+  default:
+    return Triple.getArchName();
+  }
+}
+
 bool ToolChain::IsUnwindTablesDefault() const {
   return false;
 }

Added: cfe/trunk/test/Driver/darwin-arch-default.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-arch-default.c?rev=167571&view=auto
==============================================================================
--- cfe/trunk/test/Driver/darwin-arch-default.c (added)
+++ cfe/trunk/test/Driver/darwin-arch-default.c Wed Nov  7 21:38:26 2012
@@ -0,0 +1,7 @@
+// Check that the name of the arch we bind is "ppc" not "powerpc".
+//
+// RUN: %clang -target powerpc-apple-darwin8 -### \
+// RUN:   -ccc-print-phases %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-POWERPC < %t %s
+//
+// CHECK-POWERPC: bind-arch, "ppc"





More information about the cfe-commits mailing list