[llvm] [llvm-lto2] Added version command for llvm-lto2 (PR #148866)
Faith Rivera via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 15 08:19:27 PDT 2025
https://github.com/fnriv created https://github.com/llvm/llvm-project/pull/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`.
>From 48ba0edc59a2c106da83b33ba8ce38c44d88f21d Mon Sep 17 00:00:00 2001
From: Faith Rivera <103224896+fnriv at users.noreply.github.com>
Date: Mon, 14 Jul 2025 11:25:04 -0700
Subject: [PATCH 1/4] Added version command for llvm-lto2
---
llvm/test/tools/llvm-lto2/version.test | 7 +++++++
llvm/tools/llvm-lto2/llvm-lto2.cpp | 6 +++++-
2 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/tools/llvm-lto2/version.test
diff --git a/llvm/test/tools/llvm-lto2/version.test b/llvm/test/tools/llvm-lto2/version.test
new file mode 100644
index 0000000000000..87ac738ab5da2
--- /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..55797b8c954f3 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -247,7 +247,7 @@ template <typename T> static T check(ErrorOr<T> E, std::string Msg) {
}
static int usage() {
- errs() << "Available subcommands: dump-symtab run print-guid\n";
+ errs() << "Available subcommands: dump-symtab run print-guid version\n";
return 1;
}
@@ -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();
}
>From d2208809565650841b9315237fd6fb21f018c496 Mon Sep 17 00:00:00 2001
From: Faith Rivera <103224896+fnriv at users.noreply.github.com>
Date: Mon, 14 Jul 2025 14:42:31 -0700
Subject: [PATCH 2/4] llvm-lto2: Changed version main command to --version
---
llvm/test/tools/llvm-lto2/version.test | 2 +-
llvm/tools/llvm-lto2/llvm-lto2.cpp | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/test/tools/llvm-lto2/version.test b/llvm/test/tools/llvm-lto2/version.test
index 87ac738ab5da2..16c728553b896 100644
--- a/llvm/test/tools/llvm-lto2/version.test
+++ b/llvm/test/tools/llvm-lto2/version.test
@@ -1,7 +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 --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 55797b8c954f3..c8eb1c8ca6e80 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -247,7 +247,7 @@ template <typename T> static T check(ErrorOr<T> E, std::string Msg) {
}
static int usage() {
- errs() << "Available subcommands: dump-symtab run print-guid version\n";
+ errs() << "Available subcommands: dump-symtab run print-guid --version\n";
return 1;
}
@@ -616,7 +616,7 @@ int main(int argc, char **argv) {
outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
return 0;
}
- if (Subcommand == "version") {
+ if (Subcommand == "--version") {
cl::PrintVersionMessage();
return 0;
}
>From cf5ae9d7c282fcaf7e5e4fa72372da121f8e6383 Mon Sep 17 00:00:00 2001
From: Faith Rivera <103224896+fnriv at users.noreply.github.com>
Date: Mon, 14 Jul 2025 14:58:30 -0700
Subject: [PATCH 3/4] llvm-lto2 fixed usage description for commands
---
llvm/tools/llvm-lto2/llvm-lto2.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index c8eb1c8ca6e80..8b4bb90eee9a1 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -247,7 +247,7 @@ template <typename T> static T check(ErrorOr<T> E, std::string Msg) {
}
static int usage() {
- errs() << "Available subcommands: dump-symtab run print-guid --version\n";
+ errs() << "Available subcommands: dump-symtab run print-guid version\n";
return 1;
}
>From 6440d774ae8b90111338d00c74142298f5d6d61b Mon Sep 17 00:00:00 2001
From: Faith Rivera <103224896+fnriv at users.noreply.github.com>
Date: Mon, 14 Jul 2025 15:35:53 -0700
Subject: [PATCH 4/4] Revised usage message
---
llvm/tools/llvm-lto2/llvm-lto2.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 8b4bb90eee9a1..d27a2199d75d8 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -247,7 +247,7 @@ template <typename T> static T check(ErrorOr<T> E, std::string Msg) {
}
static int usage() {
- errs() << "Available subcommands: dump-symtab run print-guid version\n";
+ errs() << "Available subcommands: dump-symtab run print-guid\n";
return 1;
}
More information about the llvm-commits
mailing list