<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Oct 23, 2014 at 11:41 AM, Ben Langmuir <span dir="ltr"><<a href="mailto:blangmuir@apple.com" target="_blank">blangmuir@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Oct 23, 2014, at 11:24 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 23, 2014 at 11:05 AM, Ben Langmuir <span dir="ltr"><<a href="mailto:blangmuir@apple.com" target="_blank">blangmuir@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: benlangmuir<br>
Date: Thu Oct 23 13:05:36 2014<br>
New Revision: 220493<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=220493&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=220493&view=rev</a><br>
Log:<br>
Add a "signature" to AST files to verify that they haven't changed<br>
<br>
Since the order of the IDs in the AST file (e.g. DeclIDs, SelectorIDs)<br>
is not stable,</blockquote><div><br>Um... when you say "not stable" what do you mean? (& when you say "nothing changed" what do you mean)<br></div></div></div></div></div></blockquote><div><br></div></span><div>Identifiers, decls, macros, etc. are referred to by ID numbers, which depend on the order the entity is looked at during serialization. This in turn often depends on hash-table iteration order and is not stable across runs. When a module refers to a name in one of its imports, it will find the wrong name if the order has changed since it was first built.</div><div><br></div><div>By “not changed” I mean that the sources have not changed.</div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>It's pretty important that the compiler produces identical bytes given identical input. We're pretty clear about fixing any cases where it doesn't (but maybe we haven't been as rigorous about that with AST serialization? I don't know - I'b be a bit scared if we haven’t)<br></div></div></div></div></div></blockquote><div><br></div></span><div>Maybe someone more familiar with the history of the ASTWriter can comment? +rsmith, +dgregor, +akyrtzidis</div></div></div></blockquote><div><br></div><div>Non-deterministic output is a bug, but it's been lower priority than other stuff I've been looking at up until now. It's likely to get near the top of my priority stack fairly soon. So... this patch is /technically/ making that existing problem worse by adding more nondeterminism to the output, but since it's also fixing an immediate problem, I suggest we keep this change in place until we've fixed the other nondeterminism, then revert it.</div><div><br></div><div>Does that seem reasonable?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div>I briefly looked at making the IDs deterministic, but I saw several hash tables being iterated over with no apparently guarantee of order, and figured we were not trying to produce identical bytes. We certainly *aren’t* producing identical bytes, and when this happens it causes utter insanity.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Ben</div></font></span><div><div class="h5"><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> it is not safe to load an AST file that depends on<br>
another AST file that has been rebuilt since the importer was built,<br>
even if "nothing changed". We previously used size and modtime to check<br>
this, but I've seen cases where a module rebuilt quickly enough to foil<br>
this check and caused very hard to debug build errors.<br>
<br>
To save cycles when we're loading the AST, we just generate a random<br>
nonce value and check that it hasn't changed when we load an imported<br>
module, rather than actually hash the whole file.<br>
<br>
This is slightly complicated by the fact that we need to verify the<br>
signature inside addModule, since we might otherwise consider that a<br>
mdoule is "OutOfDate" when really it is the importer that is out of<br>
date. I didn't see any regressions in module load time after this<br>
change.<br>
<br>
Added:<br>
cfe/trunk/test/Modules/rebuild.m<br>
Modified:<br>
cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br>
cfe/trunk/include/clang/Serialization/ASTReader.h<br>
cfe/trunk/include/clang/Serialization/Module.h<br>
cfe/trunk/include/clang/Serialization/ModuleManager.h<br>
cfe/trunk/lib/Serialization/ASTReader.cpp<br>
cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp<br>
cfe/trunk/lib/Serialization/Module.cpp<br>
cfe/trunk/lib/Serialization/ModuleManager.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=220493&r1=220492&r2=220493&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=220493&r1=220492&r2=220493&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)<br>
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Thu Oct 23 13:05:36 2014<br>
@@ -288,7 +288,10 @@ namespace clang {<br>
<br>
/// \brief Record code for the module map file that was used to build this<br>
/// AST file.<br>
- MODULE_MAP_FILE = 14<br>
+ MODULE_MAP_FILE = 14,<br>
+<br>
+ /// \brief Record code for the signature that identifiers this AST file.<br>
+ SIGNATURE = 15<br>
};<br>
<br>
/// \brief Record types that occur within the input-files block<br>
<br>
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=220493&r1=220492&r2=220493&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=220493&r1=220492&r2=220493&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)<br>
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Oct 23 13:05:36 2014<br>
@@ -1125,6 +1125,7 @@ private:<br>
SourceLocation ImportLoc, ModuleFile *ImportedBy,<br>
SmallVectorImpl<ImportedModule> &Loaded,<br>
off_t ExpectedSize, time_t ExpectedModTime,<br>
+ serialization::ASTFileSignature ExpectedSignature,<br>
unsigned ClientLoadCapabilities);<br>
ASTReadResult ReadControlBlock(ModuleFile &F,<br>
SmallVectorImpl<ImportedModule> &Loaded,<br>
<br>
Modified: cfe/trunk/include/clang/Serialization/Module.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=220493&r1=220492&r2=220493&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=220493&r1=220492&r2=220493&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Serialization/Module.h (original)<br>
+++ cfe/trunk/include/clang/Serialization/Module.h Thu Oct 23 13:05:36 2014<br>
@@ -97,6 +97,8 @@ public:<br>
bool isNotFound() const { return Val.getInt() == NotFound; }<br>
};<br>
<br>
+typedef unsigned ASTFileSignature;<br>
+<br>
/// \brief Information about a module that has been loaded by the ASTReader.<br>
///<br>
/// Each instance of the Module class corresponds to a single AST file, which<br>
@@ -152,6 +154,10 @@ public:<br>
/// \brief The file entry for the module file.<br>
const FileEntry *File;<br>
<br>
+ /// \brief The signature of the module file, which may be used along with size<br>
+ /// and modification time to identify this particular file.<br>
+ ASTFileSignature Signature;<br>
+<br>
/// \brief Whether this module has been directly imported by the<br>
/// user.<br>
bool DirectlyImported;<br>
<br>
Modified: cfe/trunk/include/clang/Serialization/ModuleManager.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ModuleManager.h?rev=220493&r1=220492&r2=220493&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ModuleManager.h?rev=220493&r1=220492&r2=220493&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Serialization/ModuleManager.h (original)<br>
+++ cfe/trunk/include/clang/Serialization/ModuleManager.h Thu Oct 23 13:05:36 2014<br>
@@ -179,6 +179,12 @@ public:<br>
/// \param ExpectedModTime The expected modification time of the module<br>
/// file, used for validation. This will be zero if unknown.<br>
///<br>
+ /// \param ExpectedSignature The expected signature of the module file, used<br>
+ /// for validation. This will be zero if unknown.<br>
+ ///<br>
+ /// \param ReadSignature Reads the signature from an AST file without actually<br>
+ /// loading it.<br>
+ ///<br>
/// \param Module A pointer to the module file if the module was successfully<br>
/// loaded.<br>
///<br>
@@ -191,6 +197,9 @@ public:<br>
SourceLocation ImportLoc,<br>
ModuleFile *ImportedBy, unsigned Generation,<br>
off_t ExpectedSize, time_t ExpectedModTime,<br>
+ ASTFileSignature ExpectedSignature,<br>
+ std::function<ASTFileSignature(llvm::BitstreamReader &)><br>
+ ReadSignature,<br>
ModuleFile *&Module,<br>
std::string &ErrorStr);<br>
<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=220493&r1=220492&r2=220493&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=220493&r1=220492&r2=220493&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 23 13:05:36 2014<br>
@@ -2363,6 +2363,11 @@ ASTReader::ReadControlBlock(ModuleFile &<br>
break;<br>
}<br>
<br>
+ case SIGNATURE:<br>
+ assert((!F.Signature || F.Signature == Record[0]) && "signature changed");<br>
+ F.Signature = Record[0];<br>
+ break;<br>
+<br>
case IMPORTS: {<br>
// Load each of the imported PCH files.<br>
unsigned Idx = 0, N = Record.size();<br>
@@ -2376,6 +2381,7 @@ ASTReader::ReadControlBlock(ModuleFile &<br>
SourceLocation::getFromRawEncoding(Record[Idx++]);<br>
off_t StoredSize = (off_t)Record[Idx++];<br>
time_t StoredModTime = (time_t)Record[Idx++];<br>
+ ASTFileSignature StoredSignature = Record[Idx++];<br>
unsigned Length = Record[Idx++];<br>
SmallString<128> ImportedFile(Record.begin() + Idx,<br>
Record.begin() + Idx + Length);<br>
@@ -2383,7 +2389,7 @@ ASTReader::ReadControlBlock(ModuleFile &<br>
<br>
// Load the AST file.<br>
switch(ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F, Loaded,<br>
- StoredSize, StoredModTime,<br>
+ StoredSize, StoredModTime, StoredSignature,<br>
ClientLoadCapabilities)) {<br>
case Failure: return Failure;<br>
// If we have to ignore the dependency, we'll have to ignore this too.<br>
@@ -3552,7 +3558,7 @@ ASTReader::ASTReadResult ASTReader::Read<br>
SmallVector<ImportedModule, 4> Loaded;<br>
switch(ASTReadResult ReadResult = ReadASTCore(FileName, Type, ImportLoc,<br>
/*ImportedBy=*/nullptr, Loaded,<br>
- 0, 0,<br>
+ 0, 0, 0,<br>
ClientLoadCapabilities)) {<br>
case Failure:<br>
case Missing:<br>
@@ -3719,6 +3725,8 @@ ASTReader::ASTReadResult ASTReader::Read<br>
return Success;<br>
}<br>
<br>
+static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile);<br>
+<br>
ASTReader::ASTReadResult<br>
ASTReader::ReadASTCore(StringRef FileName,<br>
ModuleKind Type,<br>
@@ -3726,12 +3734,14 @@ ASTReader::ReadASTCore(StringRef FileNam<br>
ModuleFile *ImportedBy,<br>
SmallVectorImpl<ImportedModule> &Loaded,<br>
off_t ExpectedSize, time_t ExpectedModTime,<br>
+ ASTFileSignature ExpectedSignature,<br>
unsigned ClientLoadCapabilities) {<br>
ModuleFile *M;<br>
std::string ErrorStr;<br>
ModuleManager::AddModuleResult AddResult<br>
= ModuleMgr.addModule(FileName, Type, ImportLoc, ImportedBy,<br>
getGeneration(), ExpectedSize, ExpectedModTime,<br>
+ ExpectedSignature, readASTFileSignature,<br>
M, ErrorStr);<br>
<br>
switch (AddResult) {<br>
@@ -4029,6 +4039,34 @@ static bool SkipCursorToBlock(BitstreamC<br>
}<br>
}<br>
<br>
+static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile){<br>
+ BitstreamCursor Stream(StreamFile);<br>
+ if (Stream.Read(8) != 'C' ||<br>
+ Stream.Read(8) != 'P' ||<br>
+ Stream.Read(8) != 'C' ||<br>
+ Stream.Read(8) != 'H') {<br>
+ return 0;<br>
+ }<br>
+<br>
+ // Scan for the CONTROL_BLOCK_ID block.<br>
+ if (SkipCursorToBlock(Stream, CONTROL_BLOCK_ID))<br>
+ return 0;<br>
+<br>
+ // Scan for SIGNATURE inside the control block.<br>
+ ASTReader::RecordData Record;<br>
+ while (1) {<br>
+ llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();<br>
+ if (Entry.Kind == llvm::BitstreamEntry::EndBlock ||<br>
+ Entry.Kind != llvm::BitstreamEntry::Record)<br>
+ return 0;<br>
+<br>
+ Record.clear();<br>
+ StringRef Blob;<br>
+ if (SIGNATURE == Stream.readRecord(Entry.ID, Record, &Blob))<br>
+ return Record[0];<br>
+ }<br>
+}<br>
+<br>
/// \brief Retrieve the name of the original source file name<br>
/// directly from the AST file, without actually loading the AST<br>
/// file.<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=220493&r1=220492&r2=220493&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=220493&r1=220492&r2=220493&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Oct 23 13:05:36 2014<br>
@@ -51,6 +51,7 @@<br>
#include "llvm/Support/MemoryBuffer.h"<br>
#include "llvm/Support/OnDiskHashTable.h"<br>
#include "llvm/Support/Path.h"<br>
+#include "llvm/Support/Process.h"<br>
#include <algorithm><br>
#include <cstdio><br>
#include <string.h><br>
@@ -862,6 +863,7 @@ void ASTWriter::WriteBlockInfoBlock() {<br>
// Control Block.<br>
BLOCK(CONTROL_BLOCK);<br>
RECORD(METADATA);<br>
+ RECORD(SIGNATURE);<br>
RECORD(MODULE_NAME);<br>
RECORD(MODULE_MAP_FILE);<br>
RECORD(IMPORTS);<br>
@@ -1092,6 +1094,14 @@ adjustFilenameForRelocatablePCH(const ch<br>
return Filename + Pos;<br>
}<br>
<br>
+static ASTFileSignature getSignature() {<br>
+ while (1) {<br>
+ if (ASTFileSignature S = llvm::sys::Process::GetRandomNumber())<br>
+ return S;<br>
+ // Rely on GetRandomNumber to eventually return non-zero...<br>
+ }<br>
+}<br>
+<br>
/// \brief Write the control block.<br>
void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,<br>
StringRef isysroot,<br>
@@ -1121,6 +1131,11 @@ void ASTWriter::WriteControlBlock(Prepro<br>
Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,<br>
getClangFullRepositoryVersion());<br>
<br>
+ // Signature<br>
+ Record.clear();<br>
+ Record.push_back(getSignature());<br>
+ Stream.EmitRecord(SIGNATURE, Record);<br>
+<br>
// Module name<br>
if (WritingModule) {<br>
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();<br>
@@ -1173,6 +1188,7 @@ void ASTWriter::WriteControlBlock(Prepro<br>
AddSourceLocation((*M)->ImportLoc, Record);<br>
Record.push_back((*M)->File->getSize());<br>
Record.push_back((*M)->File->getModificationTime());<br>
+ Record.push_back((*M)->Signature);<br>
const std::string &FileName = (*M)->FileName;<br>
Record.push_back(FileName.size());<br>
Record.append(FileName.begin(), FileName.end());<br>
<br>
Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=220493&r1=220492&r2=220493&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=220493&r1=220492&r2=220493&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Thu Oct 23 13:05:36 2014<br>
@@ -591,6 +591,10 @@ bool GlobalModuleIndexBuilder::loadModul<br>
off_t StoredSize = (off_t)Record[Idx++];<br>
time_t StoredModTime = (time_t)Record[Idx++];<br>
<br>
+ // Skip the stored signature.<br>
+ // FIXME: we could read the signature out of the import and validate it.<br>
+ Idx++;<br>
+<br>
// Retrieve the imported file name.<br>
unsigned Length = Record[Idx++];<br>
SmallString<128> ImportedFile(Record.begin() + Idx,<br>
<br>
Modified: cfe/trunk/lib/Serialization/Module.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/Module.cpp?rev=220493&r1=220492&r2=220493&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/Module.cpp?rev=220493&r1=220492&r2=220493&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/Module.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/Module.cpp Thu Oct 23 13:05:36 2014<br>
@@ -21,7 +21,7 @@ using namespace serialization;<br>
using namespace reader;<br>
<br>
ModuleFile::ModuleFile(ModuleKind Kind, unsigned Generation)<br>
- : Kind(Kind), File(nullptr), DirectlyImported(false),<br>
+ : Kind(Kind), File(nullptr), Signature(0), DirectlyImported(false),<br>
Generation(Generation), SizeInBits(0),<br>
LocalNumSLocEntries(0), SLocEntryBaseID(0),<br>
SLocEntryBaseOffset(0), SLocEntryOffsets(nullptr),<br>
<br>
Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=220493&r1=220492&r2=220493&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=220493&r1=220492&r2=220493&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Thu Oct 23 13:05:36 2014<br>
@@ -57,6 +57,9 @@ ModuleManager::addModule(StringRef FileN<br>
SourceLocation ImportLoc, ModuleFile *ImportedBy,<br>
unsigned Generation,<br>
off_t ExpectedSize, time_t ExpectedModTime,<br>
+ ASTFileSignature ExpectedSignature,<br>
+ std::function<ASTFileSignature(llvm::BitstreamReader &)><br>
+ ReadSignature,<br>
ModuleFile *&Module,<br>
std::string &ErrorStr) {<br>
Module = nullptr;<br>
@@ -130,6 +133,21 @@ ModuleManager::addModule(StringRef FileN<br>
// Initialize the stream<br>
New->StreamFile.init((const unsigned char *)New->Buffer->getBufferStart(),<br>
(const unsigned char *)New->Buffer->getBufferEnd());<br>
+<br>
+ if (ExpectedSignature) {<br>
+ New->Signature = ReadSignature(New->StreamFile);<br>
+ if (New->Signature != ExpectedSignature) {<br>
+ ErrorStr = New->Signature ? "signature mismatch"<br>
+ : "could not read module signature";<br>
+<br>
+ // Remove the module file immediately, since removeModules might try to<br>
+ // invalidate the file cache for Entry, and that is not safe if this<br>
+ // module is *itself* up to date, but has an out-of-date importer.<br>
+ Modules.erase(Entry);<br>
+ Chain.pop_back();<br>
+ return OutOfDate;<br>
+ }<br>
+ }<br>
}<br>
<br>
if (ImportedBy) {<br>
<br>
Added: cfe/trunk/test/Modules/rebuild.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/rebuild.m?rev=220493&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/rebuild.m?rev=220493&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/rebuild.m (added)<br>
+++ cfe/trunk/test/Modules/rebuild.m Thu Oct 23 13:05:36 2014<br>
@@ -0,0 +1,29 @@<br>
+// REQUIRES: shell<br>
+// RUN: rm -rf %t<br>
+<br>
+// Build Module and set its timestamp<br>
+// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -<br>
+// RUN: touch -m -a -t 201101010000 %t/Module.pcm<br>
+// RUN: cp %t/Module.pcm %t/Module.pcm.saved<br>
+// RUN: wc -c %t/Module.pcm > %t/Module.size.saved<br>
+<br>
+// Build DependsOnModule<br>
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s<br>
+// RUN: diff %t/Module.pcm %t/Module.pcm.saved<br>
+// RUN: cp %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved<br>
+<br>
+// Rebuild Module, reset its timestamp, and verify its size hasn't changed<br>
+// RUN: rm %t/Module.pcm<br>
+// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -<br>
+// RUN: touch -m -a -t 201101010000 %t/Module.pcm<br>
+// RUN: wc -c %t/Module.pcm > %t/Module.size<br>
+// RUN: diff %t/Module.size %t/Module.size.saved<br>
+// RUN: cp %t/Module.pcm %t/Module.pcm.saved.2<br>
+<br>
+// But the signature at least is expected to change, so we rebuild DependsOnModule.<br>
+// NOTE: if we change how the signature is created, this test may need updating.<br>
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s<br>
+// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2<br>
+// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved<br>
+<br>
+@import DependsOnModule;<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>
</div></blockquote></div></div></div><br></div></blockquote></div><br></div></div>