[PATCH] D104465: [clang][deps] Prevent PCH validation failures by padding minimized files

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 17 11:43:11 PDT 2021


dexonsmith added a comment.

> This patch fixes dependency scanning of a TU with prebuilt modular/PCH dependencies.
>
> Such modules/PCH might have been built using non-minimized files, while dependency scanner does use the minimized versions of source files. Implicit build doesn't like the discrepancy in file sizes and errors out.
>
> The issues is worked around by padding the minimized files with whitespace in such scenarios. This approach throws away one advantage of source minimization (the memory savings), but still keeps the benefits of faster preprocessing/lexing.

I'm not sure this is the right approach.

- Don't PCHs sometimes validate based on hashes of inputs instead of size? At least, that has been discussed, and this patch would block making the change.
- Can PCHs embed inputs, like modules can? How would that work (or not) minimized sources generally?
- What happens if the PCH has a delayed diagnostic, triggered when parsing the next thing? Will the fix-it point in the wrong place? (Are there other things that depend on reading the original sources when reading a PCH?)

A few other ideas:

1. Disable PCH validation when minimizing. (Is that less robust than your current workaround? If so, can you explain why?)
2. Use the original PCH header in the scanning `-cc1`s (translate `-include-pch` to `-include`) and switch back in the generated `-cc1`s (back to `-include-pch`).
3. Embed instructions in the PCH for how to build it, and make a "minimized" version of the PCH.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104465



More information about the cfe-commits mailing list