[PATCH] D118498: [ELF] Change the search order for dependent libraries
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 28 20:46:08 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71dcd9bd049e: [ELF] Change the search order for dependent libraries (authored by phosek).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118498/new/
https://reviews.llvm.org/D118498
Files:
lld/ELF/InputFiles.cpp
lld/test/ELF/deplibs.s
Index: lld/test/ELF/deplibs.s
===================================================================
--- lld/test/ELF/deplibs.s
+++ lld/test/ELF/deplibs.s
@@ -35,23 +35,24 @@
# CMDLINE-NEXT: {{^libcmdline\.a}}
## LLD tries to resolve dependent library specifiers in the following order:
-## 1) The literal name in the current working directory.
-## 2) The literal name in a library search path.
-## 3) The name, prefixed with "lib" and suffixed with ".so" or ".a" in a
+## 1) The name, prefixed with "lib" and suffixed with ".so" or ".a" in a
## library search path. This means that a directive of "foo.a" could lead
## to a library named "libfoo.a.a" being linked in.
+## 2) The literal name in a library search path.
+## 3) The literal name in the current working directory.
## When using library search paths for dependent libraries, LLD follows the same
## rules as for libraries specified on the command line.
# RUN: cp %t.dir/foo.a %t.cwd/foo.a
# RUN: cp %t.dir/foo.a %t.dir/libfoo.a.a
+
# RUN: ld.lld %t.o -o /dev/null -L %t.dir --trace 2>&1 | \
-# RUN: FileCheck %s -DOBJ=%t.o -DDIR=%t.dir --check-prefix=CWD \
+# RUN: FileCheck %s -DOBJ=%t.o -DDIR=%t.dir --check-prefix=LIBA-DIR \
# RUN: --implicit-check-not=foo.a --implicit-check-not=libbar.so
-# CWD: [[OBJ]]
-# CWD-NEXT: {{^foo\.a}}
+# LIBA-DIR: [[OBJ]]
+# LIBA-DIR-NEXT: [[DIR]]{{[\\/]}}libfoo.a.a
-# RUN: rm %t.cwd/foo.a
+# RUN: rm %t.dir/libfoo.a.a
# RUN: ld.lld %t.o -o /dev/null -L %t.dir --trace 2>&1 | \
# RUN: FileCheck %s -DOBJ=%t.o -DDIR=%t.dir --check-prefix=PLAIN-DIR \
# RUN: --implicit-check-not=foo.a --implicit-check-not=libbar.so
@@ -61,11 +62,11 @@
# RUN: rm %t.dir/foo.a
# RUN: ld.lld %t.o -o /dev/null -L %t.dir --trace 2>&1 | \
-# RUN: FileCheck %s -DOBJ=%t.o -DDIR=%t.dir --check-prefix=LIBA-DIR \
+# RUN: FileCheck %s -DOBJ=%t.o -DDIR=%t.dir --check-prefix=CWD \
# RUN: --implicit-check-not=foo.a --implicit-check-not=libbar.so
-# LIBA-DIR: [[OBJ]]
-# LIBA-DIR-NEXT: [[DIR]]{{[\\/]}}libfoo.a.a
+# CWD: [[OBJ]]
+# CWD-NEXT: {{^foo\.a}}
call foo
.section ".deplibs","MS", at llvm_dependent_libraries,1
Index: lld/ELF/InputFiles.cpp
===================================================================
--- lld/ELF/InputFiles.cpp
+++ lld/ELF/InputFiles.cpp
@@ -490,12 +490,12 @@
static void addDependentLibrary(StringRef specifier, const InputFile *f) {
if (!config->dependentLibraries)
return;
- if (fs::exists(specifier))
- driver->addFile(specifier, /*withLOption=*/false);
- else if (Optional<std::string> s = findFromSearchPaths(specifier))
+ if (Optional<std::string> s = searchLibraryBaseName(specifier))
driver->addFile(*s, /*withLOption=*/true);
- else if (Optional<std::string> s = searchLibraryBaseName(specifier))
+ else if (Optional<std::string> s = findFromSearchPaths(specifier))
driver->addFile(*s, /*withLOption=*/true);
+ else if (fs::exists(specifier))
+ driver->addFile(specifier, /*withLOption=*/false);
else
error(toString(f) +
": unable to find library from dependent library specifier: " +
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118498.404225.patch
Type: text/x-patch
Size: 3170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220129/0da26e1a/attachment.bin>
More information about the llvm-commits
mailing list