From 85093df3bd27256fcad259d4ee16b5e4f894b209 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 25 Mar 2014 20:40:27 +0000 Subject: [PATCH] [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 --- lld/lib/Driver/WinLinkDriver.cpp | 18 +++++++++++++++--- lld/test/pecoff/responsefile.test | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index f441034dfed1..49a117ad251b 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -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 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 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; } diff --git a/lld/test/pecoff/responsefile.test b/lld/test/pecoff/responsefile.test index 9732cb37d0e0..6a5da298e730 100644 --- a/lld/test/pecoff/responsefile.test +++ b/lld/test/pecoff/responsefile.test @@ -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