[lld] 06010fd - [ELF] Make -V an alias for -v

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 17:12:53 PDT 2022


Author: Fangrui Song
Date: 2022-09-20T17:12:44-07:00
New Revision: 06010fd1be3d816fdbbb53f75a26902c02b6f111

URL: https://github.com/llvm/llvm-project/commit/06010fd1be3d816fdbbb53f75a26902c02b6f111
DIFF: https://github.com/llvm/llvm-project/commit/06010fd1be3d816fdbbb53f75a26902c02b6f111.diff

LOG: [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

Added: 
    

Modified: 
    lld/ELF/Options.td
    lld/docs/ld.lld.1
    lld/test/ELF/version.test

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 72d5b6e2e663c..1d8cc77ed0094 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -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=">,

diff  --git a/lld/docs/ld.lld.1 b/lld/docs/ld.lld.1
index 7a4aa219187b6..9ddd2897a23af 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 ab753963690fa..cdeeb4795e185 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)


        


More information about the llvm-commits mailing list