This is an archive of the discontinued LLVM Phabricator instance.

[lld/mac] Add --reproduce option
ClosedPublic

Authored by thakis on Nov 28 2020, 7:45 PM.

Details

Summary

This adds support for ld.lld's --reproduce / lld-link's /reproduce:
flag to the MachO port. This flag can be added to a link command
to make the link write a tar file containing all inputs to the link
and a response file containing the link command. This can be used
to reproduce the link on another machine, which is useful for sharing
bug report inputs or performance test loads.

Since the linker is usually called through the clang driver and
adding linker flags can be a bit cumbersome, setting the env var
LLD_REPRODUCE=foo.tar triggers the feature as well.

The file response.txt in the archive can be used with
ld64.lld.darwinnew $(cat response.txt) as long as the contents are
smaller than the command-line limit, or with `ld64.lld.darwinnew
@response.txt` once D92149 is in.

The support in this patch is sufficient to create a tar file for
Chromium's base_unittests that can link after unpacking on a different
machine.

Diff Detail

Event Timeline

thakis created this revision.Nov 28 2020, 7:45 PM
thakis requested review of this revision.Nov 28 2020, 7:45 PM
thakis added inline comments.
lld/Common/Reproduce.cpp
61

(Turns out neither ELF nor COFF ports have MultiArg<> flags. Covered by the -platform_version flag in the test.)

int3 accepted this revision.Nov 29 2020, 9:41 PM

lgtm

lld/Common/Reproduce.cpp
61
lld/MachO/DriverUtils.cpp
118
lld/MachO/InputFiles.h
40
lld/test/MachO/reproduce.s
33

nit: align with previous line

This revision is now accepted and ready to land.Nov 29 2020, 9:41 PM
thakis marked 3 inline comments as done.Nov 30 2020, 5:39 AM

Thanks!

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald Transcript