[lld] r268172 - ELF: --reproduce: quote pathnames for -L and other options.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 30 15:46:47 PDT 2016


Author: ruiu
Date: Sat Apr 30 17:46:47 2016
New Revision: 268172

URL: http://llvm.org/viewvc/llvm-project?rev=268172&view=rev
Log:
ELF: --reproduce: quote pathnames for -L and other options.

Previously, arguments for options that take pathnames were not rewritten.

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

Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=268172&r1=268171&r2=268172&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Sat Apr 30 17:46:47 2016
@@ -137,6 +137,12 @@ static std::string quote(StringRef S) {
   return ("\"" + S + "\"").str();
 }
 
+static std::string rewritePath(StringRef S) {
+  if (fs::exists(S))
+    return getDestPath(S);
+  return S;
+}
+
 // Copies all input files to Config->Reproduce directory and
 // create a response file as "response.txt", so that you can re-run
 // the same command with the same inputs just by executing
@@ -157,25 +163,25 @@ void elf::createResponseFile(const llvm:
   raw_fd_ostream OS(Path, EC, sys::fs::OpenFlags::F_None);
   check(EC);
 
-  // Dump the command line to response.txt while copying files
-  // and rewriting paths.
+  // Copy the command line to response.txt while rewriting paths.
   for (auto *Arg : Args) {
     switch (Arg->getOption().getID()) {
     case OPT_reproduce:
       break;
+    case OPT_INPUT:
+      OS << quote(rewritePath(Arg->getValue())) << "\n";
+      break;
+    case OPT_L:
+    case OPT_dynamic_list:
+    case OPT_export_dynamic_symbol:
+    case OPT_rpath:
     case OPT_script:
-      OS << "--script ";
-      // fallthrough
-    case OPT_INPUT: {
-      StringRef Path = Arg->getValue();
-      if (fs::exists(Path))
-        OS << quote(getDestPath(Path)) << "\n";
-      else
-        OS << quote(Path) << "\n";
+    case OPT_version_script:
+      OS << Arg->getSpelling() << " "
+         << quote(rewritePath(Arg->getValue())) << "\n";
       break;
-    }
     default:
-      OS << Arg->getAsString(Args) << "\n";
+      OS << quote(Arg->getAsString(Args)) << "\n";
     }
   }
 }

Modified: lld/trunk/test/ELF/reproduce.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/reproduce.s?rev=268172&r1=268171&r2=268172&view=diff
==============================================================================
--- lld/trunk/test/ELF/reproduce.s (original)
+++ lld/trunk/test/ELF/reproduce.s Sat Apr 30 17:46:47 2016
@@ -19,10 +19,13 @@
 # RUN: ld.lld ./../../../foo.o -o bar -shared --as-needed --reproduce repro
 # RUN: diff %t.dir/build2/foo.o repro/%:t.dir/build2/foo.o
 
-# RUN: not ld.lld build1/foo.o --reproduce repro2 'foo bar' -soname=foo
+# RUN: touch file
+# RUN: not ld.lld --reproduce repro2 'foo bar' -L"foo bar" -Lfile -version-script file
 # RUN: FileCheck %s --check-prefix=RSP2 < repro2/response.txt
 # RSP2:      "foo bar"
-# RSP2-NEXT: -soname=foo
+# RSP2-NEXT: -L "foo bar"
+# RSP2-NEXT: -L {{.+}}file
+# RSP2-NEXT: -version-script {{.+}}file
 
 # RUN: not ld.lld build1/foo.o -o bar -shared --as-needed --reproduce . 2>&1 \
 # RUN:   | FileCheck --check-prefix=ERROR %s




More information about the llvm-commits mailing list