[PATCH] D88054: [lld-macho] handle options -search_paths_first, -search_dylibs_first

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 09:39:00 PDT 2020


int3 added inline comments.


================
Comment at: lld/MachO/Driver.cpp:107
 static Optional<std::string> findLibrary(StringRef name) {
-  llvm::SmallString<261> location;
-  for (StringRef dir : config->librarySearchPaths) {
-      location = dir;
-      path::append(location, Twine("lib") + name);
-      if (Optional<std::string> path =
-              findWithExtension(location, {".tbd", ".dylib", ".a"}))
-        return path;
+  if (config->searchDylibsFirst) {
+    return findAlongPathsWithExtensions(name, {".tbd", ".dylib"});
----------------
at some point we should create a `LinkerDriver` class like in lld-ELF, then we can move driver-only options there


================
Comment at: lld/MachO/Driver.cpp:108
+  if (config->searchDylibsFirst) {
+    return findAlongPathsWithExtensions(name, {".tbd", ".dylib"});
+    return findAlongPathsWithExtensions(name, {".a"});
----------------
this should probably be an `if` instead of a `return`


================
Comment at: lld/test/MachO/link-search-order.s:26-28
+# PATHS-FIRST: @executable_path/libhello.dylib
+# PATHS-FIRST-NOT: @executable_path/libgoodbye.dylib
+# PATHS-FIRST: /usr/lib/libSystem.B.dylib
----------------
nit: align the right column


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88054/new/

https://reviews.llvm.org/D88054



More information about the llvm-commits mailing list