Skip to content

Commit d8a7634

Browse files
committed
[llvm] Include LLVM_REPOSITORY and LLVM_REVISION in tool version (llvm#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 (cherry picked from commit 6885810)
1 parent 1c41e44 commit d8a7634

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
@@ -279,6 +279,9 @@ add_llvm_component_library(LLVMSupport
279279
${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
280280
${Backtrace_INCLUDE_DIRS}
281281

282+
DEPENDS
283+
llvm_vcsrevision_h
284+
282285
LINK_LIBS
283286
${system_libs} ${imported_libs} ${delayload_flags}
284287

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>
@@ -2544,7 +2545,15 @@ class VersionPrinter {
25442545
#else
25452546
OS << "LLVM (http://llvm.org/):\n ";
25462547
#endif
2547-
OS << PACKAGE_NAME << " version " << PACKAGE_VERSION << "\n ";
2548+
OS << PACKAGE_NAME << " version " << PACKAGE_VERSION;
2549+
#ifdef LLVM_REPOSITORY
2550+
OS << " (" << LLVM_REPOSITORY;
2551+
#ifdef LLVM_REVISION
2552+
OS << ' ' << LLVM_REVISION;
2553+
#endif
2554+
OS << ')';
2555+
#endif
2556+
OS << "\n ";
25482557
#if LLVM_IS_DEBUG_BUILD
25492558
OS << "DEBUG build";
25502559
#else

0 commit comments

Comments
 (0)