ELF2: Support reponse files.
http://reviews.llvm.org/D13148
llvm-svn: 248575
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 8d7ef5e..704d7c9 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -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 @@
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) +