This is an archive of the discontinued LLVM Phabricator instance.

lld: use modern library search ordering
ClosedPublic

Authored by compnerd on Jun 3 2020, 4:35 PM.

Details

Reviewers
smeenai
int3
gkm
Group Reviewers
Restricted Project
Summary

This merges the static and shared library and behaves as if
-search_paths_first was specified which is also the default beahviour
on ld64 (and now lld). Unify the paths, and use llvm::sys::path to
deal with the path to be truly agnostic to the host.

Diff Detail

Event Timeline

compnerd created this revision.Jun 3 2020, 4:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2020, 4:35 PM

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

gkm requested changes to this revision.Jun 3 2020, 7:11 PM
gkm added a subscriber: gkm.
gkm added inline comments.
lld/MachO/Driver.cpp
79

Nit: I'd rather see PATH_MAX, but literal ints like this are the norm.

85

Nit: check for fs::is_regular_file()

lld/test/MachO/link-search-order.s
17

Please add an archive that will be found, alongside the one that is shadowed by a dylib.

This revision now requires changes to proceed.Jun 3 2020, 7:11 PM
MaskRay added inline comments.
lld/MachO/Driver.cpp
79

Do we omit llvm:: for commonly used LLVM ADT/Support classes?

lld/test/MachO/link-search-order.s
12

Move it to the top

22

Looks misaligned.

You may need to convert some tabs to spaces.

compnerd marked 3 inline comments as done.Jun 4 2020, 8:38 AM
compnerd added inline comments.
lld/MachO/Driver.cpp
79

PATH_MAX is different from MAX_PATH ... 260 is the larger of the two and there is no macro to unify the two spellings on different platforms.

85

That was not checked for previously, why introduce that with this change?

lld/test/MachO/link-search-order.s
17

I think that the existing check for the static archive covers that part of the test. Arguably, because this change is about cleaning up that path, it _could_ make sense to remove the test case from the change and do the testing improvements later. What case is it that is missing testing?

compnerd updated this revision to Diff 268494.Jun 4 2020, 8:45 AM
compnerd marked 2 inline comments as done.
gkm added inline comments.Jun 4 2020, 11:44 AM
lld/MachO/Driver.cpp
79

Very well.

85

It's an opportunistic improvement: a tighter validity check.

lld/test/MachO/link-search-order.s
17

Tested:

  • use a dylib (does not shadow an archive)
  • use a dylib (shadows an archive)

Untested:

  • use an archive (not shadowed by a dylib)
compnerd marked 2 inline comments as done.Jun 4 2020, 12:23 PM
compnerd added inline comments.
lld/MachO/Driver.cpp
85

Seems better as a separate change as it technically changes the semantics.

lld/test/MachO/link-search-order.s
17

The last case already tested in a different test that I added previously.

gkm accepted this revision.Jun 4 2020, 1:22 PM
This revision is now accepted and ready to land.Jun 4 2020, 1:22 PM

You need to retain Reviewed by: and Differential Revision: to close the revision automatically when you push the commit to master.

arcfilter () {
  arc amend
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F -
}

Reviewed By: is considered important by some people (https://lists.llvm.org/pipermail/llvm-dev/2020-January/137889.html). You should keep the tag. (I started to use --date=now because some people find author date != committer date annoying. The committer date is usually what people care.))