mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-19 06:38:28 +00:00
[PDB] Write the command line after response file expansion
Summary: Fixes PR38085 Reviewers: ruiu, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49566 llvm-svn: 337628
This commit is contained in:
parent
8aacc2cce6
commit
276d7167d0
@ -64,7 +64,6 @@ bool link(ArrayRef<const char *> Args, bool CanExitEarly, raw_ostream &Diag) {
|
||||
" (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 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
|
||||
|
||||
// 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;
|
||||
|
@ -791,26 +791,31 @@ opt::InputArgList ArgParser::parse(ArrayRef<const char *> Argv) {
|
||||
// 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 @@ opt::InputArgList ArgParser::parseLINK(std::vector<const char *> Argv) {
|
||||
// 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);
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user