Go to file
Brian Gesiak 7873d822f7 [Basic] Detect Git submodule version in CMake
Summary:
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.

To fix, check whether '.git' is a directory or a file. If it's a
directory, simply use the '.git/logs/HEAD' path. If it's a file, read it
and check for the tell-tale sign of a Git submodule: the text "gitdir:".
If it exists, follow that path and use the 'logs/HEAD' at that location
instead. This allows not only the correct revision information to be
retrieved, but also uses a file that will change with each source
control revision.

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).

Reviewers: jordan_rose, beanz, probinson

Reviewed By: jordan_rose

Subscribers: chapuni, mgorny, cfe-commits

Differential Revision: https://reviews.llvm.org/D34955

llvm-svn: 308205
2017-07-17 19:22:57 +00:00
clang [Basic] Detect Git submodule version in CMake 2017-07-17 19:22:57 +00:00
clang-tools-extra [NFC] Update function call names as changed in MacroInfo that should refer to Parameters (as opposed to Arguments). 2017-07-17 17:20:57 +00:00
compiler-rt [asan] Disable not working new test on Windows 2017-07-16 01:28:40 +00:00
debuginfo-tests Add a test for PR33166. 2017-05-25 19:33:16 +00:00
libclc generic: add missing get_work_dim include 2017-06-02 15:58:35 +00:00
libcxx Add case for c++2a to libc++ and test macros 2017-07-17 03:02:27 +00:00
libcxxabi [demangler] Respect try_to_parse_template_args 2017-07-13 19:37:37 +00:00
libunwind [libunwind][CMake] Add install path variable to allow overriding the destination 2017-07-11 01:12:09 +00:00
lld [ELF] Introduce target specific inBranchRange() function 2017-07-17 16:54:29 +00:00
lldb Fix debugserver accepting remote connections 2017-07-13 20:58:13 +00:00
llgo irgen: Create functions instead of global variables for builtin hash and equal algorithms. 2017-06-04 22:11:28 +00:00
llvm [ORC] Remove extraneous else. 2017-07-17 18:36:35 +00:00
openmp Removed "duplicates" from verbose affinity output 2017-07-17 17:06:43 +00:00
parallel-libs [Axccel] Remove -Wno-missing-braces in build 2016-12-19 21:34:07 +00:00
polly [PPCGCodeGeneration] Generate invariant loads before trying to generate IR. 2017-07-17 15:57:01 +00:00