r222507 - [modules] When explicitly importing a module, it's fine for the imported module

Richard Smith richard-llvm at metafoo.co.uk
Thu Nov 20 21:37:21 PST 2014


Author: rsmith
Date: Thu Nov 20 23:37:20 2014
New Revision: 222507

URL: http://llvm.org/viewvc/llvm-project?rev=222507&view=rev
Log:
[modules] When explicitly importing a module, it's fine for the imported module
to be newer than we were expecting. That happens if .pcm's get moved between
file systems during a distributed build. (It's still not OK for them to actually
be different, though, so we still check the size and signature matches.)

Modified:
    cfe/trunk/lib/Serialization/ModuleManager.cpp
    cfe/trunk/test/Modules/explicit-build.cpp

Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=222507&r1=222506&r2=222507&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Thu Nov 20 23:37:20 2014
@@ -67,6 +67,13 @@ ModuleManager::addModule(StringRef FileN
   // Look for the file entry. This only fails if the expected size or
   // modification time differ.
   const FileEntry *Entry;
+  if (Type == MK_ExplicitModule) {
+    // If we're not expecting to pull this file out of the module cache, it
+    // might have a different mtime due to being moved across filesystems in
+    // a distributed build. The size must still match, though. (As must the
+    // contents, but we can't check that.)
+    ExpectedModTime = 0;
+  }
   if (lookupModuleFile(FileName, ExpectedSize, ExpectedModTime, Entry)) {
     ErrorStr = "module file out of date";
     return OutOfDate;

Modified: cfe/trunk/test/Modules/explicit-build.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/explicit-build.cpp?rev=222507&r1=222506&r2=222507&view=diff
==============================================================================
--- cfe/trunk/test/Modules/explicit-build.cpp (original)
+++ cfe/trunk/test/Modules/explicit-build.cpp Thu Nov 20 23:37:20 2014
@@ -153,3 +153,23 @@
 // RUN:            %s 2>&1 | FileCheck --check-prefix=CHECK-BAD-FILE %s
 //
 // CHECK-BAD-FILE: fatal error: file '{{.*}}t.pcm' is not a precompiled module file
+
+// -------------------------------
+// Check that we don't get upset if B's timestamp is newer than C's.
+// RUN: touch %t/b.pcm
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=%t/c.pcm \
+// RUN:            -verify %s -DHAVE_A -DHAVE_B -DHAVE_C
+//
+// ... but that we do get upset if our B is different from the B that C expects.
+//
+// RUN: cp %t/b-not-a.pcm %t/b.pcm
+//
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=%t/c.pcm \
+// RUN:            %s -DHAVE_A -DHAVE_B -DHAVE_C 2>&1 | FileCheck --check-prefix=CHECK-MISMATCHED-B %s
+//
+// CHECK-MISMATCHED-B: fatal error: malformed or corrupted AST file: {{.*}}b.pcm": module file out of date





More information about the cfe-commits mailing list