[llvm] [llvm] Include LLVM_REPOSITORY and LLVM_REVISION in tool version (PR #84990)
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 10:19:42 PDT 2024
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/84990
>From 39ac5fb536d09f27d9b0212d05d6d79add07fb71 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Tue, 12 Mar 2024 16:19:44 -0700
Subject: [PATCH 1/2] [llvm] Include LLVM_REPOSITORY and LLVM_REVISION in tool
version
Include the LLVM_REPOSITORY and LLVM_REVISION in the version output of
tools using cl::PrintVersionMessage().
---
llvm/lib/Support/CommandLine.cpp | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index c076ae8b843179..42dbc4de200303 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -39,6 +39,7 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VCSRevision.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdlib>
@@ -2538,7 +2539,15 @@ class VersionPrinter {
#else
OS << "LLVM (http://llvm.org/):\n ";
#endif
- OS << PACKAGE_NAME << " version " << PACKAGE_VERSION << "\n ";
+ OS << PACKAGE_NAME << " version " << PACKAGE_VERSION;
+#ifdef LLVM_REPOSITORY
+ OS << " (" << LLVM_REPOSITORY;
+#ifdef LLVM_REVISION
+ OS << ' ' << LLVM_REVISION;
+#endif
+ OS << ')';
+#endif
+ OS << "\n ";
#if LLVM_IS_DEBUG_BUILD
OS << "DEBUG build";
#else
>From 01b1ebd8da4b51bd4137f3656623c3e995b05937 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Wed, 13 Mar 2024 10:19:25 -0700
Subject: [PATCH 2/2] Add dependency on llvm_vcsrevision_h
---
llvm/lib/Support/CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 1f2d82427552f7..b9c13c43e9a7c5 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -286,6 +286,9 @@ add_llvm_component_library(LLVMSupport
${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
${Backtrace_INCLUDE_DIRS}
+ DEPENDS
+ llvm_vcsrevision_h
+
LINK_LIBS
${system_libs} ${imported_libs} ${delayload_flags}
More information about the llvm-commits
mailing list