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

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`
This commit is contained in:
OldWorldOrdr 2024-01-20 16:53:55 -05:00 committed by GitHub
parent 07b5829fca
commit 46a9135d61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -90,6 +90,10 @@ static std::optional<StringRef> findLibrary(StringRef name) {
return entry->second;
auto doFind = [&] {
// Special case for Csu support files required for Mac OS X 10.7 and older
// (crt1.o)
if (name.ends_with(".o"))
return findPathCombination(name, config->librarySearchPaths, {""});
if (config->searchDylibsFirst) {
if (std::optional<StringRef> path =
findPathCombination("lib" + name, config->librarySearchPaths,

View File

@ -0,0 +1,14 @@
# REQUIRES: x86
# RUN: mkdir -p %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s -o %t/hello.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
# RUN: %lld -L %t %t/main.o %t/hello.o -o %t/a.out
# RUN: llvm-nm %t/a.out | FileCheck %s
# CHECK: _main
# CHECK: _print_hello
.globl _main
_main:
call _print_hello
ret