This is an archive of the discontinued LLVM Phabricator instance.

lld: add basic static library search
ClosedPublic

Authored by compnerd on Jun 3 2020, 11:58 AM.

Details

Reviewers
smeenai
int3
Group Reviewers
Restricted Project
Summary

This is a very basic static library search addition. This is the pre-Xcode4 behaviour of searching all paths for the shared version before searching for the static version of the library. This behaviour is supposed to be inverted with -search_paths_first being the default. This adds the library search with the intention of providing the setup to merge the paths into one path and making it controllable by OPT_search_paths_first.

Diff Detail

Event Timeline

compnerd created this revision.Jun 3 2020, 11:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2020, 11:58 AM
int3 added a reviewer: Restricted Project.Jun 3 2020, 12:13 PM

I do have the follow up fix that this really begs for. I figure that doing it in slower incremental steps is easier, but Im okay with either doing it in two steps or keeping it a single step.

int3 marked an inline comment as done.Jun 3 2020, 3:27 PM

Doing it in two steps is fine :)

lld/test/MachO/static-link.s
3–5

The inclusion of a dylib symbol here seems unrelated to the static linking behavior. Let's try to keep the tests as targeted as possible. Also, static GOTPCREL relocations won't work correctly before D80857: [lld-macho] Handle GOT relocations of non-dylib symbols lands. I think we should just do normal symbol lookup (i.e. X86_64_RELOC_SIGNED), and use llvm-objdump --section-headers --syms -d to check that the resulting code has the correct relocated addresses. relocation.s should be a good reference.

10

we usually put this as the first line in the file

compnerd updated this revision to Diff 268324.Jun 3 2020, 3:56 PM
compnerd marked an inline comment as done.

Update test

int3 accepted this revision.Jun 3 2020, 4:10 PM

LGTM, thanks!

lld/test/MachO/static-link.s
25–30

nit: we usually put these right after their respective FileCheck invocation line (so after line 11 in this file)

This revision is now accepted and ready to land.Jun 3 2020, 4:10 PM
int3 added inline comments.Jun 3 2020, 4:24 PM
lld/test/MachO/static-link.s
17–20

one more nit: would be nice to clean up the indentation of these comments

compnerd marked an inline comment as done.Jun 3 2020, 4:30 PM
compnerd added inline comments.
lld/test/MachO/static-link.s
17–20

Oh, they are just aligned (with hard tabs as is the general pattern with assembly files), I can change them to be indented with space instead.

25–30

Hmm, most of LLVM IIRC also tends to just group the expectations and the RUN lines so that its easier to understand the full flow of the test.

gkm added a subscriber: gkm.Jun 3 2020, 6:22 PM
gkm added inline comments.
lld/MachO/Driver.cpp
299–302

You have implemented old -search_dylibs_first semantics. The default since Xcode 4 is -search_paths_first

Could you upload with full context? It's hard to read this as-is.

Oops, wrong one.

gkm added inline comments.Jun 3 2020, 6:35 PM
lld/MachO/Driver.cpp
299–302

Nevermind. I see D81124 fixes it.