Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ 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; @@ -253,10 +254,15 @@ return; } - if (auto *Arg = Args.getLastArg(OPT_reproduce)) { + const char *ReproducePath = nullptr; + if (Args.hasArg(OPT_reproduce)) + ReproducePath = Args.getLastArg(OPT_reproduce)->getValue(); + else + ReproducePath = ::getenv("LLD_REPRODUCE"); + if (ReproducePath) { // 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(ReproducePath)); if (Cpio) { Cpio->append("response.txt", createResponseFile(Args)); Cpio->append("version.txt", getVersionString()); Index: test/ELF/reproduce.s =================================================================== --- test/ELF/reproduce.s +++ 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