compilationclangclang++ccache

Problem with ccache after changing branches with larger diff


I'm compiling my app with ccache enabled. Everything works fine until I change my repo's branch to the one with bigger diff.

Flow:

If I change to other branch with much smaller diff, ccache works ok.

I have no clue why it doesn't work in scenario above.

Here are options I'm using:

(default) absolute_paths_in_stderr = false
(default) base_dir =
(environment) cache_dir = /ccache
(default) compiler =
(default) compiler_check = mtime
(environment) compiler_type = clang
(default) compression = true
(default) compression_level = 0
(default) cpp_extension =
(environment) debug = true
(environment) debug_dir = /ccache/debug
(environment) depend_mode = true
(environment) direct_mode = true
(default) disable = false
(default) extra_files_to_hash =
(environment) file_clone = true
(default) hard_link = false
(default) hash_dir = true
(default) ignore_headers_in_manifest =
(default) ignore_options =
(environment) inode_cache = true
(default) keep_comments_cpp = false
(default) limit_multiple = 0.8
(environment) log_file = /ccache/ccache-log
(default) max_files = 0
(/ccache/config) max_size = 20.0G
(default) namespace =
(default) path =
(default) pch_external_checksum = false
(default) prefix_command =
(default) prefix_command_cpp =
(default) read_only = false
(default) read_only_direct = false
(default) recache = false
(default) reshare = false
(environment) run_second_cpp = true
(default) secondary_storage =
(environment) sloppiness = clang_index_store, include_file_ctime, include_file_mtime, ivfsoverlay, locale, modules, pch_defines, system_headers, time_macros
(default) stats = true
(default) stats_log =
(default) temporary_dir = /ccache/tmp
(default) umask =

Anyone has any idea what am I doing wrong ?

PS. It's probably because of that my .hpp files timestamps changes during that branch switching, but isn't ccache resistant for such a timestamp change ? It's is obvious that during compilation without ccache after such a change program will have compile from scratch, but I think that ccache should help for that. Am I wrong ?


Solution

  • I found out what is the problem. I'm using precompile headers, and I'm compiling them to .gch. When timestamp of some header which is included in that pch changes there is a problem, cuz newly generated .gch differs from previous one and then all .cpp files which use this pch have to be recompiled, cuz ccache doesn't find hits for them.

    Workaround solution for me in that case is to use pch files as prefix headers and just include them instead of using them as precompile headers.