[lld] r248575 - ELF2: Support reponse files.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 08:37:33 PDT 2015


Author: ruiu
Date: Fri Sep 25 10:37:33 2015
New Revision: 248575

URL: http://llvm.org/viewvc/llvm-project?rev=248575&view=rev
Log:
ELF2: Support reponse files.

http://reviews.llvm.org/D13148

Modified:
    lld/trunk/ELF/Driver.h
    lld/trunk/ELF/DriverUtils.cpp
    lld/trunk/test/elf2/basic.s

Modified: lld/trunk/ELF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=248575&r1=248574&r2=248575&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.h (original)
+++ lld/trunk/ELF/Driver.h Fri Sep 25 10:37:33 2015
@@ -28,6 +28,9 @@ class ArgParser {
 public:
   // Parses command line options.
   llvm::opt::InputArgList parse(ArrayRef<const char *> Args);
+
+private:
+  llvm::BumpPtrAllocator Alloc;
 };
 
 class LinkerDriver {

Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=248575&r1=248574&r2=248575&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Fri Sep 25 10:37:33 2015
@@ -16,6 +16,8 @@
 #include "Driver.h"
 #include "Error.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/StringSaver.h"
 
 using namespace llvm;
 
@@ -53,7 +55,13 @@ opt::InputArgList ArgParser::parse(Array
   unsigned MissingIndex;
   unsigned MissingCount;
 
-  opt::InputArgList Args = Table.ParseArgs(Argv, MissingIndex, MissingCount);
+  // Expand response files. '@<filename>' is replaced by the file's contents.
+  SmallVector<const char *, 256> Vec(Argv.data(), Argv.data() + Argv.size());
+  StringSaver Saver(Alloc);
+  llvm::cl::ExpandResponseFiles(Saver, llvm::cl::TokenizeGNUCommandLine, Vec);
+
+  // Parse options and then do error checking.
+  opt::InputArgList Args = Table.ParseArgs(Vec, MissingIndex, MissingCount);
   if (MissingCount)
     error(Twine("missing arg value for \"") + Args.getArgString(MissingIndex) +
           "\", expected " + Twine(MissingCount) +

Modified: lld/trunk/test/elf2/basic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=248575&r1=248574&r2=248575&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic.s (original)
+++ lld/trunk/test/elf2/basic.s Fri Sep 25 10:37:33 2015
@@ -176,6 +176,11 @@ _start:
 # CHECK-NEXT:   }
 # CHECK-NEXT: ]
 
+# RUN: echo " -o %t2" > %t.responsefile
+# RUN: lld -flavor gnu2 %t @%t.responsefile
+# RUN: llvm-readobj -file-headers -sections -program-headers -symbols %t2 \
+# RUN:   | FileCheck %s
+
 # RUN: not lld -flavor gnu2 %t 2>&1 | FileCheck --check-prefix=NO_O %s
 # NO_O: -o must be specified.
 




More information about the llvm-commits mailing list