aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
authorDaniel Chen <cdchen@ca.ibm.com>2025-03-28 09:22:02 -0400
committerGitHub <noreply@github.com>2025-03-28 09:22:02 -0400
commit316bb89c942c1a1cf61d3e673030f82d6f0b8acf (patch)
tree84b3f812a98b39a8fd2c02eea7f9717e8d3c2905 /clang/lib/Driver/ToolChain.cpp
parent4abff4d7b2b49f343da68f32ffdae2914ba8ae7f (diff)
downloadllvm-316bb89c942c1a1cf61d3e673030f82d6f0b8acf.zip
llvm-316bb89c942c1a1cf61d3e673030f82d6f0b8acf.tar.gz
llvm-316bb89c942c1a1cf61d3e673030f82d6f0b8acf.tar.bz2
[Driver] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON on AIX. (#132821)
In the wake of discussion in PR #131200 and internal discussion after, we will add support for `LLVM_ENABLE_PER_TARGET_RUNTIME=ON` for AIX instead of disable it. I already reverted the change in PR #131200. The default value of the option is still OFF on AIX.
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r--clang/lib/Driver/ToolChain.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 5f75d004..8a922b2 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -779,8 +779,6 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
if (Path.empty())
Path = P;
}
- if (getTriple().isOSAIX())
- Path.clear();
// Check the filename for the old layout if the new one does not exist.
CRTBasename =
@@ -846,6 +844,16 @@ ToolChain::getFallbackAndroidTargetPath(StringRef BaseDir) const {
return std::string(P);
}
+llvm::Triple ToolChain::getTripleWithoutOSVersion() const {
+ return (Triple.hasEnvironment()
+ ? llvm::Triple(Triple.getArchName(), Triple.getVendorName(),
+ llvm::Triple::getOSTypeName(Triple.getOS()),
+ llvm::Triple::getEnvironmentTypeName(
+ Triple.getEnvironment()))
+ : llvm::Triple(Triple.getArchName(), Triple.getVendorName(),
+ llvm::Triple::getOSTypeName(Triple.getOS())));
+}
+
std::optional<std::string>
ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
auto getPathForTriple =
@@ -864,14 +872,7 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
if (T.isOSzOS() &&
(!T.getOSVersion().empty() || !T.getEnvironmentVersion().empty())) {
// Build the triple without version information
- const llvm::Triple &TripleWithoutVersion =
- (T.hasEnvironment()
- ? llvm::Triple(
- T.getArchName(), T.getVendorName(),
- llvm::Triple::getOSTypeName(T.getOS()),
- llvm::Triple::getEnvironmentTypeName(T.getEnvironment()))
- : llvm::Triple(T.getArchName(), T.getVendorName(),
- llvm::Triple::getOSTypeName(T.getOS())));
+ const llvm::Triple &TripleWithoutVersion = getTripleWithoutOSVersion();
if (auto Path = getPathForTriple(TripleWithoutVersion))
return *Path;
}
@@ -909,9 +910,18 @@ std::optional<std::string> ToolChain::getRuntimePath() const {
llvm::sys::path::append(P, "lib");
if (auto Ret = getTargetSubDirPath(P))
return Ret;
- // Darwin and AIX does not use per-target runtime directory.
- if (Triple.isOSDarwin() || Triple.isOSAIX())
+ // Darwin does not use per-target runtime directory.
+ 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);
}