ELF: Make --reproduce to produce a response file.
authorRui Ueyama <ruiu@google.com>
Sat, 30 Apr 2016 21:40:04 +0000 (21:40 +0000)
committerRui Ueyama <ruiu@google.com>
Sat, 30 Apr 2016 21:40:04 +0000 (21:40 +0000)
commitaa00e96a849cf0953db5f3ad519b6cb4447e0ff0
tree6f1d31f3c682a9ce4adb953931c533a0e3c89870
parent53aa9f2475a1dd9050524bc9a0508d1e27a637a9
ELF: Make --reproduce to produce a response file.

The aim of this patch is to make it easy to re-run the command without
updating paths in the command line. Here is a use case.

Assume that Alice is having an issue with lld and is reporting the issue
to developer Bob. Alice's current directly is /home/alice/work and her
command line is "ld.lld -o foo foo.o ../bar.o". She adds "--reproduce repro"
to the command line and re-run. Then the following text will be produced as
response.txt (notice that the paths are rewritten so that they are
relative to /home/alice/work/repro.)

  -o home/alice/work/foo home/alice/work/foo.o home/alice/bar.o

The command also produces the following files by copying inputs.

  /home/alice/repro/home/alice/work/foo.o
  /home/alice/repro/home/alice/bar.o

Alice zips the directory and send it to Bob. Bob get an archive from Alice
and extract it to his home directory as /home/bob/repro. Now his directory
have the following files.

  /home/bob/repro/response.txt
  /home/bob/repro/home/alice/work/foo.o
  /home/bob/repro/home/alice/bar.o

Bob then re-run the command with these files by the following commands.

  cd /home/bob/repro
  ld.lld @response.txt

This command will run the linker with the same command line options and
the same input files as Alice's, so it is very likely that Bob will see
the same issue as Alice saw.

Differential Revision: http://reviews.llvm.org/D19737

llvm-svn: 268169
lld/ELF/Driver.cpp
lld/ELF/Driver.h
lld/ELF/DriverUtils.cpp
lld/test/ELF/reproduce.s