[lld] r204754 - [PECOFF] Print out command line if we have expanded response files.
Rui Ueyama
ruiu at google.com
Tue Mar 25 13:40:27 PDT 2014
Author: ruiu
Date: Tue Mar 25 15:40:27 2014
New Revision: 204754
URL: http://llvm.org/viewvc/llvm-project?rev=204754&view=rev
Log:
[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.
Modified:
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/test/pecoff/responsefile.test
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=204754&r1=204753&r2=204754&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Mar 25 15:40:27 2014
@@ -640,9 +640,9 @@ static bool readResponseFile(StringRef p
// 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::InputA
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, P
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;
}
Modified: lld/trunk/test/pecoff/responsefile.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/responsefile.test?rev=204754&r1=204753&r2=204754&view=diff
==============================================================================
--- lld/trunk/test/pecoff/responsefile.test (original)
+++ lld/trunk/test/pecoff/responsefile.test Tue Mar 25 15:40:27 2014
@@ -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
More information about the llvm-commits
mailing list