Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions clang/test/Driver/aix-default-target-triple.c
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonykuttai, this is not sufficient. The target also has to be AIX to begin with (as opposed to an AIX-hosted cross-compiling configuration).

// 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;
}
2 changes: 1 addition & 1 deletion llvm/lib/TargetParser/Unix/Host.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function shouldn't depend on the host triple in the first place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test file to lock this down.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function shouldn't depend on the host triple in the first place

This function intends to transfer host characteristics (the OS version information) to AIX target triples (which is then used in Clang for predefined macros, among other things). The host characteristics have no reasonable relation to the AIX target triple unless the compiler is hosted on AIX.

Triple TT(std::move(TargetTripleString));
Triple TT{TargetTripleString};
if (TT.getOS() == Triple::AIX && !TT.getOSMajorVersion()) {
struct utsname name;
if (uname(&name) != -1) {
Expand Down
Loading