Index: lld/trunk/ELF/Driver.cpp =================================================================== --- lld/trunk/ELF/Driver.cpp +++ lld/trunk/ELF/Driver.cpp @@ -23,6 +23,7 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" +#include #include using namespace llvm; @@ -234,6 +235,12 @@ return V; } +static const char *getReproduceOption(opt::InputArgList &Args) { + if (Args.hasArg(OPT_reproduce)) + return Args.getLastArg(OPT_reproduce)->getValue(); + return getenv("LLD_REPRODUCE"); +} + static bool hasZOption(opt::InputArgList &Args, StringRef Key) { for (auto *Arg : Args.filtered(OPT_z)) if (Key == Arg->getValue()) @@ -253,10 +260,10 @@ return; } - if (auto *Arg = Args.getLastArg(OPT_reproduce)) { + if (const char *Path = getReproduceOption(Args)) { // Note that --reproduce is a debug option so you can ignore it // if you are trying to understand the whole picture of the code. - Cpio.reset(CpioFile::create(Arg->getValue())); + Cpio.reset(CpioFile::create(Path)); if (Cpio) { Cpio->append("response.txt", createResponseFile(Args)); Cpio->append("version.txt", getVersionString()); Index: lld/trunk/test/ELF/reproduce.s =================================================================== --- lld/trunk/test/ELF/reproduce.s +++ lld/trunk/test/ELF/reproduce.s @@ -25,7 +25,7 @@ # RUN: mkdir -p %t.dir/build2/a/b/c # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.dir/build2/foo.o # RUN: cd %t.dir/build2/a/b/c -# RUN: ld.lld ./../../../foo.o -o bar -shared --as-needed --reproduce repro +# RUN: env LLD_REPRODUCE=repro ld.lld ./../../../foo.o -o bar -shared --as-needed # RUN: cpio -id < repro.cpio # RUN: diff %t.dir/build2/foo.o repro/%:t.dir/build2/foo.o