Skip to content

Commit 6885810

Browse files
authored
[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 ([email protected]:llvm/llvm-project.git 8467457) Optimized build with assertions. ``` rdar://121526866
1 parent 35db929 commit 6885810

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

llvm/lib/Support/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ add_llvm_component_library(LLVMSupport
286286
${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
287287
${Backtrace_INCLUDE_DIRS}
288288

289+
DEPENDS
290+
llvm_vcsrevision_h
291+
289292
LINK_LIBS
290293
${system_libs} ${imported_libs} ${delayload_flags}
291294

llvm/lib/Support/CommandLine.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "llvm/Support/Path.h"
4040
#include "llvm/Support/Process.h"
4141
#include "llvm/Support/StringSaver.h"
42+
#include "llvm/Support/VCSRevision.h"
4243
#include "llvm/Support/VirtualFileSystem.h"
4344
#include "llvm/Support/raw_ostream.h"
4445
#include <cstdlib>
@@ -2538,7 +2539,15 @@ class VersionPrinter {
25382539
#else
25392540
OS << "LLVM (http://llvm.org/):\n ";
25402541
#endif
2541-
OS << PACKAGE_NAME << " version " << PACKAGE_VERSION << "\n ";
2542+
OS << PACKAGE_NAME << " version " << PACKAGE_VERSION;
2543+
#ifdef LLVM_REPOSITORY
2544+
OS << " (" << LLVM_REPOSITORY;
2545+
#ifdef LLVM_REVISION
2546+
OS << ' ' << LLVM_REVISION;
2547+
#endif
2548+
OS << ')';
2549+
#endif
2550+
OS << "\n ";
25422551
#if LLVM_IS_DEBUG_BUILD
25432552
OS << "DEBUG build";
25442553
#else

0 commit comments

Comments
 (0)