[lld] [lld-macho] Find objects in library search path (PR #78628)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 13:26:18 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld-macho

Author: None (OldWorldOrdr)

<details>
<summary>Changes</summary>

Find object files in library search path just like Apple's linker, this makes building with some older MacOS SDKs easier since clang runs with `-lcrt1.10.6.o`

---
Full diff: https://github.com/llvm/llvm-project/pull/78628.diff


1 Files Affected:

- (modified) lld/MachO/Driver.cpp (+9-4) 


``````````diff
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();

``````````

</details>


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


More information about the llvm-commits mailing list