[llvm] 6885810 - [llvm] Include LLVM_REPOSITORY and LLVM_REVISION in tool version (#84990)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 15:33:16 PDT 2024


Author: Jonas Devlieghere
Date: 2024-03-13T15:33:11-07:00
New Revision: 6885810e7de283ee8d3c8fc328a98544970b3db6

URL: https://github.com/llvm/llvm-project/commit/6885810e7de283ee8d3c8fc328a98544970b3db6
DIFF: https://github.com/llvm/llvm-project/commit/6885810e7de283ee8d3c8fc328a98544970b3db6.diff

LOG: [llvm] Include LLVM_REPOSITORY and LLVM_REVISION in tool version (#84990)

Include the `LLVM_REPOSITORY` and `LLVM_REVISION` in the version output
of tools using `cl::PrintVersionMessage()` such as dwarfdump and
dsymutil.

Before:

```
$ llvm-dwarfdump --version
LLVM (http://llvm.org/):
  LLVM version 19.0.0git
  Optimized build with assertions.
```

After:

```
$ llvm-dwarfdump --version
LLVM (http://llvm.org/):
  LLVM version 19.0.0git (git at github.com:llvm/llvm-project.git 8467457afc61d70e881c9817ace26356ef757733)
  Optimized build with assertions.
```

rdar://121526866

Added: 
    

Modified: 
    llvm/lib/Support/CMakeLists.txt
    llvm/lib/Support/CommandLine.cpp

Removed: 
    


################################################################################
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}
 

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


        


More information about the llvm-commits mailing list