[PATCH] D109768: [lld/mac] Search .tbd before binary for framework files too

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 14 12:27:11 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGed2f0ad30719: [lld/mac] Search .tbd before binary for framework files too (authored by thakis).
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109768

Files:
  lld/MachO/DriverUtils.cpp
  lld/test/MachO/link-search-order.s


Index: lld/test/MachO/link-search-order.s
===================================================================
--- lld/test/MachO/link-search-order.s
+++ lld/test/MachO/link-search-order.s
@@ -48,6 +48,10 @@
 # RUN:     -L%tD       -L%t -lhello -lgoodbye -lSystem %t/test.o -search_dylibs_first
 # RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s
 
+################ Test that we try the tbd file before the binary for frameworks too.
+# RUN: not %lld -dylib -F %t -framework Foo -o %t --print-dylib-search \
+# RUN:     | FileCheck --check-prefix=FRAMEWORKSEARCH -DPATH=%t %s
+
 # DYLIB: @executable_path/libhello.dylib
 # DYLIB: @executable_path/libgoodbye.dylib
 # DYLIB: /usr/lib/libSystem.dylib
@@ -72,6 +76,9 @@
 # ARCHIVESEARCH:      searched [[PATH]]{{[/\\]}}libhello.dylib, found
 # ARCHIVESEARCH:      searched [[PATH]]A{{[/\\]}}libgoodbye.a, found
 
+# FRAMEWORKSEARCH:      searched [[PATH]]{{[/\\]}}Foo.framework{{[/\\]}}Foo.tbd, not found
+# FRAMEWORKSEARCH-NEXT: searched [[PATH]]{{[/\\]}}Foo.framework{{[/\\]}}Foo, not found
+
 .section __TEXT,__text
 .global _main
 
Index: lld/MachO/DriverUtils.cpp
===================================================================
--- lld/MachO/DriverUtils.cpp
+++ lld/MachO/DriverUtils.cpp
@@ -186,17 +186,17 @@
 Optional<std::string> macho::resolveDylibPath(StringRef dylibPath) {
   // TODO: if a tbd and dylib are both present, we should check to make sure
   // they are consistent.
-  bool dylibExists = fs::exists(dylibPath);
-  searchedDylib(dylibPath, dylibExists);
-  if (dylibExists)
-    return std::string(dylibPath);
-
   SmallString<261> tbdPath = dylibPath;
   path::replace_extension(tbdPath, ".tbd");
   bool tbdExists = fs::exists(tbdPath);
   searchedDylib(tbdPath, tbdExists);
   if (tbdExists)
     return std::string(tbdPath);
+
+  bool dylibExists = fs::exists(dylibPath);
+  searchedDylib(dylibPath, dylibExists);
+  if (dylibExists)
+    return std::string(dylibPath);
   return {};
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109768.372535.patch
Type: text/x-patch
Size: 2002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210914/c6f478dd/attachment.bin>


More information about the llvm-commits mailing list