From 06010fd1be3d816fdbbb53f75a26902c02b6f111 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 20 Sep 2022 17:12:44 -0700 Subject: [PATCH] [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 --- lld/ELF/Options.td | 2 +- lld/docs/ld.lld.1 | 4 ++-- lld/test/ELF/version.test | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td index 72d5b6e..1d8cc77e 100644 --- a/lld/ELF/Options.td +++ b/lld/ELF/Options.td @@ -542,7 +542,7 @@ def: Flag<["-"], "t">, Alias, HelpText<"Alias for --trace">; def: Joined<["-", "--"], "Ttext-segment=">, Alias; def: JoinedOrSeparate<["-"], "y">, Alias, HelpText<"Alias for --trace-symbol">; def: JoinedOrSeparate<["-"], "u">, Alias, HelpText<"Alias for --undefined">; -def: Flag<["-"], "V">, Alias, HelpText<"Alias for --version">; +def: Flag<["-"], "V">, Alias, HelpText<"Alias for -v">; // LTO-related options. def lto_aa_pipeline: JJ<"lto-aa-pipeline=">, diff --git a/lld/docs/ld.lld.1 b/lld/docs/ld.lld.1 index 7a4aa21..9ddd289 100644 --- a/lld/docs/ld.lld.1 +++ b/lld/docs/ld.lld.1 @@ -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. diff --git a/lld/test/ELF/version.test b/lld/test/ELF/version.test index ab75396..cdeeb47 100644 --- a/lld/test/ELF/version.test +++ b/lld/test/ELF/version.test @@ -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) -- 2.7.4