[PATCH] D101758: [clang][modules] Add -cc1 option to backup PCM files

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 3 07:14:47 PDT 2021


jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added a subscriber: dang.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

During a highly parallel build with `-fimplicit-modules`, multiple translation units may generate a PCM file for the same module at the same filesystem path in a short sequence.

When the first Clang instance tries to verify signature of the module on import, it discovers the new version of the PCM file (produced by latter Clang instance) that may have a different signature, leading to a mismatch and failed build.

To be able to debug such mismatch, it's invaluable to be able to compare the latter PCM (on disk) with the first one (overwritten).

This patch adds new -cc1 option `-fbackup-module` that tells Clang to store each PCM to the normal location **and** also to a path with an unique suffix (the PID of the Clang instance).

This is mostly additional change, but `PCHContainerGenerator` now doesn't unconditionally destroy the given `PCHBuffer` anymore and instead just decreases its reference count.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101758

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Serialization/PCHContainerOperations.cpp
  clang/test/Modules/backup-module.c
  clang/test/Modules/backup-module.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101758.342378.patch
Type: text/x-patch
Size: 7826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210503/5d7156a9/attachment-0001.bin>


More information about the cfe-commits mailing list