[PATCH] D104526: [LLD] [MinGW] Print errors/warnings in lld-link with a "ld.lld" prefix

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 18 05:36:04 PDT 2021


mstorsjo created this revision.
mstorsjo added a reviewer: rnk.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

Pass the original argv[0] to the coff linker, as the coff linker uses
the basename of argv[0] as the log prefix.

This makes error messages to be printed with a "ld.lld:" prefix
instead of "lld-link:". The current "lld-link:" prefix can be confusing
to users, as they're invoking the MinGW linker (and might not even have
a lld-link executable).

Keep the first argument as lld-link when printing the command line, to
make it an actually reproducible standalone command.

To actually test the effect of this, we'd have to actually do linking
from the test/MinGW subdirectory (which we don't do so far) and
have that link trigger an error.

Do you think it's necessary to make a standalone failing link test
to test the effect of this, or is it good as is?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104526

Files:
  lld/MinGW/Driver.cpp
  lld/test/MinGW/driver.test


Index: lld/test/MinGW/driver.test
===================================================================
--- lld/test/MinGW/driver.test
+++ lld/test/MinGW/driver.test
@@ -102,7 +102,7 @@
 WHOLE-ARCHIVE: foo.o -wholearchive:bar.a baz.a
 
 RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix MINGW-FLAG %s
-MINGW-FLAG: -lldmingw
+MINGW-FLAG: lld-link -lldmingw
 
 RUN: ld.lld -### -m i386pep foo.o --exclude-all-symbols | FileCheck -check-prefix EXCLUDE-ALL %s
 RUN: ld.lld -### -m i386pep foo.o -exclude-all-symbols | FileCheck -check-prefix EXCLUDE-ALL %s
Index: lld/MinGW/Driver.cpp
===================================================================
--- lld/MinGW/Driver.cpp
+++ lld/MinGW/Driver.cpp
@@ -436,5 +436,8 @@
   std::vector<const char *> vec;
   for (const std::string &s : linkArgs)
     vec.push_back(s.c_str());
+  // Pass the actual binary name, to make error messages be printed with
+  // the right prefix.
+  vec[0] = argsArr[0];
   return coff::link(vec, canExitEarly, stdoutOS, stderrOS);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104526.352982.patch
Type: text/x-patch
Size: 1019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210618/a6f9c93a/attachment.bin>


More information about the llvm-commits mailing list