<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70736>70736</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [front-end][PCH] Precompiled header version check is too strict
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:PCH
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          huangjd
      </td>
    </tr>
</table>

<pre>
    In `clang/lib/Serialization/ASTReader.cpp` near line 3009 
```const std::string &CurBranch = getClangFullRepositoryVersion();
      StringRef ASTBranch = Blob;
      if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
        if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
          Diag(diag::err_pch_different_branch) << ASTBranch << CurBranch;
        return VersionMismatch;
 }```

It is checking if a PCH file is generated by the same compiler built by the same commit that's compiling the source code, and exits with error if version mismatch. This check is way too strict than necessary because in most cases PCH format doesn't change between commits, and it should use its own internal versioning instead of depending on the commit's hash. 

This overly strict check possibly has a significant impact on many organizations using LLVM, on how they set up their build system.  There is an option to disable this check but it also disables other validation which is probably not wanted. It also seems that only at this particular location in the entire LLVM project checks for commit revision, instead of a more stable version number for compatibility validation purpose. 





</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxkVV-P4roP_TThxVpUUijwwAMDQrvSrrSaGe3ryG1Mm_2lSRW78Ov99FdpgflzEWqrxD72OY5jZLa1J9qp1ZNaHWfYSxPirunR13_NrAxm2P3woIqscuhrpU_OlkqfXihadPYfFBu80qf9y-szoaE4r7pOFRl4wgjOeoI8y7agsqPK9qrIpn8VPAuwGJXvVb5nidbXoHRx6ONTRF81oPIj1CSHFPbUO_dMXWArIQ5_KPIYdaP0VuVPEzaMv5cR6ZnOsH95_YD05EL5xdSeQenNw0HpzSO40ltQepEcP8DoQukirR8tY-noDzprbgJsQa0_od_xE6yz5OVnQHPADkv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