This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Implement `-no_implicit_dylibs`
ClosedPublic

Authored by int3 on Dec 9 2020, 10:35 PM.

Details

Reviewers
thakis
Group Reviewers
Restricted Project
Commits
rG6a348f6158ec: [lld-macho] Implement `-no_implicit_dylibs`
Summary

Dylibs that are "public" -- i.e. top-level system libraries -- are considered
implicitly linked when another library re-exports them. That is, we should load
them & bind directly to their symbols instead of via their re-exporting
umbrella library. This diff implements that behavior by default, as well as an
opt-out flag.

In theory, this is just a performance optimization, but in practice it seems
that it's needed for correctness.

Fixes llvm.org/PR48395.

Diff Detail

Event Timeline

int3 created this revision.Dec 9 2020, 10:35 PM
int3 requested review of this revision.Dec 9 2020, 10:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2020, 10:35 PM
thakis accepted this revision.Dec 10 2020, 5:54 AM

Thanks! I'll patch this in and verify if it fixes PR48395

lld/MachO/Config.h
39

nit: Because double negation is confusing, naming booleans always for the positive variant ("enableFoo" instead of "disableFoo" etc) tends to make for more readable code. Can we name this implictDylibs? It doesn't make a huge difference for readability in this case, but not having negated booleans is a good general guideline imho.

lld/MachO/InputFiles.cpp
512

nit: isImplicitlyLinked or shouldImplicitlyLink

This revision is now accepted and ready to land.Dec 10 2020, 5:54 AM

Thanks! I'll patch this in and verify if it fixes PR48395

It does :) base_unittests now starts up fine on macOS 10.13, and llvm-objdump --macho --dylibs-used out/gnmac/base_unittests shows /usr/lib/libobjc.A.dylib (a whole bunch of times, but D93001 will fix that too).

int3 marked 2 inline comments as done.Dec 10 2020, 3:56 PM

Thanks for verifying the fix!

int3 updated this revision to Diff 311045.Dec 10 2020, 3:56 PM
int3 edited the summary of this revision. (Show Details)

rename

This revision was landed with ongoing or failed builds.Dec 10 2020, 3:58 PM
This revision was automatically updated to reflect the committed changes.