This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Handle framework search path, alongside library search path
ClosedPublic

Authored by gkm on May 27 2020, 5:05 PM.

Details

Summary

Add front-end support for lld::macho::Configuration::frameworkSearchPath.

Depends on D80582.

Diff Detail

Event Timeline

gkm created this revision.May 27 2020, 5:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2020, 5:05 PM
int3 added inline comments.May 27 2020, 5:49 PM
lld/MachO/Config.h
33

maybe add a TODO to indicate this isn't currently used

lld/MachO/Driver.cpp
114

not a big deal, but how about erasing the invalid paths from the list?

though if we aren't doing that we should take paths by const ref at least

lld/test/MachO/search-paths.test
18

nit: do we really need 8 paths? wouldn't a test with one or two library/framework paths respectively be sufficient?

gkm marked 3 inline comments as done.May 27 2020, 6:31 PM
gkm added inline comments.
lld/MachO/Config.h
33

Si, señor

lld/MachO/Driver.cpp
114

You are quite correct that it is bone-headed to keep excreta in the search path.

lld/test/MachO/search-paths.test
18

I got kinda carried away. I will show more restraint ...

gkm marked an inline comment as done.May 27 2020, 7:56 PM
gkm added inline comments.
lld/MachO/Driver.cpp
114

You are quite correct that it is bone-headed to keep excreta in the search path. ld64 removes bogus paths.

Problem: in a Linux-hosted environment, the Appleish /Library/Frameworks and /System/Library/Frameworks do not exist. There is no benefit to keeping them, but issuing warnings about them seems rude. Moreover, there will be host-OS-specific deviation in expected test results. How do we handle that? There must be other corners of the toolchain that encounter these problems. I will dig.

gkm updated this revision to Diff 266763.May 28 2020, 12:56 AM
  • Use system library and frameworks search paths only Darwin hosts
  • Only push good directories onto library and frameworks search paths
  • Make better & simpler tests
int3 added inline comments.May 28 2020, 5:25 PM
lld/MachO/Driver.cpp
363–365

this seems reasonable to me (and it looks like lld-ELF has isOS checks too) but cc @MaskRay @ruiu just in case

370

would StringRef work here instead of std::string?

gkm updated this revision to Diff 267102.May 28 2020, 6:08 PM

rebase

gkm edited the summary of this revision. (Show Details)May 28 2020, 6:09 PM
int3 accepted this revision.Jun 2 2020, 3:56 PM
This revision is now accepted and ready to land.Jun 2 2020, 3:56 PM
gkm marked 5 inline comments as done.Jun 15 2020, 11:06 PM
gkm added inline comments.
lld/MachO/Driver.cpp
114

I predicate Frameworks paths on host OS = Darwin: Triple(sys::getProcessTriple()).isOSDarwin().

gkm updated this revision to Diff 270968.Jun 15 2020, 11:09 PM
  • incorporate review feedback
int3 added a comment.Jun 15 2020, 11:37 PM

minor nit, I'm fine if you prefer to keep things the way they are right now though

lld/MachO/Driver.cpp
125–157

nit: could we factor out the common logic into a helper function, something like getSearchPaths(const std::vector<StringRef>& argPaths, const std::vector<StringRef>& sysDefaultPaths)?

gkm updated this revision to Diff 271521.Jun 17 2020, 4:40 PM
  • factorcommon code into getSearchPaths()
gkm updated this revision to Diff 271524.Jun 17 2020, 4:45 PM
  • swap args of getLibrarySearchPaths() and getFrameworkSearchPaths() to match getSearchPaths()
Harbormaster completed remote builds in B60735: Diff 271524.
int3 added inline comments.Jun 17 2020, 8:10 PM
lld/MachO/Driver.cpp
114–131

nit: I think these make more sense as plain StringRefs instead of StringRef & since a ref-of-ref doesn't really seem useful

143

nit: this can just a ctor call instead of an assignment

(actually the local variable itself isn't necessary if we take the parameter by const ref)

gkm marked an inline comment as done.Jun 17 2020, 8:45 PM
gkm added inline comments.
lld/MachO/Driver.cpp
143

What is the syntax for eliding the local variable?

int3 added inline comments.Jun 17 2020, 8:46 PM
lld/MachO/Driver.cpp
143

ah, it looks like SmallVectorImpl doesn't have a ctor that takes an initializer list, but making the parameter a const SmallVectorImpl<StringRef, 2> & works

int3 added inline comments.Jun 17 2020, 8:52 PM
lld/MachO/Driver.cpp
143

Sorry, I meant const SmallVector<StringRef, 2> &

This revision was automatically updated to reflect the committed changes.