This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Implement -load_hidden
ClosedPublic

Authored by BertalanD on Jul 25 2022, 3:17 AM.

Details

Summary

This flag was introduced in ld64-609. It instructs the linker to link to
a static library while treating its symbols as if they had hidden
visibility. This is useful when building a dylib that links to static
libraries but we don't want the symbols from those to be exported.

Closes https://github.com/llvm/llvm-project/issues/51505

Diff Detail

Event Timeline

BertalanD created this revision.Jul 25 2022, 3:17 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 25 2022, 3:17 AM
BertalanD requested review of this revision.Jul 25 2022, 3:17 AM
thakis accepted this revision.Jul 25 2022, 6:23 AM
thakis added a subscriber: thakis.

This is annoyingly invasive, but I can't think of a better way.

lld/test/MachO/load-hidden.s
15

nit: spell out "without"

51

good tests!

This revision is now accepted and ready to land.Jul 25 2022, 6:23 AM

This is annoyingly invasive, but I can't think of a better way.

I completely agree. I've been sitting on this one for a while, hoping that I could come up with a nicer solution. We could avoid having to pass forceHidden to all the helper functions by making them methods of ObjFile, but that would be a similarly invasive diff, and the changes to the {Archive,Obj,Bitcode}File ctors would still have to stay.

int3 accepted this revision.Jul 25 2022, 7:36 AM
int3 added a subscriber: int3.

We could possibly pass ArchiveFile * into the BitcodeFile and ObjFile constructors and have that take the place of archiveName + forceHidden. But that's a marginal improvement (saving one parameter in the ctors); I don't see a way around the rest of the parameter passing. I'm good with this as-is. Thanks!

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 25 2022, 11:59 AM

Added handling for bitcode files; this will fix the bot breakage that was due to BitcodeFile::forceHidden being unused.

BertalanD reopened this revision.Jul 25 2022, 12:46 PM
This revision is now accepted and ready to land.Jul 25 2022, 12:46 PM
thakis accepted this revision.Jul 25 2022, 12:52 PM

still lg

This revision was automatically updated to reflect the committed changes.