Skip to content

Commit 06010fd

Browse files
committed
[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 llvm#57859
1 parent bd6e018 commit 06010fd

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

lld/ELF/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
542542
def: Joined<["-", "--"], "Ttext-segment=">, Alias<Ttext_segment>;
543543
def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
544544
def: JoinedOrSeparate<["-"], "u">, Alias<undefined>, HelpText<"Alias for --undefined">;
545-
def: Flag<["-"], "V">, Alias<version>, HelpText<"Alias for --version">;
545+
def: Flag<["-"], "V">, Alias<v>, HelpText<"Alias for -v">;
546546

547547
// LTO-related options.
548548
def lto_aa_pipeline: JJ<"lto-aa-pipeline=">,

lld/docs/ld.lld.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,10 @@ Creates a separate output section for every orphan input section.
637637
Determine how to handle unresolved symbols.
638638
.It Fl -use-android-relr-tags
639639
Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*.
640-
.It Fl v
640+
.It Fl v , Fl V
641641
Display the version number and proceed with linking if object files are
642642
specified.
643-
.It Fl V , Fl -version
643+
.It Fl -version
644644
Display the version number and exit.
645645
.It Fl -verbose
646646
Verbose mode.

lld/test/ELF/version.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
# RUN: ld.lld -v 2>&1 | FileCheck %s
66
# RUN: not ld.lld -v %t/not-exist 2>&1 | FileCheck %s
77
# RUN: ld.lld -V 2>&1 | FileCheck %s
8+
# RUN: not ld.lld -V %t/not-exist 2>&1 | FileCheck %s
89

910
# CHECK: LLD {{.*}} (compatible with GNU linkers)

0 commit comments

Comments
 (0)