Skip to content

Conversation

@DanielCChen
Copy link
Contributor

@DanielCChen DanielCChen commented Apr 6, 2025

addArchSpecificRPath should immediately return for AIX as AIX doesn't support rpath option.
getArchSpecificLibPaths should return as well as we don't want -L/ArchSepcificLibPaths sent to the linker on AIX.

@DanielCChen DanielCChen requested a review from daltenty April 6, 2025 03:28
@DanielCChen DanielCChen self-assigned this Apr 6, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Apr 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 6, 2025

@llvm/pr-subscribers-flang-driver
@llvm/pr-subscribers-backend-powerpc
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Daniel Chen (DanielCChen)

Changes

addArchSpecificRPath shoudl immediately return for AIX as AIX doesn't support rpath option.
getArchSpecificLibPaths also needs to get the triple without the OS version on AIX.


Full diff: https://github.com/llvm/llvm-project/pull/134520.diff

2 Files Affected:

  • (modified) clang/lib/Driver/ToolChain.cpp (+6-1)
  • (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+3)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 36d0ae34dec86..dd3cc33b5a233 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -999,7 +999,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 ddeadff8f6dfb..e5d221cbf8b51 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);

@DanielCChen DanielCChen changed the title [driver] return in addArchSpecificRPath for AIX and also get the triple without the OS on AIX. [driver] return in addArchSpecificRPath for AIX and also get the triple without the OS on AIX in getArchSpecificLibPaths. Apr 6, 2025
@DanielCChen DanielCChen force-pushed the daniel_AIX_not_support_rpath branch from a3583c5 to 1f6eecb Compare April 15, 2025 19:39
@DanielCChen DanielCChen changed the title [driver] return in addArchSpecificRPath for AIX and also get the triple without the OS on AIX in getArchSpecificLibPaths. [driver] return immediately in addArchSpecificRPath and getArchSpecificLibPaths on AIX Apr 16, 2025
Copy link
Member

@daltenty daltenty left a comment

Choose a reason for hiding this comment

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

Change LGTM, but this really ought to have a test (or affect some existing test somehow)

@DanielCChen
Copy link
Contributor Author

Change LGTM, but this really ought to have a test (or affect some existing test somehow)

Agreed. Will add a test.

@DanielCChen DanielCChen force-pushed the daniel_AIX_not_support_rpath branch from f1c7f40 to 64e5b60 Compare April 28, 2025 19:39
@llvmbot llvmbot added flang:driver flang Flang issues not falling into any other category labels Apr 28, 2025
@DanielCChen DanielCChen merged commit 3f80359 into llvm:main Apr 29, 2025
13 checks passed
@DanielCChen DanielCChen deleted the daniel_AIX_not_support_rpath branch April 29, 2025 14:39
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…cificLibPaths` on AIX (llvm#134520)

`addArchSpecificRPath` should immediately return for AIX as AIX doesn't
support `rpath` option.
`getArchSpecificLibPaths` should return as well as we don't want
`-L/ArchSepcificLibPaths` sent to the linker on AIX.
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
…cificLibPaths` on AIX (llvm#134520)

`addArchSpecificRPath` should immediately return for AIX as AIX doesn't
support `rpath` option.
`getArchSpecificLibPaths` should return as well as we don't want
`-L/ArchSepcificLibPaths` sent to the linker on AIX.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:PowerPC clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants