This is an archive of the discontinued LLVM Phabricator instance.

[lld/mac] Propagate -(un)exported_symbol(s_list) to privateExtern in Driver
ClosedPublic

Authored by thakis on May 17 2021, 6:28 PM.

Details

Summary

That way, it's done only once instead of every time shouldExportSymbol() is
called.

Possibly a bit faster:

% ministat at_main at_symtodo
x at_main
+ at_symtodo
    N           Min           Max        Median           Avg        Stddev
x  30     3.9732189      4.114846      4.024621     4.0304692   0.037022865
+  30       3.93766     4.0510042     3.9973931      3.991469   0.028472565
Difference at 95.0% confidence
        -0.0390002 +/- 0.0170714
        -0.967635% +/- 0.423559%
        (Student's t, pooled s = 0.0330256)

In other runs with n=30 it makes no perf difference, so maybe it's just noise.
But being able to quickly and conveniently answer "is this symbol exported?"
is useful for fixing PR50373 and for implementing -dead_strip, so this seems
like a good change regardless.

No behavior change.

Diff Detail

Event Timeline

thakis created this revision.May 17 2021, 6:28 PM
Herald added a reviewer: gkm. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
thakis requested review of this revision.May 17 2021, 6:28 PM
int3 accepted this revision.May 17 2021, 8:08 PM
int3 added inline comments.
lld/MachO/Driver.cpp
1197

I assume that we are handling exportedSymbols after this line so we can export/unexported synthetic symbols... do we want to have a test for this to check ld64 parity? (If you think that's too obscure to bother with that's fair too)

This revision is now accepted and ready to land.May 17 2021, 8:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2021, 4:43 AM

Thanks! Landed with the tweak you suggested on D102662

lld/MachO/Driver.cpp
1197

__mh_execute_header is the only visible synthetic symbol, so it's really just for that. ld64 does mark that symbol as internal with -Wl,-exported_symbol,_main so that's why I put this here, but adding a test for it felt a bit frivolous to me :D

thakis edited the summary of this revision. (Show Details)May 18 2021, 4:46 AM