It has been a month and I decided to take a closer look again, and I
seemed to understand it a little better.
The precompiled headers in trouble are:
$ ls -lh out/Debug/obj/third_party/WebKit/Source/WebCore/webcore_*.gch
-rw-r--r-- 1 jjgod staff 7.6M Apr 16 16:28
out/Debug/obj/third_party/WebKit/Source/WebCore/webcore_dom.WebCorePrefix.h-cc.gch
-rw-r--r-- 1 jjgod staff 7.6M Apr 16 16:28
out/Debug/obj/third_party/WebKit/Source/WebCore/webcore_html.WebCorePrefix.h-cc.gch
-rw-r--r-- 1 jjgod staff 7.6M Apr 16 16:28
out/Debug/obj/third_party/WebKit/Source/WebCore/webcore_platform.WebCorePrefix.h-cc.gch
-rw-r--r-- 1 jjgod staff 15M Apr 16 16:28
out/Debug/obj/third_party/WebKit/Source/WebCore/webcore_platform.WebCorePrefix.h-mm.gch
-rw-r--r-- 1 jjgod staff 7.6M Apr 16 16:28
out/Debug/obj/third_party/WebKit/Source/WebCore/webcore_platform_geometry.WebCorePrefix.h-cc.gch
-rw-r--r-- 1 jjgod staff 7.6M Apr 16 16:28
out/Debug/obj/third_party/WebKit/Source/WebCore/webcore_remaining.WebCorePrefix.h-cc.gch
-rw-r--r-- 1 jjgod staff 7.6M Apr 16 16:28
out/Debug/obj/third_party/WebKit/Source/WebCore/webcore_rendering.WebCorePrefix.h-cc.gch
-rw-r--r-- 1 jjgod staff 15M Apr 16 16:28
out/Debug/obj/third_party/WebKit/Source/WebCore/webcore_rendering.WebCorePrefix.h-mm.gch
which are all generated from third_party/WebKit/Source/WebCore/WebCorePrefix.h.
Let's say if I built in current branch, ccache will cache the gch
files. Then I switched to another branch that has modified
third_party/WebKit/Source/WebCore/WebCorePrefix.h, so the mtime of
this file will change. When I switch back to the old branch, since the
contents of third_party/WebKit/Source/WebCore/WebCorePrefix.h still
matches what's cached, so ccache returns the old precompiled header,
however clang thinks it's out of date by comparing modification time:
// For an overridden file, there is nothing to validate.
if (!Overridden && (StoredSize != File->getSize()
#if !defined(LLVM_ON_WIN32)
// In our regression testing, the Windows file system seems to
// have inconsistent modification times that sometimes
// erroneously trigger this error-handling path.
|| StoredTime != File->getModificationTime()
#endif
)) {
if (Complain) {
Error(diag::err_fe_pch_file_modified, Filename, F.FileName);
}
IsOutOfDate = true;
}
Thus we got the errors like:
fatal error: file
'/Users/jjgod/work/chromium/src/out/Debug/../../third_party/WebKit/Source/WebCore/WebCorePrefix.h'
has been modified since the precompiled header was built.
A potential fix I can think of is to force ccache always recache the
PCHs:
https://gist.github.com/jjgod/5396544
Do you guys think it's feasible to accept this patch or is there any
better way to solve this? Of course it sounds like the wrong place to
fix this problem as it's not a ninja problem at all, nor it should
affect building with any other compilers than clang (and not on
Windows either).
- Jiang