[PATCH] D79400: [CMAKE] Fix build failure when source directory is read only

Pushpinder Singh via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 15 03:02:44 PDT 2020


pdhaliwal added a comment.

I understand that `.git/logs/HEAD` acts as a dependency for `vcs_revision_h` target. However, problem here is that cmake fails when it tries to create `.git/logs/HEAD` in read-only filesystem.

I had following ideas for solving above issue,

1. Skip creating `.git/logs/HEAD` whenever a cmake variable (say, LLVM_SKIP_VC_HEAD_CHECK) is turned `On`.
2. Remove the creation of `.git/logs/HEAD`.
  - So, in cases of normal checkout, `.git/logs/HEAD` will added as dependency to generation script and hence latter will not be triggered for every build.
  - In case of `repo` based checkout, the file will not be created and hence will not be a dependency to generation script. In this scenario, script will be triggered for every build, but will not generate header if HEAD does not change as GenerateVersionFromVCS.cmake#L49 <https://github.com/llvm/llvm-project/blob/969c63a2ecfb536062ff2174645abe31e4036067/llvm/cmake/modules/GenerateVersionFromVCS.cmake#L49> will take care.
3. Another way is to gracefully handle the `file` write error, for which I don't think there is a portable way. (which @scott.linder also suggested)
4. Last way will be to check if we have write permissions, which again is also not portable.

Please suggest if there might exist some other solution. This patch simply implements solution number 2.

Also, could you elaborate more on "avoid running `git rev-parse HEAD` for every build"? I think it should not harm the build time in such a bad way or maybe I am missing something.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79400/new/

https://reviews.llvm.org/D79400





More information about the cfe-commits mailing list