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

Merged
merged 4 commits into from
Jun 2, 2025
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
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 and the OS version from the triple.
AIXTriple = llvm::Triple(T.getArchName(), T.getVendorName(),
llvm::Triple::getOSTypeName(T.getOS()));
} else {
// Strip the OS version from the triple.
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