[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
This commit is contained in:
Martin Storsjö 2021-06-18 14:29:55 +03:00
parent 0f558db742
commit 1c8bb625b7
2 changed files with 4 additions and 1 deletions

View File

@ -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);
}

View File

@ -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