This is an archive of the discontinued LLVM Phabricator instance.

COFF: Implement /reproduce flag.
ClosedPublic

Authored by pcc on Jul 15 2016, 11:09 AM.

Details

Summary

This flag is similar to --reproduce in the ELF linker.

This patch implements /reproduce by moving the cpio writer and associated
utility functions to lldCore, and using that implementation in both linkers.

One COFF-specific detail is that we store the object file from which the
resource files were created in our reproducer, rather than the resource
files themselves. This allows the reproducer to be used on non-Windows
systems for example.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 64168.Jul 15 2016, 11:09 AM
pcc retitled this revision from to COFF: Implement /reproduce flag..
pcc updated this object.
pcc added reviewers: ruiu, compnerd.
pcc added a subscriber: llvm-commits.
compnerd added inline comments.Jul 15 2016, 11:12 AM
COFF/Driver.cpp
315 ↗(On Diff #64168)

Unnecessary braces

COFF/Options.td
37 ↗(On Diff #64168)

We should use the link flag here. /linkrepro:<directory for staging>

ruiu added inline comments.Jul 15 2016, 11:16 AM
ELF/Driver.cpp
272–273 ↗(On Diff #64168)

check does not return if there's an error, but we want to return to the caller as it is not a critical error such as object file is corrupted.

lib/Core/Reproduce.cpp
81 ↗(On Diff #64168)

How can it fail?

pcc updated this revision to Diff 64171.Jul 15 2016, 11:19 AM
pcc marked an inline comment as done.
  • Remove braces and fix merge error
COFF/Options.td
37 ↗(On Diff #64168)

Even though this flag has different semantics to the link.exe flag?

ruiu added inline comments.Jul 15 2016, 11:21 AM
COFF/Options.td
37 ↗(On Diff #64171)

I think I prefer not use the same option name as we always create an archive whether the link succeeded or not.

pcc updated this revision to Diff 64175.Jul 15 2016, 11:35 AM
  • Fix error handling
pcc marked an inline comment as done.Jul 15 2016, 11:35 AM
pcc added inline comments.
lib/Core/Reproduce.cpp
82 ↗(On Diff #64171)
ruiu added inline comments.Jul 15 2016, 11:50 AM
lib/Core/Reproduce.cpp
83 ↗(On Diff #64175)

It seems that if getcwd (or equivalent) failed, the system is really broken and can't do anything sane. Should we just swallow an error and returns the original string in case of an error?

ruiu added inline comments.Jul 15 2016, 11:56 AM
COFF/Driver.cpp
313 ↗(On Diff #64171)

You might be able to remote Twine().

COFF/Error.h
36 ↗(On Diff #64171)

Swap the condition (if (!EO)) for the consistency with other functions in this file.

COFF/InputFiles.cpp
99 ↗(On Diff #64171)

Remove Twine?

ELF/Driver.cpp
273 ↗(On Diff #64171)

Twine?

compnerd added inline comments.Jul 15 2016, 12:27 PM
COFF/Options.td
37 ↗(On Diff #64175)

I did try this. It seems that I was mistaken and link does *always* populate the directory. If it fails really early like in the command line parsing, it will only populate link.rsp, but it does populate it. So, I think that the behaviour matches what we currently have in lld, and we should be able to use the same name.

pcc updated this revision to Diff 65456.Jul 25 2016, 6:34 PM
pcc marked 4 inline comments as done.
  • Address review comments
pcc added inline comments.Jul 25 2016, 6:37 PM
COFF/Options.td
37 ↗(On Diff #64175)

Okay, this now uses the /linkrepro flag. We create a file named "repro.cpio" in the given directory.

lib/Core/Reproduce.cpp
83 ↗(On Diff #64175)

Seems reasonable enough to me, done.

ruiu accepted this revision.Jul 25 2016, 6:43 PM
ruiu edited edge metadata.

LGTM

COFF/Driver.cpp
318 ↗(On Diff #65456)

/linkrepro

COFF/Driver.h
73 ↗(On Diff #65456)

for /linkrepro

This revision is now accepted and ready to land.Jul 25 2016, 6:43 PM
This revision was automatically updated to reflect the committed changes.