[clang] [llvm] [PowerPC][clang] Fix triple constructor ambiguity causing "unknown" target triple on AIX (PR #147488)
Tony Varghese via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 8 02:52:33 PDT 2025
https://github.com/tonykuttai updated https://github.com/llvm/llvm-project/pull/147488
>From 859bdf07278fef79780b833fc998810219ca1d27 Mon Sep 17 00:00:00 2001
From: Tony Varghese <tony.varghese at ibm.com>
Date: Tue, 8 Jul 2025 05:04:12 -0400
Subject: [PATCH] [PowerPC][clang] Fix triple constructor ambiguity causing
"unknown" target triple on AIX
---
clang/test/Driver/aix-default-target-triple.c | 17 +++++++++++++++++
llvm/lib/TargetParser/Unix/Host.inc | 2 +-
2 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 clang/test/Driver/aix-default-target-triple.c
diff --git a/clang/test/Driver/aix-default-target-triple.c b/clang/test/Driver/aix-default-target-triple.c
new file mode 100644
index 0000000000000..43d809d168e9d
--- /dev/null
+++ b/clang/test/Driver/aix-default-target-triple.c
@@ -0,0 +1,17 @@
+// Test for the Triple constructor ambiguity fix on AIX
+// This test verifies that the default target triple is correctly resolved
+// and doesn't fall back to "unknown" due to constructor ambiguity.
+
+// REQUIRES: system-aix
+// RUN: %clang -v %s -c 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET
+
+// Test that the target triple contains AIX and is not "unknown"
+// The target should be something like "powerpc-ibm-aix7.3.0.0"
+// CHECK-TARGET: Target: {{.*}}aix{{.*}}
+// CHECK-TARGET-NOT: error: unknown target triple 'unknown'
+
+#include <stdio.h>
+
+int main() {
+ return 0;
+}
diff --git a/llvm/lib/TargetParser/Unix/Host.inc b/llvm/lib/TargetParser/Unix/Host.inc
index ef9e288ee3a01..aeb2f59218700 100644
--- a/llvm/lib/TargetParser/Unix/Host.inc
+++ b/llvm/lib/TargetParser/Unix/Host.inc
@@ -55,7 +55,7 @@ static std::string updateTripleOSVersion(std::string TargetTripleString) {
// On AIX, the AIX version and release should be that of the current host
// unless if the version has already been specified.
if (Triple(LLVM_HOST_TRIPLE).getOS() == Triple::AIX) {
- Triple TT(std::move(TargetTripleString));
+ Triple TT{TargetTripleString};
if (TT.getOS() == Triple::AIX && !TT.getOSMajorVersion()) {
struct utsname name;
if (uname(&name) != -1) {
More information about the llvm-commits
mailing list