[Lldb-commits] [lld] [llvm] [lldb] [compiler-rt] [libcxx] [lld-macho] Find objects in library search path (PR #78628)

via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 18 18:28:35 PST 2024


https://github.com/OldWorldOrdr updated https://github.com/llvm/llvm-project/pull/78628

>From e73fc2d0263e9e601f2964a90cfe347e8d2bb87c Mon Sep 17 00:00:00 2001
From: OldWorldOrdr <joey.t.reinhart at gmail.com>
Date: Thu, 18 Jan 2024 16:20:52 -0500
Subject: [PATCH 1/2] [lld-macho] Find objects in library search path

---
 lld/MachO/Driver.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 401459a054394e..f04165f5c02615 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -95,11 +95,16 @@ static std::optional<StringRef> findLibrary(StringRef name) {
               findPathCombination("lib" + name, config->librarySearchPaths,
                                   {".tbd", ".dylib", ".so"}))
         return path;
-      return findPathCombination("lib" + name, config->librarySearchPaths,
-                                 {".a"});
+      else if (std::optional<StringRef> path = findPathCombination(
+                   "lib" + name, config->librarySearchPaths, {".a"}))
+        return path;
+      return findPathCombination(name, config->librarySearchPaths, {""});
     }
-    return findPathCombination("lib" + name, config->librarySearchPaths,
-                               {".tbd", ".dylib", ".so", ".a"});
+    if (std::optional<StringRef> path =
+            findPathCombination("lib" + name, config->librarySearchPaths,
+                                {".tbd", ".dylib", ".so", ".a"}))
+      return path;
+    return findPathCombination(name, config->librarySearchPaths, {""});
   };
 
   std::optional<StringRef> path = doFind();

>From 004fd9ae7e96e74c4bc1de811505d777e860c721 Mon Sep 17 00:00:00 2001
From: OldWorldOrdr <joey.t.reinhart at gmail.com>
Date: Thu, 18 Jan 2024 21:16:57 -0500
Subject: [PATCH 2/2] [lld-macho] find objects in library search path version 2

---
 lld/MachO/Driver.cpp | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index f04165f5c02615..3fd8ca21ac533b 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -90,21 +90,18 @@ static std::optional<StringRef> findLibrary(StringRef name) {
     return entry->second;
 
   auto doFind = [&] {
+    if (name.ends_with(".o"))
+      return findPathCombination(name, config->librarySearchPaths, {});
     if (config->searchDylibsFirst) {
       if (std::optional<StringRef> path =
               findPathCombination("lib" + name, config->librarySearchPaths,
                                   {".tbd", ".dylib", ".so"}))
         return path;
-      else if (std::optional<StringRef> path = findPathCombination(
-                   "lib" + name, config->librarySearchPaths, {".a"}))
-        return path;
-      return findPathCombination(name, config->librarySearchPaths, {""});
+      return findPathCombination("lib" + name, config->librarySearchPaths,
+                                 {".a"});
     }
-    if (std::optional<StringRef> path =
-            findPathCombination("lib" + name, config->librarySearchPaths,
-                                {".tbd", ".dylib", ".so", ".a"}))
-      return path;
-    return findPathCombination(name, config->librarySearchPaths, {""});
+    return findPathCombination("lib" + name, config->librarySearchPaths,
+                               {".tbd", ".dylib", ".so", ".a"});
   };
 
   std::optional<StringRef> path = doFind();



More information about the lldb-commits mailing list