Skip to content

Commit 0777c90

Browse files
nicotstellar
authored andcommitted
Make LLVM_APPEND_VC_REV=OFF affect clang, lld, and lldb as well.
When LLVM_APPEND_VC_REV=OFF is set, the current git hash is no longer embedded into binaries (mostly for --version output). Without it, most binaries need to relink after every single commit, even if they didn't change otherwise (due to, say, a documentation-only commit). LLVM_APPEND_VC_REV is ON by default, so this doesn't change the default behavior of anything. With this, all clients of GenerateVersionFromVCS.cmake honor LLVM_APPEND_VC_REV. Differential Revision: https://reviews.llvm.org/D72855 (cherry picked from commit fb5fafb)
1 parent 9706568 commit 0777c90

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

clang/lib/Basic/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
1212

1313
set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
1414

15-
if(llvm_vc)
15+
if(llvm_vc AND LLVM_APPEND_VC_REV)
1616
set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
1717
endif()
18-
if(clang_vc)
18+
if(clang_vc AND LLVM_APPEND_VC_REV)
1919
set(clang_source_dir ${CLANG_SOURCE_DIR})
2020
endif()
2121

lld/Common/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ find_first_existing_vc_file("${LLD_SOURCE_DIR}" lld_vc)
88
set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
99
set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
1010

11-
if(lld_vc)
11+
if(lld_vc AND LLVM_APPEND_VC_REV)
1212
set(lld_source_dir ${LLD_SOURCE_DIR})
1313
endif()
1414

1515
add_custom_command(OUTPUT "${version_inc}"
1616
DEPENDS "${lld_vc}" "${generate_vcs_version_script}"
1717
COMMAND ${CMAKE_COMMAND} "-DNAMES=LLD"
18-
"-DLLD_SOURCE_DIR=${LLD_SOURCE_DIR}"
18+
"-DLLD_SOURCE_DIR=${lld_source_dir}"
1919
"-DHEADER_FILE=${version_inc}"
2020
-P "${generate_vcs_version_script}")
2121

lldb/source/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ endforeach()
1818
set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
1919
set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
2020

21-
if(lldb_vc)
21+
if(lldb_vc AND LLVM_APPEND_VC_REV)
2222
set(lldb_source_dir ${LLDB_SOURCE_DIR})
2323
endif()
2424

2525
add_custom_command(OUTPUT "${version_inc}"
2626
DEPENDS "${lldb_vc}" "${generate_vcs_version_script}"
2727
COMMAND ${CMAKE_COMMAND} "-DNAMES=LLDB"
28-
"-DLLDB_SOURCE_DIR=${LLDB_SOURCE_DIR}"
28+
"-DLLDB_SOURCE_DIR=${lldb_source_dir}"
2929
"-DHEADER_FILE=${version_inc}"
3030
-P "${generate_vcs_version_script}")
3131

llvm/cmake/modules/LLVMConfig.cmake.in

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ set(LLVM_LIBDIR_SUFFIX @LLVM_LIBDIR_SUFFIX@)
7878
set(LLVM_INCLUDE_DIRS "@LLVM_CONFIG_INCLUDE_DIRS@")
7979
set(LLVM_LIBRARY_DIRS "@LLVM_CONFIG_LIBRARY_DIRS@")
8080

81+
set(LLVM_APPEND_VC_REV "@LLVM_APPEND_VC_REV@")
82+
8183
# These variables are duplicated for install tree but they have different
8284
# values for build tree. LLVM_INCLUDE_DIRS contains both source
8385
# and generated include directories while the following variables have

llvm/docs/CMake.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ LLVM-specific variables
272272
Generate build targets for the LLVM benchmarks. Defaults to ON.
273273

274274
**LLVM_APPEND_VC_REV**:BOOL
275-
Embed version control revision info (svn revision number or Git revision id).
275+
Embed version control revision info (Git revision id).
276276
The version info is provided by the ``LLVM_REVISION`` macro in
277277
``llvm/include/llvm/Support/VCSRevision.h``. Developers using git who don't
278278
need revision info can disable this option to avoid re-linking most binaries

0 commit comments

Comments
 (0)