Skip to content

[clang][AIX] Fix -print-runtime-dir fallback on AIX #141439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
23 changes: 10 additions & 13 deletions clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,11 +933,16 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
if (auto Path = getPathForTriple(T))
return *Path;

if (T.isOSAIX() && T.getEnvironment() == Triple::UnknownEnvironment) {
// Strip unknown environment from the triple.
const llvm::Triple AIXTriple(
llvm::Triple(T.getArchName(), T.getVendorName(),
llvm::Triple::getOSTypeName(T.getOS())));
if (T.isOSAIX()) {
llvm::Triple AIXTriple;
if (T.getEnvironment() == Triple::UnknownEnvironment) {
// Strip unknown environment from the triple.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: this effectively strips the OSVersion as well. Since we moved them together, may be explicitly say it in the comment to make it clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved the OS version comment to apply to the whole if statement

Copy link
Contributor

@DanielCChen DanielCChen May 26, 2025

Choose a reason for hiding this comment

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

Sorry Jake. This is not what I meant. I should have made it clearer.
I meant to change the original comment on line 937 to be Strip unknown environment and the OSVersion from the triple. and keep the comment at line 940 as is.

AIXTriple = llvm::Triple(T.getArchName(), T.getVendorName(),
llvm::Triple::getOSTypeName(T.getOS()));
} else {
// Get the triple without the OS version.
AIXTriple = getTripleWithoutOSVersion();
}
if (auto Path = getPathForTriple(AIXTriple))
return *Path;
}
Expand Down Expand Up @@ -987,14 +992,6 @@ std::optional<std::string> ToolChain::getRuntimePath() const {
if (Triple.isOSDarwin())
return {};

// For AIX, get the triple without the OS version.
if (Triple.isOSAIX()) {
const llvm::Triple &TripleWithoutVersion = getTripleWithoutOSVersion();
llvm::sys::path::append(P, TripleWithoutVersion.str());
if (getVFS().exists(P))
return std::string(P);
return {};
}
llvm::sys::path::append(P, Triple.str());
return std::string(P);
}
Expand Down
9 changes: 0 additions & 9 deletions clang/test/Driver/aix-print-runtime-dir.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
// Test output of -print-runtime-dir on AIX

// RUN: %clang -print-runtime-dir --target=powerpc-ibm-aix \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s

// RUN: %clang -print-runtime-dir --target=powerpc64-ibm-aix \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s

// RUN: %clang -print-runtime-dir --target=powerpc-ibm-aix \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir\
// RUN: | FileCheck --check-prefix=PRINT-RUNTIME-DIR32-PER-TARGET %s
Expand All @@ -24,7 +16,6 @@
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: | FileCheck --check-prefix=PRINT-RUNTIME-DIR64-UNKNOWN-ENV %s

// PRINT-RUNTIME-DIR: lib{{/|\\}}aix{{$}}
// PRINT-RUNTIME-DIR32-PER-TARGET: lib{{/|\\}}powerpc-ibm-aix{{$}}
// PRINT-RUNTIME-DIR64-PER-TARGET: lib{{/|\\}}powerpc64-ibm-aix{{$}}
// PRINT-RUNTIME-DIR32-UNKNOWN-ENV: lib{{/|\\}}powerpc-ibm-aix
Expand Down
Loading