[lld] r273698 - [ELF] Allow --reproduce to be specified as an environment variable.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 24 11:02:51 PDT 2016


Author: davide
Date: Fri Jun 24 13:02:50 2016
New Revision: 273698

URL: http://llvm.org/viewvc/llvm-project?rev=273698&view=rev
Log:
[ELF] Allow --reproduce to be specified as an environment variable.

PR: 28257
Differential Revision:   http://reviews.llvm.org/D21628

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/test/ELF/reproduce.s

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=273698&r1=273697&r2=273698&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Jun 24 13:02:50 2016
@@ -23,6 +23,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
+#include <cstdlib>
 #include <utility>
 
 using namespace llvm;
@@ -234,6 +235,12 @@ static int getInteger(opt::InputArgList
   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 @@ void LinkerDriver::main(ArrayRef<const c
     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());

Modified: lld/trunk/test/ELF/reproduce.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/reproduce.s?rev=273698&r1=273697&r2=273698&view=diff
==============================================================================
--- lld/trunk/test/ELF/reproduce.s (original)
+++ lld/trunk/test/ELF/reproduce.s Fri Jun 24 13:02:50 2016
@@ -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
 




More information about the llvm-commits mailing list