This is an archive of the discontinued LLVM Phabricator instance.

[lld/mac] Always reference dyld_stub_binder when linked with libSystem
ClosedPublic

Authored by thakis on Jul 11 2021, 10:20 AM.

Details

Summary

lld currently only references dyld_stub_binder when it's needed.
ld64 always references it when libSystem is linked.
Match ld64.

The (somewhat lame) motivation is that nm on a binary without any
export writes a "no symbols" warning to stderr, and this change makes
it so that every binary in practice has at least a reference to
dyld_stub_binder, which suppresses that.

Every "real" output file will reference dyld_stub_binder, so most
of the time this shouldn't make much of a difference. And if you
really don't want to have this reference for whatever reason, you
can stop passing -lSystem, like you have to for ld64 anyways.

(After linking any dylib, we dump the exported list of symbols to
a txt file with nm and only relink downstream deps if that txt
file changes. A nicer fix is to make lld optionally write .tbd files
with the public interface of a linked dylib and use that instead,
but for now the txt files are what we do.)

Diff Detail

Event Timeline

thakis created this revision.Jul 11 2021, 10:20 AM
Herald added a reviewer: gkm. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
thakis requested review of this revision.Jul 11 2021, 10:20 AM
int3 accepted this revision.Jul 11 2021, 10:28 AM
int3 added inline comments.
lld/MachO/Driver.cpp
1049

can we make it clear that this isn't needed for correctness (as far as we know)?

This revision is now accepted and ready to land.Jul 11 2021, 10:28 AM
thakis marked an inline comment as done.Jul 11 2021, 10:36 AM

Thanks!

This revision was landed with ongoing or failed builds.Jul 11 2021, 10:38 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2021, 10:38 AM