[PATCH] D49566: [PDB] Write the command line after response file expansion

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 20 15:39:33 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD337628: [PDB] Write the command line after response file expansion (authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49566?vs=156355&id=156624#toc

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D49566

Files:
  COFF/Driver.cpp
  COFF/DriverUtils.cpp
  test/COFF/pdb-linker-module.test


Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -64,7 +64,6 @@
       " (use /errorlimit:0 to see all errors)";
   errorHandler().ExitEarly = CanExitEarly;
   Config = make<Configuration>();
-  Config->Argv = {Args.begin(), Args.end()};
 
   Symtab = make<SymbolTable>();
 
@@ -875,7 +874,7 @@
 
   // Parse command line options.
   ArgParser Parser;
-  opt::InputArgList Args = Parser.parseLINK(ArgsArr.slice(1));
+  opt::InputArgList Args = Parser.parseLINK(ArgsArr);
 
   // Parse and evaluate -mllvm options.
   std::vector<const char *> V;
Index: COFF/DriverUtils.cpp
===================================================================
--- COFF/DriverUtils.cpp
+++ COFF/DriverUtils.cpp
@@ -791,26 +791,31 @@
   // Make InputArgList from string vectors.
   unsigned MissingIndex;
   unsigned MissingCount;
-  SmallVector<const char *, 256> Vec(Argv.data(), Argv.data() + Argv.size());
 
   // We need to get the quoting style for response files before parsing all
   // options so we parse here before and ignore all the options but
   // --rsp-quoting.
-  opt::InputArgList Args = Table.ParseArgs(Vec, MissingIndex, MissingCount);
+  opt::InputArgList Args = Table.ParseArgs(Argv, MissingIndex, MissingCount);
 
   // Expand response files (arguments in the form of @<filename>)
   // and then parse the argument again.
-  cl::ExpandResponseFiles(Saver, getQuotingStyle(Args), Vec);
-  Args = Table.ParseArgs(Vec, MissingIndex, MissingCount);
+  SmallVector<const char *, 256> ExpandedArgv(Argv.data(), Argv.data() + Argv.size());
+  cl::ExpandResponseFiles(Saver, getQuotingStyle(Args), ExpandedArgv);
+  Args = Table.ParseArgs(makeArrayRef(ExpandedArgv).drop_front(), MissingIndex,
+                         MissingCount);
 
   // Print the real command line if response files are expanded.
-  if (Args.hasArg(OPT_verbose) && Argv.size() != Vec.size()) {
+  if (Args.hasArg(OPT_verbose) && Argv.size() != ExpandedArgv.size()) {
     std::string Msg = "Command line:";
-    for (const char *S : Vec)
+    for (const char *S : ExpandedArgv)
       Msg += " " + std::string(S);
     message(Msg);
   }
 
+  // Save the command line after response file expansion so we can write it to
+  // the PDB if necessary.
+  Config->Argv = {ExpandedArgv.begin(), ExpandedArgv.end()};
+
   // Handle /WX early since it converts missing argument warnings to errors.
   errorHandler().FatalWarnings = Args.hasFlag(OPT_WX, OPT_WX_no, false);
 
@@ -862,11 +867,11 @@
   // Concatenate LINK env and command line arguments, and then parse them.
   if (Optional<std::string> S = Process::GetEnv("LINK")) {
     std::vector<const char *> V = tokenize(*S);
-    Argv.insert(Argv.begin(), V.begin(), V.end());
+    Argv.insert(std::next(Argv.begin()), V.begin(), V.end());
   }
   if (Optional<std::string> S = Process::GetEnv("_LINK_")) {
     std::vector<const char *> V = tokenize(*S);
-    Argv.insert(Argv.begin(), V.begin(), V.end());
+    Argv.insert(std::next(Argv.begin()), V.begin(), V.end());
   }
   return parse(Argv);
 }
Index: test/COFF/pdb-linker-module.test
===================================================================
--- test/COFF/pdb-linker-module.test
+++ test/COFF/pdb-linker-module.test
@@ -1,4 +1,5 @@
-RUN: lld-link /debug /pdb:%t.pdb /nodefaultlib /entry:main %S/Inputs/pdb-diff.obj
+RUN: echo "/nodefaultlib" > %t.rsp
+RUN: lld-link /debug /pdb:%t.pdb @%t.rsp /entry:main %S/Inputs/pdb-diff.obj
 RUN: llvm-pdbutil dump -modules %t.pdb | FileCheck --check-prefix=MODS %s
 RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck --check-prefix=SYMS %s
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49566.156624.patch
Type: text/x-patch
Size: 3650 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180720/a289eed5/attachment.bin>


More information about the llvm-commits mailing list