diff options
author | Ben Langmuir <blangmuir@apple.com> | 2014-10-23 18:05:36 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2014-10-23 18:05:36 +0000 |
commit | 854931f5dafff52c3f2f431dfdf1b0ba1cddc6bc (patch) | |
tree | e7e184eaa5bb3487e2b78a04171af2f15f5590ae /test/Modules/rebuild.m | |
parent | c7fcc109745a5bb0756c1c6159d1f4e0fa296737 (diff) | |
download | clang-854931f5dafff52c3f2f431dfdf1b0ba1cddc6bc.tar.gz |
Add a "signature" to AST files to verify that they haven't changed
Since the order of the IDs in the AST file (e.g. DeclIDs, SelectorIDs)
is not stable, it is not safe to load an AST file that depends on
another AST file that has been rebuilt since the importer was built,
even if "nothing changed". We previously used size and modtime to check
this, but I've seen cases where a module rebuilt quickly enough to foil
this check and caused very hard to debug build errors.
To save cycles when we're loading the AST, we just generate a random
nonce value and check that it hasn't changed when we load an imported
module, rather than actually hash the whole file.
This is slightly complicated by the fact that we need to verify the
signature inside addModule, since we might otherwise consider that a
mdoule is "OutOfDate" when really it is the importer that is out of
date. I didn't see any regressions in module load time after this
change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220493 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Modules/rebuild.m')
-rw-r--r-- | test/Modules/rebuild.m | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/Modules/rebuild.m b/test/Modules/rebuild.m new file mode 100644 index 0000000000..c6e7920339 --- /dev/null +++ b/test/Modules/rebuild.m @@ -0,0 +1,29 @@ +// REQUIRES: shell +// RUN: rm -rf %t + +// Build Module and set its timestamp +// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c - +// RUN: touch -m -a -t 201101010000 %t/Module.pcm +// RUN: cp %t/Module.pcm %t/Module.pcm.saved +// RUN: wc -c %t/Module.pcm > %t/Module.size.saved + +// Build DependsOnModule +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s +// RUN: diff %t/Module.pcm %t/Module.pcm.saved +// RUN: cp %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved + +// Rebuild Module, reset its timestamp, and verify its size hasn't changed +// RUN: rm %t/Module.pcm +// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c - +// RUN: touch -m -a -t 201101010000 %t/Module.pcm +// RUN: wc -c %t/Module.pcm > %t/Module.size +// RUN: diff %t/Module.size %t/Module.size.saved +// RUN: cp %t/Module.pcm %t/Module.pcm.saved.2 + +// But the signature at least is expected to change, so we rebuild DependsOnModule. +// NOTE: if we change how the signature is created, this test may need updating. +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s +// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2 +// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved + +@import DependsOnModule; |