[clang] 37e7cf7 - Driver: Make macOS the default target OS for -arch arm64

Duncan P. N. Exon Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 18 13:39:51 PDT 2022


Author: Duncan P. N. Exon Smith
Date: 2022-03-18T13:36:47-07:00
New Revision: 37e7cf7f1c6920d33a4a5dd3f0a415a61dd24731

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

LOG: Driver: Make macOS the default target OS for -arch arm64

This is a follow up to 565603cc94d79a8d0de6df840fd53714899fb890,
which made macOS the default target OS for `-arch arm64` when
running on an Apple Silicon Mac. Now it'll be the default when
running on an Intel Mac too.

clang/test/Driver/apple-arm64-arch.c was a bit odd before: it was added
for the above commit, but tested the inverse behaviour and XFAIL'ed on
Apple Silicon. This inverts it to the (new) behaviour (that's now
correct regardless) and removes the XFAIL.

Radar-Id: rdar://90500294

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Darwin.cpp
    clang/test/Driver/apple-arm64-arch.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index a11cd3fbaa71c..47eb14ffb83e4 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1886,16 +1886,9 @@ inferDeploymentTargetFromArch(DerivedArgList &Args, const Darwin &Toolchain,
   llvm::Triple::OSType OSTy = llvm::Triple::UnknownOS;
 
   StringRef MachOArchName = Toolchain.getMachOArchName(Args);
-  if (MachOArchName == "arm64" || MachOArchName == "arm64e") {
-#if __arm64__
-    // A clang running on an Apple Silicon mac defaults
-    // to building for mac when building for arm64 rather than
-    // defaulting to iOS.
+  if (MachOArchName == "arm64" || MachOArchName == "arm64e")
     OSTy = llvm::Triple::MacOSX;
-#else
-    OSTy = llvm::Triple::IOS;
-#endif
-  } else if (MachOArchName == "armv7" || MachOArchName == "armv7s")
+  else if (MachOArchName == "armv7" || MachOArchName == "armv7s")
     OSTy = llvm::Triple::IOS;
   else if (MachOArchName == "armv7k" || MachOArchName == "arm64_32")
     OSTy = llvm::Triple::WatchOS;

diff  --git a/clang/test/Driver/apple-arm64-arch.c b/clang/test/Driver/apple-arm64-arch.c
index a37346b1a9bb0..a111260b38a6b 100644
--- a/clang/test/Driver/apple-arm64-arch.c
+++ b/clang/test/Driver/apple-arm64-arch.c
@@ -2,6 +2,5 @@
 // RUN:   FileCheck %s
 //
 // REQUIRES: system-darwin
-// XFAIL: apple-silicon-mac
 //
-// CHECK: "-triple" "arm64-apple-ios{{[0-9.]+}}"
+// CHECK: "-triple" "arm64-apple-macosx{{[0-9.]+}}"


        


More information about the cfe-commits mailing list