Skip to content

[NFC][RISCV] Simplify the dynamic linker construction logic #97383

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

Conversation

wangpc-pp
Copy link
Contributor

The format of dynamic linker is ld-linux-{arch}-{abi}.so.1, so
we can just get the arch name from arch type.

harishch4 and others added 2 commits July 2, 2024 13:34
Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Jul 2, 2024
@wangpc-pp wangpc-pp requested a review from MaskRay July 2, 2024 05:34
@llvmbot
Copy link
Member

llvmbot commented Jul 2, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Pengcheng Wang (wangpc-pp)

Changes

The format of dynamic linker is ld-linux-{arch}-{abi}.so.1, so
we can just get the arch name from arch type.


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

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Linux.cpp (+3-7)
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 49e029e7c9ab7..98a878e1d764d 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -568,16 +568,12 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
     Loader =
         (tools::ppc::hasPPCAbiArg(Args, "elfv1")) ? "ld64.so.1" : "ld64.so.2";
     break;
-  case llvm::Triple::riscv32: {
-    StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
-    LibDir = "lib";
-    Loader = ("ld-linux-riscv32-" + ABIName + ".so.1").str();
-    break;
-  }
+  case llvm::Triple::riscv32:
   case llvm::Triple::riscv64: {
+    StringRef ArchName = llvm::Triple::getArchTypeName(Arch);
     StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
     LibDir = "lib";
-    Loader = ("ld-linux-riscv64-" + ABIName + ".so.1").str();
+    Loader = ("ld-linux-" + ArchName + "-" + ABIName + ".so.1").str();
     break;
   }
   case llvm::Triple::sparc:

@wangpc-pp wangpc-pp requested review from asb and kito-cheng July 2, 2024 05:35
Created using spr 1.3.6-beta.1
@wangpc-pp wangpc-pp requested a review from JDevlieghere as a code owner July 2, 2024 06:41
@wangpc-pp wangpc-pp changed the base branch from users/wangpc-pp/spr/main.nfcriscv-simplify-the-dynamic-linker-construction-logic to main July 2, 2024 06:41
@wangpc-pp wangpc-pp merged commit 4468c3d into main Jul 2, 2024
2 of 3 checks passed
@wangpc-pp wangpc-pp deleted the users/wangpc-pp/spr/nfcriscv-simplify-the-dynamic-linker-construction-logic branch July 2, 2024 06:41
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
The format of dynamic linker is `ld-linux-{arch}-{abi}.so.1`, so
we can just get the arch name from arch type.

Reviewers: asb, kito-cheng, MaskRay

Reviewed By: MaskRay

Pull Request: llvm#97383
kbluck pushed a commit to kbluck/llvm-project that referenced this pull request Jul 6, 2024
The format of dynamic linker is `ld-linux-{arch}-{abi}.so.1`, so
we can just get the arch name from arch type.

Reviewers: asb, kito-cheng, MaskRay

Reviewed By: MaskRay

Pull Request: llvm#97383
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants