[llvm] 7e4883f - [llvm-ranlib] Change -v (alias for --version) to -V
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 5 09:24:16 PDT 2024
Author: Fangrui Song
Date: 2024-04-05T09:24:13-07:00
New Revision: 7e4883f8881bfaea30996c4e846369fbf0b4b549
URL: https://github.com/llvm/llvm-project/commit/7e4883f8881bfaea30996c4e846369fbf0b4b549
DIFF: https://github.com/llvm/llvm-project/commit/7e4883f8881bfaea30996c4e846369fbf0b4b549.diff
LOG: [llvm-ranlib] Change -v (alias for --version) to -V
-V prints the version information in both BSD and GNU ar/ranlib.
BSD ranlib rejects -v while -v enables verbose output in GNU ar but is
another alias for --version in GNU ranlib. The GNU ranlib behavior is
inconsistent: `ranlib -v` is different from `ar -sv`. But it's not a
major concern in practice:
* Users typically use ranlib solely for creating archive symbol tables,
and they don't need verbose output.
* Verbose output in ranlib seems a no-op.
* GNU ar creates an archive symbol table by default. Many ranlib uses
have been eliminated.
* Modern linkers like lld/ELF (since version 14) and mold don't rely on
archive symbol tables anymore.
https://reviews.llvm.org/D71554 introduced -v. This patch removes it so
that `llvm-ranlib -v` and `llvm-ranlib -version` lead to errors (GNU
ranlib rejects `-version` as well). -V is added as an alias for
--version.
Close #87654
Pull Request: https://github.com/llvm/llvm-project/pull/87661
Added:
Modified:
llvm/docs/ReleaseNotes.rst
llvm/test/tools/llvm-ranlib/help-message.test
llvm/tools/llvm-ar/llvm-ar.cpp
Removed:
################################################################################
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 7588048334d792..d2d542752b555e 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -174,6 +174,10 @@ Changes to the LLVM tools
* llvm-ar now allows specifying COFF archive format with ``--format`` argument
and uses it by default for COFF targets.
+* llvm-ranlib now supports ``-V`` as an alias for ``--version``.
+ ``-v`` (``--verbose`` in llvm-ar) has been removed.
+ (`#87661 <https://github.com/llvm/llvm-project/pull/87661>`_)
+
* llvm-objcopy now supports ``--set-symbol-visibility`` and
``--set-symbols-visibility`` options for ELF input to change the
visibility of symbols.
diff --git a/llvm/test/tools/llvm-ranlib/help-message.test b/llvm/test/tools/llvm-ranlib/help-message.test
index 8d8824ac46121a..97212aa035b313 100644
--- a/llvm/test/tools/llvm-ranlib/help-message.test
+++ b/llvm/test/tools/llvm-ranlib/help-message.test
@@ -5,13 +5,22 @@
# RUN: llvm-ranlib -help | FileCheck %s --check-prefix=HELP
# RUN: llvm-ranlib --help | FileCheck %s --check-prefix=HELP
# RUN: llvm-ranlib --version | FileCheck %s --check-prefix=VERSION
-# RUN: llvm-ranlib -version | FileCheck %s --check-prefix=VERSION
-# RUN: llvm-ranlib -v | FileCheck %s --check-prefix=VERSION
+# RUN: llvm-ranlib -V | FileCheck %s --check-prefix=VERSION
## Also check combined options (first -h/-v flag wins)
# RUN: llvm-ranlib -Dh | FileCheck %s --check-prefix=HELP
-# RUN: llvm-ranlib -Dvh | FileCheck %s --check-prefix=VERSION
-# RUN: llvm-ranlib -Dhv | FileCheck %s --check-prefix=HELP
+# RUN: llvm-ranlib -DVh | FileCheck %s --check-prefix=VERSION
+# RUN: llvm-ranlib -DhV | FileCheck %s --check-prefix=HELP
# HELP: USAGE: llvm-ranlib
# VERSION: version
+
+## -v enables verbose output in BSD ranlib and GNU ar but is another alias
+## for --version in GNU ranlib. Reject -v.
+# RUN: not llvm-ranlib -v 2>&1 | FileCheck %s --check-prefix=ERR1
+# RUN: not llvm-ranlib -version 2>&1 | FileCheck %s --check-prefix=ERR2
+# RUN: not llvm-ranlib -Dvh 2>&1 | FileCheck %s --check-prefix=ERR3
+
+# ERR1: error: Invalid option: '-v'
+# ERR2: error: Invalid option: '-version'
+# ERR3: error: Invalid option: '-vh'
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp
index 294b8531b08f13..3b842b76d5c870 100644
--- a/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -65,7 +65,7 @@ static void printRanLibHelp(StringRef ToolName) {
<< "USAGE: " + ToolName + " archive...\n\n"
<< "OPTIONS:\n"
<< " -h --help - Display available options\n"
- << " -v --version - Display the version of this program\n"
+ << " -V --version - Display the version of this program\n"
<< " -D - Use zero for timestamps and uids/gids "
"(default)\n"
<< " -U - Use actual timestamps and uids/gids\n"
@@ -1439,7 +1439,7 @@ static int ranlib_main(int argc, char **argv) {
} else if (arg.front() == 'h') {
printHelpMessage();
return 0;
- } else if (arg.front() == 'v') {
+ } else if (arg.front() == 'V') {
cl::PrintVersionMessage();
return 0;
} else if (arg.front() == 'X') {
More information about the llvm-commits
mailing list