modocache created this revision. Herald added a subscriber: mgorny. When searching for Git version control information, libBasic's CMake checks for the path '.git/logs/HEAD'. However, when LLVM is included as a Git submodule, this path does not exist. Instead, it contains a '.git' file with the following:
gitdir: ../../.git/modules/external/llvm Where '../..' is the relative path to the root repository that contains the LLVM Git submodule. Because of this discrepancy, `clang --version` does not output source control information if built from a Git submodule. The full '.git/logs/HEAD' path is only used to gate the invocation of LLVM CMake's GetSVN.cmake script, which is invoked using the `LLVM_MAIN_SRC_DIR` and `CLANG_SOURCE_DIR` paths, which point to the right places even when Clang is built as a submodule. Once invoked with these paths, GetSVN.cmake works just fine, and correct version control information is retrieved, even when Clang is built as a submodule. To work around the problem, truncate the path being checked for: just '.git' instead of '.git/logs/HEAD'. Test Plan: 1. Before applying this change, build Clang as a Git submodule in a repository that places it in external/clang, and confirm no revision information is output when `clang --version` is invoked (just "clang 5.0.0" is output, no Git hashes). 2. Apply these changes and build Clang as a Git repository nested under llvm/tools/clang, and confirm that `clang --version` displays correct version information. 3. Apply these changes and build Clang as a Git submodule using the structure described in (1), and confirm version control information is output as in (2). https://reviews.llvm.org/D34955 Files: lib/Basic/CMakeLists.txt Index: lib/Basic/CMakeLists.txt =================================================================== --- lib/Basic/CMakeLists.txt +++ lib/Basic/CMakeLists.txt @@ -16,7 +16,7 @@ macro(find_first_existing_vc_file out_var path) find_first_existing_file(${out_var} - "${path}/.git/logs/HEAD" # Git + "${path}/.git" # Git "${path}/.svn/wc.db" # SVN 1.7 "${path}/.svn/entries" # SVN 1.6 )
Index: lib/Basic/CMakeLists.txt =================================================================== --- lib/Basic/CMakeLists.txt +++ lib/Basic/CMakeLists.txt @@ -16,7 +16,7 @@ macro(find_first_existing_vc_file out_var path) find_first_existing_file(${out_var} - "${path}/.git/logs/HEAD" # Git + "${path}/.git" # Git "${path}/.svn/wc.db" # SVN 1.7 "${path}/.svn/entries" # SVN 1.6 )
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits