lld: make -v behave similarly to GNU ld.bfd
Previously, lld exited with an error status if the only option given to the command was -v. GNU linkers gracefully exit in that case. This patch makes lld behave like GNU. Note that even with this patch, lld's -v and --version options behave slightly differently than GNU linkers' counterparts. For example, if you run ld.bfd -v -v, the version string is printed out twice. But that is an edge case that I don't think we need to take care of. Fixes https://bugs.llvm.org/show_bug.cgi?id=31582 Obtained from: LLVM r319717 MFC after: 1 week
This commit is contained in:
parent
b07bc39a23
commit
a6aca65caf
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=326547
@ -345,9 +345,10 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr, bool CanExitEarly) {
|
|||||||
if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version))
|
if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version))
|
||||||
message(getLLDVersion() + " (compatible with GNU linkers)");
|
message(getLLDVersion() + " (compatible with GNU linkers)");
|
||||||
|
|
||||||
// ld.bfd always exits after printing out the version string.
|
// The behavior of -v or --version is a bit strange, but this is
|
||||||
// ld.gold proceeds if a given option is -v. Because gold's behavior
|
// needed for compatibility with GNU linkers.
|
||||||
// is more permissive than ld.bfd, we chose what gold does here.
|
if (Args.hasArg(OPT_v) && !Args.hasArg(OPT_INPUT))
|
||||||
|
return;
|
||||||
if (Args.hasArg(OPT_version))
|
if (Args.hasArg(OPT_version))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user