aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
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);
}