[clang] [flang] [driver] return immediately in `addArchSpecificRPath` and `getArchSpecificLibPaths` on AIX (PR #134520)
Daniel Chen via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 28 12:43:10 PDT 2025
https://github.com/DanielCChen updated https://github.com/llvm/llvm-project/pull/134520
>From 0287e939669dafd0b6f2467f88d1e7f8a4aa22e2 Mon Sep 17 00:00:00 2001
From: Daniel Chen <cdchen at ca.ibm.com>
Date: Sat, 5 Apr 2025 23:24:09 -0400
Subject: [PATCH 1/3] [driver] return in addArchSpecificRPath for AIX and also
get the triple without the OS on AIX.
---
clang/lib/Driver/ToolChain.cpp | 7 ++++++-
clang/lib/Driver/ToolChains/CommonArgs.cpp | 3 +++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 5cd5755e01587..93ec8002b29e2 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1015,7 +1015,12 @@ ToolChain::path_list ToolChain::getArchSpecificLibPaths() const {
Paths.push_back(std::string(Path));
};
- AddPath({getTriple().str()});
+ // For AIX, get the triple without the OS version.
+ if (Triple.isOSAIX()) {
+ const llvm::Triple &TripleWithoutVersion = getTripleWithoutOSVersion();
+ AddPath({TripleWithoutVersion.str()});
+ } else
+ AddPath({getTriple().str()});
AddPath({getOSLibName(), llvm::Triple::getArchTypeName(getArch())});
return Paths;
}
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 7cc4008ec1f2b..63066d461eaa8 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1252,6 +1252,9 @@ void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args,
options::OPT_fno_rtlib_add_rpath, false))
return;
+ if (TC.getTriple().isOSAIX()) // AIX doesn't support -rpath option.
+ return;
+
SmallVector<std::string> CandidateRPaths(TC.getArchSpecificLibPaths());
if (const auto CandidateRPath = TC.getStdlibPath())
CandidateRPaths.emplace_back(*CandidateRPath);
>From 64e5b60c30e1f82f0ebd77a21cba74336bf2eb4f Mon Sep 17 00:00:00 2001
From: Daniel Chen <cdchen at ca.ibm.com>
Date: Tue, 15 Apr 2025 20:03:30 -0400
Subject: [PATCH 2/3] To disable getArchSpecificLibPaths on AIX.
---
clang/lib/Driver/ToolChain.cpp | 7 +------
clang/lib/Driver/ToolChains/AIX.h | 2 ++
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 93ec8002b29e2..5cd5755e01587 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1015,12 +1015,7 @@ ToolChain::path_list ToolChain::getArchSpecificLibPaths() const {
Paths.push_back(std::string(Path));
};
- // For AIX, get the triple without the OS version.
- if (Triple.isOSAIX()) {
- const llvm::Triple &TripleWithoutVersion = getTripleWithoutOSVersion();
- AddPath({TripleWithoutVersion.str()});
- } else
- AddPath({getTriple().str()});
+ AddPath({getTriple().str()});
AddPath({getOSLibName(), llvm::Triple::getArchTypeName(getArch())});
return Paths;
}
diff --git a/clang/lib/Driver/ToolChains/AIX.h b/clang/lib/Driver/ToolChains/AIX.h
index 8f130f6b54547..23c93aaf86ba8 100644
--- a/clang/lib/Driver/ToolChains/AIX.h
+++ b/clang/lib/Driver/ToolChains/AIX.h
@@ -98,6 +98,8 @@ class LLVM_LIBRARY_VISIBILITY AIX : public ToolChain {
return llvm::DebuggerKind::DBX;
}
+ path_list getArchSpecificLibPaths() const override { return path_list(); };
+
protected:
Tool *buildAssembler() const override;
Tool *buildLinker() const override;
>From 60b1ea64448839e50c11f83e4ea9850cc918b033 Mon Sep 17 00:00:00 2001
From: Daniel Chen <cdchen at ca.ibm.com>
Date: Mon, 28 Apr 2025 15:41:02 -0400
Subject: [PATCH 3/3] To address review comments and added a test.
---
clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +-
flang/test/Driver/flang-ld-powerpc.f90 | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 63066d461eaa8..0406142fa916b 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1252,7 +1252,7 @@ void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args,
options::OPT_fno_rtlib_add_rpath, false))
return;
- if (TC.getTriple().isOSAIX()) // AIX doesn't support -rpath option.
+ if (TC.getTriple().isOSAIX()) // TODO: AIX doesn't support -rpath option.
return;
SmallVector<std::string> CandidateRPaths(TC.getArchSpecificLibPaths());
diff --git a/flang/test/Driver/flang-ld-powerpc.f90 b/flang/test/Driver/flang-ld-powerpc.f90
index a58cb1629cadc..5328077ac21af 100644
--- a/flang/test/Driver/flang-ld-powerpc.f90
+++ b/flang/test/Driver/flang-ld-powerpc.f90
@@ -23,6 +23,7 @@
! AIX64-LD-PER-TARGET-DEFAULT-SAME: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}powerpc64-ibm-aix{{/|\\\\}}libflang_rt.runtime.a"
! AIX64-LD-PER-TARGET-DEFAULT-SAME: "-lm"
! AIX64-LD-PER-TARGET-DEFAULT-SAME: "-lpthread"
+! AIX64-LD-PER-TARGET-DEFAULT-NOT: "-L/[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}powerpc64-ibm-aix"
! Check powerpc64-ibm-aix 64-bit linking to static flang-rt by option
More information about the cfe-commits
mailing list