[PATCH] D22636: Module: retry building modules that were just compiled by the same instance and are are out of date

Manman Ren via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 21 11:15:45 PDT 2016


manmanren created this revision.
manmanren added reviewers: benlangmuir, rsmith.
manmanren added a subscriber: cfe-commits.

Even though this instance just built module "A", it is likely that "A" imports another module "B" and B.pcm becomes out of date when we try to load module "A", because another instance overwrites "B.pcm" due to changes in warning options. This patch tries to fix the error: "Module file ‘<some-file path>.pcm' is out of date and needs to be rebuilt" by simply trying again.

This seems to be the last case where we call ReadAST without the ability to handle out-of-date.

If there are other ways to fix the issue, please let me know.
Also I don't quite know how to add a testing case when two compiling instances are involved and running in parallel.

rdar://problem/26676111

https://reviews.llvm.org/D22636

Files:
  lib/Frontend/CompilerInstance.cpp

Index: lib/Frontend/CompilerInstance.cpp
===================================================================
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -1096,6 +1096,7 @@
         diagnoseBuildFailure();
         return false;
       }
+      ModuleLoadCapabilities |= ASTReader::ARR_OutOfDate;
       break;
 
     case llvm::LockFileManager::LFS_Shared:
@@ -1124,10 +1125,14 @@
             ModuleLoadCapabilities);
 
     if (ReadResult == ASTReader::OutOfDate &&
-        Locked == llvm::LockFileManager::LFS_Shared) {
+        (Locked == llvm::LockFileManager::LFS_Shared ||
+         Locked == llvm::LockFileManager::LFS_Owned)) {
       // The module may be out of date in the presence of file system races,
       // or if one of its imports depends on header search paths that are not
       // consistent with this ImportingInstance.  Try again...
+
+      // The module may be out of date right after we rebuild it if a module
+      // it imports is overwritten by another process. Try again...
       continue;
     } else if (ReadResult == ASTReader::Missing) {
       diagnoseBuildFailure();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22636.64925.patch
Type: text/x-patch
Size: 1143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160721/1b0560ec/attachment.bin>


More information about the cfe-commits mailing list