[ELF] Make -V an alias for -v

In GNU ld,

* --version skips linker input processing.
* -v and -V keep processing if there is any input file. -V has more
  information we don't support.

We currently make -V an alias for --version which skips input processing.
On many `*-freebsd` and `powerpc-*` targets, `gcc -v` passes `-V` to ld
and expects to process input. Make -V an alias for -v to provide
compatibility.

Fix https://github.com/llvm/llvm-project/issues/57859
This commit is contained in:
Fangrui Song 2022-09-20 17:12:44 -07:00
parent bd6e018472
commit 06010fd1be
3 changed files with 4 additions and 3 deletions

View File

@ -542,7 +542,7 @@ def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
def: Joined<["-", "--"], "Ttext-segment=">, Alias<Ttext_segment>;
def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
def: JoinedOrSeparate<["-"], "u">, Alias<undefined>, HelpText<"Alias for --undefined">;
def: Flag<["-"], "V">, Alias<version>, HelpText<"Alias for --version">;
def: Flag<["-"], "V">, Alias<v>, HelpText<"Alias for -v">;
// LTO-related options.
def lto_aa_pipeline: JJ<"lto-aa-pipeline=">,

View File

@ -637,10 +637,10 @@ Creates a separate output section for every orphan input section.
Determine how to handle unresolved symbols.
.It Fl -use-android-relr-tags
Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*.
.It Fl v
.It Fl v , Fl V
Display the version number and proceed with linking if object files are
specified.
.It Fl V , Fl -version
.It Fl -version
Display the version number and exit.
.It Fl -verbose
Verbose mode.

View File

@ -5,5 +5,6 @@
# RUN: ld.lld -v 2>&1 | FileCheck %s
# RUN: not ld.lld -v %t/not-exist 2>&1 | FileCheck %s
# RUN: ld.lld -V 2>&1 | FileCheck %s
# RUN: not ld.lld -V %t/not-exist 2>&1 | FileCheck %s
# CHECK: LLD {{.*}} (compatible with GNU linkers)