[PECOFF] Print out command line if we have expanded response files.

If a response file is given via command line, the final command line
arguments will not appear in the log because the actual arguments are
in the given file.

This patch is to show the final command line if /verbose is specified
to help users.

llvm-svn: 204754
This commit is contained in:
Rui Ueyama 2014-03-25 20:40:27 +00:00
parent 83055ade75
commit 85093df3bd
2 changed files with 17 additions and 4 deletions

View File

@ -640,9 +640,9 @@ static bool readResponseFile(StringRef path, PECOFFLinkingContext &ctx,
// Expand arguments starting with "@". It's an error if a specified file does
// not exist. Returns true on success.
static bool expandResponseFiles(int &argc, const char **&argv,
PECOFFLinkingContext &ctx, raw_ostream &diag) {
PECOFFLinkingContext &ctx, raw_ostream &diag,
bool &expanded) {
std::vector<const char *> newArgv;
bool expanded = false;
for (int i = 0; i < argc; ++i) {
if (argv[i][0] != '@') {
newArgv.push_back(argv[i]);
@ -669,7 +669,8 @@ static std::unique_ptr<llvm::opt::InputArgList>
parseArgs(int argc, const char **argv, PECOFFLinkingContext &ctx,
raw_ostream &diag, bool isReadingDirectiveSection) {
// Expand arguments starting with "@".
if (!expandResponseFiles(argc, argv, ctx, diag))
bool expanded = false;
if (!expandResponseFiles(argc, argv, ctx, diag, expanded))
return nullptr;
// Parse command line options using WinLinkOptions.td
@ -696,6 +697,17 @@ parseArgs(int argc, const char **argv, PECOFFLinkingContext &ctx,
continue;
diag << "warning: ignoring unknown argument: " << arg << "\n";
}
// If we have expaneded response files and /verbose is given, print out the
// final command line.
if (!isReadingDirectiveSection && expanded &&
parsedArgs->getLastArg(OPT_verbose)) {
diag << "Command line:";
for (int i = 0; i < argc; ++i)
diag << " " << argv[i];
diag << "\n\n";
}
return parsedArgs;
}

View File

@ -1,6 +1,7 @@
# RUN: yaml2obj %p/Inputs/hello.obj.yaml > %t.obj
# RUN: not lld -flavor link @%p/Inputs/responsefile.txt >& %t.log
# RUN: not lld -flavor link /verbose @%p/Inputs/responsefile.txt >& %t.log
# RUN: FileCheck %s < %t.log
CHECK: warning: ignoring unknown argument: -foo
CHECK: warning: ignoring unknown argument: -bar\baz
Command line: link /verbose -foo -bar\baz