Index: lld/COFF/Driver.h =================================================================== --- lld/COFF/Driver.h +++ lld/COFF/Driver.h @@ -52,11 +52,19 @@ llvm::opt::InputArgList parseLINK(std::vector Args); // Tokenizes a given string and then parses as command line options. - llvm::opt::InputArgList parse(StringRef S) { return parse(tokenize(S)); } + llvm::opt::InputArgList parse(StringRef S) { + return parse(tokenize(S), true); + } + + // Tokenizes a given string and then parses as command line options in + // .drectve section. + llvm::opt::InputArgList parseDirectives(StringRef S) { + return parse(tokenize(S), false); + } private: // Parses command line options. - llvm::opt::InputArgList parse(llvm::ArrayRef Args); + llvm::opt::InputArgList parse(llvm::ArrayRef Args, bool ExpandRsp); std::vector tokenize(StringRef S); Index: lld/COFF/Driver.cpp =================================================================== --- lld/COFF/Driver.cpp +++ lld/COFF/Driver.cpp @@ -227,7 +227,7 @@ void LinkerDriver::parseDirectives(StringRef S) { ArgParser Parser; // .drectve is always tokenized using Windows shell rules. - opt::InputArgList Args = Parser.parse(S); + opt::InputArgList Args = Parser.parseDirectives(S); for (auto *Arg : Args) { switch (Arg->getOption().getUnaliasedOption().getID()) { Index: lld/COFF/DriverUtils.cpp =================================================================== --- lld/COFF/DriverUtils.cpp +++ lld/COFF/DriverUtils.cpp @@ -716,7 +716,7 @@ } // Parses a given list of options. -opt::InputArgList ArgParser::parse(ArrayRef Argv) { +opt::InputArgList ArgParser::parse(ArrayRef Argv, bool ExpandRsp) { // Make InputArgList from string vectors. unsigned MissingIndex; unsigned MissingCount; @@ -727,10 +727,12 @@ // --rsp-quoting. opt::InputArgList Args = Table.ParseArgs(Vec, MissingIndex, MissingCount); - // Expand response files (arguments in the form of @) - // and then parse the argument again. - cl::ExpandResponseFiles(Saver, getQuotingStyle(Args), Vec); - Args = Table.ParseArgs(Vec, MissingIndex, MissingCount); + if (ExpandRsp) { + // Expand response files (arguments in the form of @) + // and then parse the argument again. + cl::ExpandResponseFiles(Saver, getQuotingStyle(Args), Vec); + Args = Table.ParseArgs(Vec, MissingIndex, MissingCount); + } // Print the real command line if response files are expanded. if (Args.hasArg(OPT_verbose) && Argv.size() != Vec.size()) { @@ -763,7 +765,7 @@ std::vector V = tokenize(*S); Argv.insert(Argv.begin(), V.begin(), V.end()); } - return parse(Argv); + return parse(Argv, true); } std::vector ArgParser::tokenize(StringRef S) {