From 1c8bb625b716b647206bcf5f51ac1c356ec2985e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Storsj=C3=B6?= Date: Fri, 18 Jun 2021 14:29:55 +0300 Subject: [PATCH] [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 --- lld/MinGW/Driver.cpp | 3 +++ lld/test/MinGW/driver.test | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp index 86a898d..c366343 100644 --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -437,5 +437,8 @@ bool mingw::link(ArrayRef argsArr, bool canExitEarly, std::vector 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 c8b7e2d..3d497e6 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 -- 2.7.4