[PATCH] D102321: [llvm-nm] Support the -V option, print that the tool is compatible with GNU nm
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 12 11:32:32 PDT 2021
mstorsjo updated this revision to Diff 344884.
mstorsjo added a comment.
Addressed the feedback.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102321/new/
https://reviews.llvm.org/D102321
Files:
llvm/docs/CommandGuide/llvm-nm.rst
llvm/test/tools/llvm-nm/libtool-version.test
llvm/tools/llvm-nm/llvm-nm.cpp
Index: llvm/tools/llvm-nm/llvm-nm.cpp
===================================================================
--- llvm/tools/llvm-nm/llvm-nm.cpp
+++ llvm/tools/llvm-nm/llvm-nm.cpp
@@ -229,6 +229,8 @@
"TBD(Mach-O) only"),
cl::cat(NMCat));
+cl::opt<bool> Version("V", cl::desc("Print version info"), cl::cat(NMCat));
+
cl::extrahelp HelpResponse("\nPass @FILE as argument to read options from FILE.\n");
bool PrintAddress = true;
@@ -2235,11 +2237,23 @@
}
}
+static void printExtraVersionInfo(raw_ostream &Outs) {
+ // This needs to contain the word "GNU", libtool looks for that string.
+ Outs << "llvm-nm, compatible with GNU nm\n";
+}
+
int main(int argc, char **argv) {
InitLLVM X(argc, argv);
cl::HideUnrelatedOptions(NMCat);
+ cl::AddExtraVersionPrinter(printExtraVersionInfo);
cl::ParseCommandLineOptions(argc, argv, "llvm symbol table dumper\n");
+ if (Version) {
+ printExtraVersionInfo(outs());
+ cl::PrintVersionMessage();
+ return 0;
+ }
+
// llvm-nm only reads binary files.
if (error(sys::ChangeStdinToBinary()))
return 1;
Index: llvm/test/tools/llvm-nm/libtool-version.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-nm/libtool-version.test
@@ -0,0 +1,6 @@
+Check that the output of llvm-nm -V (and --version) contains the text
+"GNU" somewhere, to let libtool know that it is compatible with GNU nm.
+
+RUN: llvm-nm -V | FileCheck %s
+RUN: llvm-nm --version | FileCheck %s
+CHECK: GNU
Index: llvm/docs/CommandGuide/llvm-nm.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-nm.rst
+++ llvm/docs/CommandGuide/llvm-nm.rst
@@ -230,7 +230,7 @@
Print only undefined symbols.
-.. option:: --version
+.. option:: --version, -V
Display the version of the :program:`llvm-nm` executable. Does not stack with
other commands.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102321.344884.patch
Type: text/x-patch
Size: 1971 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210512/2f92c173/attachment.bin>
More information about the llvm-commits
mailing list