PCH: Clang, ccache, and "please rebuild precompiled header" error
I've build Qt Creator with Clang and ccache, ccache was configured with sloppiness = time_macros, pch_defines
and direct_mode = true
.
If I deleted the build directory and configure/build Qt Creator I will get at some point:
fatal error: file 'C:/Projects\QtCreator\build-repo-Desktop_Clang_MinGW_9-Release\src\libs\3rdparty\syntax-highlighting\CMakeFiles\QtCreatorPchGui.dir\CMakeFiles\QtCreatorPchGui.dir\cmake_pch.hxx' has been modified since the precompiled header 'C:/Projects/QtCreator/build-repo-Desktop_Clang_MinGW_9-Release/src/libs/3rdparty/syntax-highlighting/CMakeFiles/QtCreatorPchGui.dir/CMakeFiles/QtCreatorPchGui.dir/cmake_pch.hxx.pch' was built
note: please rebuild precompiled header 'C:/Projects/QtCreator/build-repo-Desktop_Clang_MinGW_9-Release/src/libs/3rdparty/syntax-highlighting/CMakeFiles/QtCreatorPchGui.dir/CMakeFiles/QtCreatorPchGui.dir/cmake_pch.hxx.pch'
1 error generated.
The error goes away if I delete in %appdata%/.ccache
the entries for cmake_pch.hxx.pch
(.o and .d files), and the pch files from the build directory.
This has to do with the fact that cmake_pch.hxx
has a different time stamp after I rebuild, than when the pch file was created. ccache
doesn't notice a change, but clang
does.
Since the cmake_pch.hxx
includes other header files, I suggest to take the newest time stamp from the header files and set it explicitly. This way after a full rebuild, the cmake_pch.hxx
will have the same timestamp as it had when the pch file was generated.