[llvm] 7060fc5 - [llvm-lto2] Added version command for llvm-lto2 (#148866)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 28 02:23:14 PDT 2025


Author: Faith Rivera
Date: 2025-08-28T10:23:10+01:00
New Revision: 7060fc5f8f99bbdf632163cc34b5506a2d565bb6

URL: https://github.com/llvm/llvm-project/commit/7060fc5f8f99bbdf632163cc34b5506a2d565bb6
DIFF: https://github.com/llvm/llvm-project/commit/7060fc5f8f99bbdf632163cc34b5506a2d565bb6.diff

LOG: [llvm-lto2] Added version command for llvm-lto2 (#148866)

Previously, the only way to check version for llvm-lto2 was to add
version as a subcommand: `llvm-lto2 run --version`. This adds version as
a main command for llvm-lto2 for more intuitive access.

You can now check version with the command `llvm-lto2 --version`.

Added: 
    llvm/test/tools/llvm-lto2/version.test

Modified: 
    llvm/tools/llvm-lto2/llvm-lto2.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-lto2/version.test b/llvm/test/tools/llvm-lto2/version.test
new file mode 100644
index 0000000000000..80e465aa7ad20
--- /dev/null
+++ b/llvm/test/tools/llvm-lto2/version.test
@@ -0,0 +1,7 @@
+## Show that you can run version as a main command for llvm-lto2 
+## or a subcommand of llvm-lto2 run.
+
+RUN: llvm-lto2 --version | FileCheck %s
+RUN: llvm-lto2 run --version | FileCheck %s 
+
+CHECK: version

diff  --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index fbde66666a596..d27a2199d75d8 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -616,5 +616,9 @@ int main(int argc, char **argv) {
     outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
     return 0;
   }
+  if (Subcommand == "--version") {
+    cl::PrintVersionMessage();
+    return 0;
+  }
   return usage();
 }


        


More information about the llvm-commits mailing list