[PATCH] D21628: [ELF] Allow --reproduce to be specified as an env variable

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


This revision was automatically updated to reflect the committed changes.
Closed by commit rL273698: [ELF] Allow --reproduce to be specified as an environment variable. (authored by davide).

Changed prior to commit:
  http://reviews.llvm.org/D21628?vs=61754&id=61814#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21628

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

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
 
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 <cstdlib>
 #include <utility>
 
 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());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21628.61814.patch
Type: text/x-patch
Size: 1850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160624/46d8aa42/attachment.bin>


More information about the llvm-commits mailing list