[clang] [llvm] [clang][Driver] Don't ignore -gmodules .gch files (PR #77711)

Michael Spencer via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 11 03:39:32 PST 2024


Bigcheese wrote:

> What does the code that reads these files look like, could we leverage that somehow?

You can call `clang::ObjectFilePCHContainerReader::ExtractPCH()` and then check the magic. This lives in the CodeGen library which I don't think the driver currently (or should) links against, but this is the best way to know if something is valid.
 
> An alternative would be turn the logic around, and only ignore GCC PCH files (I believe they all start with the file magic `gpch`). However I do think that the current approach of "whitelisting" the kind of file we're looking for is better.

I would be fine with this approach, but agree that it's best if we can be more selective. My concern is that `clang::ObjectFilePCHContainerReader::ExtractPCH()` and this detection may get out of sync, as support for `-gmodules` is automatic anytime someone adds a new object format.

https://github.com/llvm/llvm-project/pull/77711


More information about the cfe-commits mailing list