[PowerPC][clang] Fix triple constructor ambiguity causing "unknown" target triple on AIX (#147488)

PR #145685 introduced constructor overload ambiguity in the Triple
class, causing `updateTripleOSVersion()` to construct Triple objects
with `unknown` instead of the configured target triple (e.g.,
`powerpc-ibm-aix7.3.0.0`). This results in Clang driver errors like
`error: unknown target triple 'unknown'`.

Used `Twine` constructor with braced initialization to bypass ambiguity.

---------

Co-authored-by: Tony Varghese <tony.varghese@ibm.com>
Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
This commit is contained in:
Tony Varghese 2025-07-08 22:45:56 +05:30 committed by GitHub
parent 320f6820e3
commit b4b150f8c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1,14 @@
// 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{{.*}}
int main() {
return 0;
}

View File

@ -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) {