[lld] [LLD][ELF] ignore ".so" when relocatable set (PR #94965)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 10 04:37:51 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-elf
@llvm/pr-subscribers-lld
Author: Reno Dakota (paparodeo)
<details>
<summary>Changes</summary>
closes: https://github.com/llvm/llvm-project/issues/94958
fixes:
```
$ lld -r test.o -o test -L./libs -ltest
lld: error: attempted static link of dynamic object ./libs/libtest.so
```
when both libtest.a and libtest.so exist in the search path
test:
```
echo void empty(void) { } > test.c
clang test.c -c
ar rc libs/libtest.a test.o
clang test.c --shared -o libs/libtest.so
lld -r test.o -o test -L./libs -ltest
```
---
Full diff: https://github.com/llvm/llvm-project/pull/94965.diff
1 Files Affected:
- (modified) lld/ELF/DriverUtils.cpp (+1-1)
``````````diff
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index ac74604408152..77214aa362459 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -234,7 +234,7 @@ std::optional<std::string> elf::findFromSearchPaths(StringRef path) {
// search paths.
std::optional<std::string> elf::searchLibraryBaseName(StringRef name) {
for (StringRef dir : config->searchPaths) {
- if (!config->isStatic)
+ if (!(config->isStatic || config->relocatable))
if (std::optional<std::string> s = findFile(dir, "lib" + name + ".so"))
return s;
if (std::optional<std::string> s = findFile(dir, "lib" + name + ".a"))
``````````
</details>
https://github.com/llvm/llvm-project/pull/94965
More information about the llvm-commits
mailing list