[clang] ac1f7ab - [clang] [Darwin] Add reverse mappings for aarch64/aarch64_32 to darwin arch names

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Fri May 29 05:23:31 PDT 2020


Author: Martin Storsjö
Date: 2020-05-29T15:23:14+03:00
New Revision: ac1f7ab007e347dc4a542aa3415e6378289480f4

URL: https://github.com/llvm/llvm-project/commit/ac1f7ab007e347dc4a542aa3415e6378289480f4
DIFF: https://github.com/llvm/llvm-project/commit/ac1f7ab007e347dc4a542aa3415e6378289480f4.diff

LOG: [clang] [Darwin] Add reverse mappings for aarch64/aarch64_32 to darwin arch names

These are mapped in MachO::getMachOArchName already, but were missing
in ToolChain::getDefaultUniversalArchName.

Having these reverse mapped here fixes weird inconsistencies like
-dumpmachine showing a target triple like "aarch64-apple-darwin",
while "clang -target aarch64-apple-darwin" didn't use to work (ended
up mapped as unknown-apple-ios).

Differential Revision: https://reviews.llvm.org/D79117

Added: 
    clang/test/Driver/darwin-arm64-target.c

Modified: 
    clang/lib/Driver/ToolChain.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index ad66e8e6b5d3..cf04fd07e2a0 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -230,9 +230,12 @@ ToolChain::getTargetAndModeFromProgramName(StringRef PN) {
 StringRef 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.
+  // an inverse of the darwin::getArchTypeForDarwinArchName() function.
   switch (Triple.getArch()) {
+  case llvm::Triple::aarch64:
+    return "arm64";
+  case llvm::Triple::aarch64_32:
+    return "arm64_32";
   case llvm::Triple::ppc:
     return "ppc";
   case llvm::Triple::ppc64:

diff  --git a/clang/test/Driver/darwin-arm64-target.c b/clang/test/Driver/darwin-arm64-target.c
new file mode 100644
index 000000000000..397afa288360
--- /dev/null
+++ b/clang/test/Driver/darwin-arm64-target.c
@@ -0,0 +1,3 @@
+// RUN: %clang -target aarch64-apple-darwin %s -miphoneos-version-min=8.0 -### 2>&1 | FileCheck %s
+
+// CHECK: "-cc1"{{.*}} "-triple" "arm64-apple-ios8.0.0"


        


More information about the cfe-commits mailing list