[lld] 1c8bb62 - [LLD] [MinGW] Print errors/warnings in lld-link with a "ld.lld" prefix

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 19 12:32:46 PDT 2021


Author: Martin Storsjö
Date: 2021-06-19T22:32:37+03:00
New Revision: 1c8bb625b716b647206bcf5f51ac1c356ec2985e

URL: https://github.com/llvm/llvm-project/commit/1c8bb625b716b647206bcf5f51ac1c356ec2985e
DIFF: https://github.com/llvm/llvm-project/commit/1c8bb625b716b647206bcf5f51ac1c356ec2985e.diff

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

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.

Differential Revision: https://reviews.llvm.org/D104526

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index 86a898de75172..c366343fc09d9 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -437,5 +437,8 @@ bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly,
   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);
 }

diff  --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index c8b7e2d12deba..3d497e6344832 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -102,7 +102,7 @@ RUN: ld.lld -### -m i386pep foo.o -whole-archive bar.a -no-whole-archive baz.a |
 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


        


More information about the llvm-commits mailing list