This is an archive of the discontinued LLVM Phabricator instance.

[lld/mac] Implement -needed_framework, -needed_library, -needed-l
ClosedPublic

Authored by thakis on Jun 1 2021, 5:48 PM.

Details

Summary

These allow overriding dead_strip_dylibs.

Diff Detail

Event Timeline

thakis created this revision.Jun 1 2021, 5:48 PM
Herald added a reviewer: gkm. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: dang. · View Herald Transcript
int3 added inline comments.Jun 1 2021, 9:42 PM
lld/MachO/Driver.cpp
333–334

why not just dylibFile->forceNeeded = isNeeded? (actually same question for forceWeakImport below... and I see we don't do that if check for explicitlyLinked above). I believe addFile() returns a new instance each time, so unconditionally setting these values should be fine

thakis added a comment.Jun 2 2021, 3:42 AM

Thanks!

lld/MachO/Driver.cpp
333–334

I did it this way for consistency with forceWeakImport, but now that I think about it I think it's needed for correctness:

I believe addFile() returns a new instance each time, so unconditionally setting these values should be fine

That's not true: It always reads the file, but it then calls addDylib() which uses the dylib cache. That's important too: -needed-lFoo -reexport-lFoo marks libFoo.dylib as both needed and reexported. (…I guess I should add a test for this.)

Good point about the explicitilyLinked: I think that's wrong. If you link a dylib both explicitly (say, via an -l flag) and implicitly via LC_LINKER_COMMAND, I think the latter runs later and overwrites explicitlyLinked with false. I'll make a CL for that.

int3 accepted this revision.Jun 2 2021, 7:51 AM
int3 added inline comments.
lld/MachO/Driver.cpp
333–334

ah I see. Makes sense now!

This revision is now accepted and ready to land.Jun 2 2021, 7:51 AM
This revision was landed with ongoing or failed builds.Jun 2 2021, 8:07 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2021, 8:07 AM