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();


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();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to