From 6cc62043c8bf4daa27664a2e1674abbe8d0492c6 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Mon, 26 Apr 2021 10:56:30 -0700 Subject: [PATCH] [clang][driver] Use the provided arch name for a Darwin target triple This ensures that the Darwin driver uses a consistent target triple representation when the triple is printed out to the user. Differential Revision: https://reviews.llvm.org/D100807 --- clang/lib/Driver/ToolChains/Darwin.cpp | 10 +++++----- clang/test/Driver/aarch64-cpus.c | 2 +- clang/test/Driver/arm64_32-link.c | 2 +- clang/test/Driver/darwin-version.c | 8 ++++---- clang/test/Driver/default-toolchain.c | 3 +++ 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index bc59b6b..177cfd6 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -74,12 +74,12 @@ void darwin::setTripleTypeForMachOArchName(llvm::Triple &T, StringRef Str) { const llvm::Triple::ArchType Arch = getArchTypeForMachOArchName(Str); llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(Str); T.setArch(Arch); - - if (Str == "x86_64h" || Str == "arm64e") + if (Arch != llvm::Triple::UnknownArch) T.setArchName(Str); - else if (ArchKind == llvm::ARM::ArchKind::ARMV6M || - ArchKind == llvm::ARM::ArchKind::ARMV7M || - ArchKind == llvm::ARM::ArchKind::ARMV7EM) { + + if (ArchKind == llvm::ARM::ArchKind::ARMV6M || + ArchKind == llvm::ARM::ArchKind::ARMV7M || + ArchKind == llvm::ARM::ArchKind::ARMV7EM) { T.setOS(llvm::Triple::UnknownOS); T.setObjectFormat(llvm::Triple::MachO); } diff --git a/clang/test/Driver/aarch64-cpus.c b/clang/test/Driver/aarch64-cpus.c index 5b9bd52..9a2fc85 100644 --- a/clang/test/Driver/aarch64-cpus.c +++ b/clang/test/Driver/aarch64-cpus.c @@ -33,7 +33,7 @@ // ARM64E-DARWIN: "-cc1"{{.*}} "-triple" "arm64e{{.*}}" "-target-cpu" "apple-a12" // RUN: %clang -target arm64-apple-darwin -arch arm64_32 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64_32-DARWIN %s -// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "aarch64_32{{.*}}" "-target-cpu" "apple-s4" +// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "arm64_32{{.*}}" "-target-cpu" "apple-s4" // RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35 %s // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35 %s diff --git a/clang/test/Driver/arm64_32-link.c b/clang/test/Driver/arm64_32-link.c index 972ae6a..6ef0b6f 100644 --- a/clang/test/Driver/arm64_32-link.c +++ b/clang/test/Driver/arm64_32-link.c @@ -1,4 +1,4 @@ // RUN: %clang -target x86_64-apple-darwin -arch arm64_32 -miphoneos-version-min=8.0 %s -### 2>&1 | FileCheck %s -// CHECK: "-cc1"{{.*}} "-triple" "aarch64_32-apple-ios8.0.0" +// CHECK: "-cc1"{{.*}} "-triple" "arm64_32-apple-ios8.0.0" // CHECK: ld{{.*}} "-arch" "arm64_32" diff --git a/clang/test/Driver/darwin-version.c b/clang/test/Driver/darwin-version.c index 3471552..130a665 100644 --- a/clang/test/Driver/darwin-version.c +++ b/clang/test/Driver/darwin-version.c @@ -60,17 +60,17 @@ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX4 %s // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX4 %s -// CHECK-VERSION-OSX4: "i386-apple-macosx10.4.0" +// CHECK-VERSION-OSX4: "i686-apple-macosx10.4.0" // RUN: %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX5 %s // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.5 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX5 %s -// CHECK-VERSION-OSX5: "i386-apple-macosx10.5.0" +// CHECK-VERSION-OSX5: "i686-apple-macosx10.5.0" // RUN: %clang -target i686-apple-darwin10 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX6 %s // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.6 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX6 %s -// CHECK-VERSION-OSX6: "i386-apple-macosx10.6.0" +// CHECK-VERSION-OSX6: "i686-apple-macosx10.6.0" // RUN: %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX10 %s // RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.10 -c %s -### 2>&1 | \ @@ -100,7 +100,7 @@ // Check environment variable gets interpreted correctly // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \ -// RUN: %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \ +// RUN: %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX5 %s // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \ // RUN: %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \ diff --git a/clang/test/Driver/default-toolchain.c b/clang/test/Driver/default-toolchain.c index b9111a6..4971c90 100644 --- a/clang/test/Driver/default-toolchain.c +++ b/clang/test/Driver/default-toolchain.c @@ -6,3 +6,6 @@ // RUN: %clang -target i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t // RUN: grep 'Target: powerpc-apple-darwin9' %t + +// RUN: %clang -target x86_64-apple-macos11 -arch arm64 -v 2>&1 | FileCheck --check-prefix=ARM64 %s +// ARM64: Target: arm64-apple-macos11 -- 2.7.4