[clang] Revert "[clang][driver] Fix -print-target-triple OS version for apple targets" (PR #104563)
Martin Storsjö via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 16 01:36:32 PDT 2024
https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/104563
This reverts llvm/llvm-project#104037 / 7227b44f928a87b5d7fb05bd1539fdfb6d4958dc.
This change had the unintended consequence of making e.g. `clang -target armv7-windows-gnu --print-target-triple` output `thumbv7-unknown-windows-gnu` rather than `armv7-unknown-windows-gnu`.
>From d39fff2a6c7c77d6046a075e6119a4126d955b1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Fri, 16 Aug 2024 11:34:18 +0300
Subject: [PATCH] =?UTF-8?q?Revert=20"[clang][driver]=20Fix=20-print-target?=
=?UTF-8?q?-triple=20OS=20version=20for=20apple=20targets=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit 7227b44f928a87b5d7fb05bd1539fdfb6d4958dc.
---
clang/lib/Driver/Driver.cpp | 13 ++----
.../test/Driver/darwin-print-target-triple.c | 42 -------------------
2 files changed, 3 insertions(+), 52 deletions(-)
delete mode 100644 clang/test/Driver/darwin-print-target-triple.c
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5b95019c25cab6..e12416e51f8d24 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2271,7 +2271,8 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
return false;
}
- auto initializeTargets = [&]() {
+ if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
+ ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(C.getArgs()));
// The 'Darwin' toolchain is initialized only when its arguments are
// computed. Get the default arguments for OFK_None to ensure that
@@ -2281,12 +2282,6 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
// FIXME: For some more esoteric targets the default toolchain is not the
// correct one.
C.getArgsForToolChain(&TC, Triple.getArchName(), Action::OFK_None);
- return Triple;
- };
-
- if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
- ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
- const llvm::Triple Triple = initializeTargets();
RegisterEffectiveTriple TripleRAII(TC, Triple);
switch (RLT) {
case ToolChain::RLT_CompilerRT:
@@ -2330,9 +2325,7 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
}
if (C.getArgs().hasArg(options::OPT_print_target_triple)) {
- initializeTargets();
- llvm::Triple Triple(TC.ComputeEffectiveClangTriple(C.getArgs()));
- llvm::outs() << Triple.getTriple() << "\n";
+ llvm::outs() << TC.getTripleString() << "\n";
return false;
}
diff --git a/clang/test/Driver/darwin-print-target-triple.c b/clang/test/Driver/darwin-print-target-triple.c
deleted file mode 100644
index 4f5fdfe9d0db34..00000000000000
--- a/clang/test/Driver/darwin-print-target-triple.c
+++ /dev/null
@@ -1,42 +0,0 @@
-// Test the output of -print-target-triple on Darwin.
-// See https://github.com/llvm/llvm-project/issues/61762
-
-//
-// All platforms
-//
-
-// RUN: %clang -print-target-triple \
-// RUN: --target=x86_64-apple-macos -mmacos-version-min=15 \
-// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-MACOS %s
-// CHECK-CLANGRT-MACOS: x86_64-apple-macosx15.0.0
-
-// RUN: %clang -print-target-triple \
-// RUN: --target=arm64-apple-ios -mios-version-min=9 \
-// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-IOS %s
-// CHECK-CLANGRT-IOS: arm64-apple-ios9.0.0
-
-// RUN: %clang -print-target-triple \
-// RUN: --target=arm64-apple-watchos -mwatchos-version-min=3 \
-// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-WATCHOS %s
-// CHECK-CLANGRT-WATCHOS: arm64-apple-watchos3.0.0
-
-// RUN: %clang -print-target-triple \
-// RUN: --target=armv7k-apple-watchos -mwatchos-version-min=3 \
-// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-WATCHOS-ARMV7K %s
-// CHECK-CLANGRT-WATCHOS-ARMV7K: thumbv7-apple-watchos3.0.0
-
-// RUN: %clang -print-target-triple \
-// RUN: --target=arm64-apple-tvos -mtvos-version-min=1\
-// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-TVOS %s
-// CHECK-CLANGRT-TVOS: arm64-apple-tvos1.0.0
-
-// RUN: %clang -print-target-triple \
-// RUN: --target=arm64-apple-driverkit \
-// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-DRIVERKIT %s
-// CHECK-CLANGRT-DRIVERKIT: arm64-apple-driverkit19.0.0
More information about the cfe-commits
mailing list