Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lld/MachO/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions lld/test/MachO/link-csu-object.s
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should one of these be linked with -l instead of by path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AHH

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it in my branch but the pr is already merged

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you mind putting it in another PR? we can get it merged there. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you mind putting it in another PR? we can get it merged there. Thanks!

done #79018

# RUN: llvm-nm %t/a.out | FileCheck %s

# CHECK: _main
# CHECK: _print_hello

.globl _main
_main:
call _print_hello
ret