-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-ranlib] Change -v (alias for --version) to -V #87661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm-ranlib] Change -v (alias for --version) to -V #87661
Conversation
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-llvm-binary-utilities Author: Fangrui Song (MaskRay) Changes-V prints the version information in both BSD and GNU ar/ranlib. -v enables verbose output in BSD ranlib and GNU ar but is another alias
https://reviews.llvm.org/D71554 introduced -v. This patch removes it so Close #87654 Full diff: https://github.com/llvm/llvm-project/pull/87661.diff 2 Files Affected:
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') {
|
-V prints the version information in both BSD and GNU ar/ranlib. -v enables verbose output in BSD ranlib and 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 lld 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 llvm#87654 Pull Request: llvm#87661
hrm, GNU ranlib help output shows
but given there's conflicting functionality between BSD and GNU ranlib for As an aside I suspect that the ranlib invocations in the FreeBSD ports collection are all unnecessary and are just leftover from build systems created for much earlier toolchains, but it's a slow process to get rid of them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Created using spr 1.3.5-bogner
-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 fromar -sv
. But it's not amajor concern in practice:
and they don't need verbose output.
have been eliminated.
archive symbol tables anymore.
https://reviews.llvm.org/D71554 introduced -v. This patch removes it so
that
llvm-ranlib -v
andllvm-ranlib -version
lead to errors (GNUranlib rejects
-version
as well). -V is added as an alias for--version.
Close #87654