On 22.08.10 12.42, Joel Rosdahl wrote:
On 2010-08-21 16:30, Joel Rosdahl wrote:
I've started implementing support for preprocessed headers (.gch)

Done.

Tor Arne: It would be great if you could try the current dev version of
ccache and see if it works well for you and if you get direct mode hits
when you use precompiled headers.

I'm sorry to report that I'm seeing build issues with master when building Qt on Mac OS X (but the issue should be fixable):

[whopper:~/build/qt/4.7-cocoa-32/src/network] $ g++ -c -include .pch/debug-shared/QtNetwork -Winvalid-pch -pipe -Xarch_i386 -mmacosx-version-min=10.4 -fconstant-cfstrings -O2 -arch i386 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -fPIC -DQT_SHARED -DQT_BUILD_NETWORK_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/Users/torarne/dev/qt/4.7/mkspecs/macx-g++ -I/Users/torarne/dev/qt/4.7/src/network -I../../include/QtCore -I../../include -I../../include/QtNetwork -I.rcc/debug-shared -I/Users/torarne/dev/qt/4.7/src/network/kernel -I.moc/release-shared -I. -F/Users/torarne/build/qt/4.7-cocoa-32/lib -o .obj/release-shared/qftp.o /Users/torarne/dev/qt/4.7/src/network/access/qftp.cpp cc1plus: warning: ./.pch/debug-shared/QtNetwork.gch/c++: not used because `QT_BUILD_XML_LIB' not defined cc1plus: warning: ./.pch/debug-shared/QtNetwork.gch/objective-c++: not for GNU C++ cc1plus: warning: ./.pch/debug-shared/QtNetwork.gch/c++: not used because `QT_BUILD_XML_LIB' not defined cc1plus: warning: ./.pch/debug-shared/QtNetwork.gch/objective-c++: not for GNU C++
cc1plus: error: .pch/debug-shared/QtNetwork: No such file or directory
cc1plus: error: one or more PCH files were found, but they were invalid

The reason seems to be that the object file hashing fails, and we end up using a cached version of the precompiled header from an earlier step in the compilation, where another define was set.

Here's when it's created, for the QtXml module:

[08-26T17:59:05.644922 70725] === CCACHE STARTED =========================================
[2010-08-26T17:59:05.645521 70725] Hostname: whopper
[2010-08-26T17:59:05.645533 70725] Working directory: /Users/torarne/build/qt/4.7-cocoa-32/src/xml [2010-08-26T17:59:05.645566 70725] i386 is not a regular file, not considering as input file [2010-08-26T17:59:05.645622 70725] Creating precompiled header; not compiling preprocessed code [2010-08-26T17:59:05.645666 70725] Source file: /Users/torarne/dev/qt/4.7/src/corelib/global/qt_pch.h [2010-08-26T17:59:05.645674 70725] Object file: .pch/debug-shared/QtXml.gch/c++
[2010-08-26T17:59:05.645692 70725] Trying direct lookup
[2010-08-26T17:59:05.645762 70725] Looking for object file hash in /Users/torarne/.ccache/d/8/a4db5d4c8aa3c1e487b474b990bc72-1807.manifest
[2010-08-26T17:59:05.645780 70725] No such manifest file
[2010-08-26T17:59:05.645787 70725] Did not find object file hash in manifest
[2010-08-26T17:59:05.645793 70725] Running preprocessor
[2010-08-26T17:59:05.645810 70725] Executing /usr/bin/g++ -pipe -Xarch_i386 -mmacosx-version-min=10.4 -fconstant-cfstrings -O2 -arch i386 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -fPIC -DQT_SHARED -DQT_BUILD_XML_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/Users/torarne/dev/qt/4.7/mkspecs/macx-g++ -I/Users/torarne/dev/qt/4.7/src/xml -I../../include/QtCore -I../../include -I../../include/QtXml -I.rcc/debug-shared -I.moc/release-shared -I. -F/Users/torarne/build/qt/4.7-cocoa-32/lib -c -x c++-header -E /Users/torarne/dev/qt/4.7/src/corelib/global/qt_pch.h
[2010-08-26T17:59:05.737271 70725] Got object file hash from preprocessor
[2010-08-26T17:59:05.737365 70725] Object file /Users/torarne/.ccache/6/c/7236596f54a9fa1cadf7181f4ebfda-1090377.o not in cache
[2010-08-26T17:59:05.737381 70725] Running real compiler
[2010-08-26T17:59:05.737386 70725] Executing /usr/bin/g++ -pipe -Xarch_i386 -mmacosx-version-min=10.4 -fconstant-cfstrings -O2 -arch i386 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -fPIC -DQT_SHARED -DQT_BUILD_XML_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/Users/torarne/dev/qt/4.7/mkspecs/macx-g++ -I/Users/torarne/dev/qt/4.7/src/xml -I../../include/QtCore -I../../include -I../../include/QtXml -I.rcc/debug-shared -I.moc/release-shared -I. -F/Users/torarne/build/qt/4.7-cocoa-32/lib -c -x c++-header -o /Users/torarne/.ccache/6/c/7236596f54a9fa1cadf7181f4ebfda-1090377.o.tmp.whopper.70725 /Users/torarne/dev/qt/4.7/src/corelib/global/qt_pch.h [2010-08-26T17:59:07.027297 70725] Stored in cache: /Users/torarne/.ccache/6/c/7236596f54a9fa1cadf7181f4ebfda-1090377.o [2010-08-26T17:59:07.027379 70725] Copying /Users/torarne/.ccache/6/c/7236596f54a9fa1cadf7181f4ebfda-1090377.o to .pch/debug-shared/QtXml.gch/c++ (uncompressed) [2010-08-26T17:59:07.292728 70725] Created .pch/debug-shared/QtXml.gch/c++ from /Users/torarne/.ccache/6/c/7236596f54a9fa1cadf7181f4ebfda-1090377.o [2010-08-26T17:59:07.294659 70725] Added object file hash to /Users/torarne/.ccache/d/8/a4db5d4c8aa3c1e487b474b990bc72-1807.manifest [2010-08-26T17:59:07.295184 70725] Acquired lock /Users/torarne/.ccache/6/stats.lock [2010-08-26T17:59:07.295548 70725] Releasing lock /Users/torarne/.ccache/6/stats.lock

The precompiled header is created with -DQT_BUILD_XML_LIB

Then it's reused later on when compiling the precompiled header for the QtNetwork module:

[2010-08-26T18:00:11.507508 73371] === CCACHE STARTED =========================================
[2010-08-26T18:00:11.508696 73371] Hostname: whopper
[2010-08-26T18:00:11.508708 73371] Working directory: /Users/torarne/build/qt/4.7-cocoa-32/src/network [2010-08-26T18:00:11.508738 73371] i386 is not a regular file, not considering as input file [2010-08-26T18:00:11.508783 73371] Creating precompiled header; not compiling preprocessed code [2010-08-26T18:00:11.508824 73371] Source file: /Users/torarne/dev/qt/4.7/src/corelib/global/qt_pch.h [2010-08-26T18:00:11.508831 73371] Object file: .pch/debug-shared/QtNetwork.gch/c++
[2010-08-26T18:00:11.508848 73371] Trying direct lookup
[2010-08-26T18:00:11.508915 73371] Looking for object file hash in /Users/torarne/.ccache/e/2/118fdff63ffd11466b18544654d0cb-1877.manifest
[2010-08-26T18:00:11.508937 73371] No such manifest file
[2010-08-26T18:00:11.508944 73371] Did not find object file hash in manifest
[2010-08-26T18:00:11.508950 73371] Running preprocessor
[2010-08-26T18:00:11.508967 73371] Executing /usr/bin/g++ -pipe -Xarch_i386 -mmacosx-version-min=10.4 -fconstant-cfstrings -O2 -arch i386 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -fPIC -DQT_SHARED -DQT_BUILD_NETWORK_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/Users/torarne/dev/qt/4.7/mkspecs/macx-g++ -I/Users/torarne/dev/qt/4.7/src/network -I../../include/QtCore -I../../include -I../../include/QtNetwork -I.rcc/debug-shared -I/Users/torarne/dev/qt/4.7/src/network/kernel -I.moc/release-shared -I. -F/Users/torarne/build/qt/4.7-cocoa-32/lib -c -x c++-header -E /Users/torarne/dev/qt/4.7/src/corelib/global/qt_pch.h
[2010-08-26T18:00:11.665981 73371] Got object file hash from preprocessor
[2010-08-26T18:00:11.666060 73371] Copying /Users/torarne/.ccache/6/c/7236596f54a9fa1cadf7181f4ebfda-1090377.o to .pch/debug-shared/QtNetwork.gch/c++ (uncompressed) [2010-08-26T18:00:11.932465 73371] Created .pch/debug-shared/QtNetwork.gch/c++ from /Users/torarne/.ccache/6/c/7236596f54a9fa1cadf7181f4ebfda-1090377.o [2010-08-26T18:00:11.934225 73371] Added object file hash to /Users/torarne/.ccache/e/2/118fdff63ffd11466b18544654d0cb-1877.manifest
[2010-08-26T18:00:11.934262 73371] Succeded getting cached result
[2010-08-26T18:00:11.934638 73371] Acquired lock /Users/torarne/.ccache/6/stats.lock [2010-08-26T18:00:11.935035 73371] Releasing lock /Users/torarne/.ccache/6/stats.lock

But at this point -DQT_BUILD_NETWORK_LIB is defined, not -DQT_BUILD_XML_LIB. Compilation then fails on the first file from the QtNetwork module that uses this precompiled header.

I'm assuming the hash is based solely on the contents of the preprocessed output, not the flags/defines that were passed? But it seems that the defines are stored somewhere in the precompiled header, since it's barfing out when detecting a mismatch.

Since we've already detected that we're dealing with a precompiled header I guess we could add the defines (and possibly other things) to the hashing algorithm just for this case without affecting normal compilation, where you'd only need to match the preprocessed output?

Tor Arne
_______________________________________________
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache

Reply via email to