-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[LLD][ELF] ignore ".so" in search path when relocatable set #94965
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
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-lld-elf @llvm/pr-subscribers-lld Author: Reno Dakota (paparodeo) Changescloses: #94958 fixes:
when both libtest.a and libtest.so exist in the search path test:
Full diff: https://github.com/llvm/llvm-project/pull/94965.diff 1 Files Affected:
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"))
|
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 ```
You need to turn off the hidden email for your contribution to be accepted The word after the tags ("[LLD][ELF]") are usually capitalized. "Ignore " I'd not use "fixes". I'd say that GNU ld does XXXX and we decide to follow suite. |
closes: #94958
fixes:
when both libtest.a and libtest.so exist in the search path
test: