This is an archive of the discontinued LLVM Phabricator instance.

Add support for -export_dynamic cmdline option
ClosedPublic

Authored by pete on Jan 8 2016, 11:40 PM.

Details

Summary

Hi Nick, Lang

This adds support for the -export_dynamic command line option. In ld64, this prevents global symbols from being dead stripped in executables and dylibs.

I've added tests for all the combinations of executable/dylib/relocatable to make sure we match that behaviour.

Thanks,
Pete

Diff Detail

Repository
rL LLVM

Event Timeline

pete updated this revision to Diff 44402.Jan 8 2016, 11:40 PM
pete retitled this revision from to Add support for -export_dynamic cmdline option.
pete updated this object.
pete added reviewers: kledzik, lhames.
pete added a project: lld.
pete added a subscriber: llvm-commits.
lhames accepted this revision.Jan 20 2016, 11:10 PM
lhames edited edge metadata.

Huh. ld64's man page only describes -export_dynamic as a modifier for dead-stripping during LTO, but it does seem to override -dead_strip for non-LTO cases too.

As far as I can tell your implementation matches ld64's behaviour. You might want to add a test case where the -dead_strip argument is after -export_dynamic to verify that -export_dynamic still takes precedence.

We may also want to talk to Nick to verify this behaviour and potentially update ld64's man-page.

LGTM.

  • Lang.
This revision is now accepted and ready to land.Jan 20 2016, 11:10 PM
This revision was automatically updated to reflect the committed changes.
pete added a comment.Jan 22 2016, 1:18 PM

As far as I can tell your implementation matches ld64's behaviour. You might want to add a test case where the -dead_strip argument is after -export_dynamic to verify that -export_dynamic still takes precedence.

Done. I've added another run line which handles this case.

We may also want to talk to Nick to verify this behaviour and potentially update ld64's man-page.

Will do. I'll double check that this is ok.

Thanks for the review.
Pete