ccache for MSVC

I’ve been a happy ccache user for years. It’s a great tool for avoiding unneeded recompilation by reusing previously cached results – thus speeding up builds quite substantially. Unfortunately, it only works for gcc; there is a ccache patch for MSVC around but it never quite worked for me.

Hence, I decided to write a program which works just like ccache except that it can be used with MSVC. It’s a Python script which is meant to be used as a drop-in replacement for the cl.exe program.

The script basically generates a hash sum out of

  • The compilers file size and modification time
  • The complete preprocessed source code
  • The command line

After computing the hash sum, the cache is checked for whether an this hash sum was used previously. If so, the previously generated object file (and the compiler output) are re-used instead of invoking the actual compiler. This can save quite some time.

The program (as well as a bit more documentation) can be found at github.com:

https://github.com/frerich/clcache

Maybe this is useful to somebody – I’d be happy to get any feedback.

3 Comments

  • Milian Wolff says:

    You should post some benchmarks to show how much this tool helps and how it compares to ccache.

    bye

  • Nicolas says:

    It doesn’t support multiple source files in a single compiler invocation, which means it’s useless when compiling Qt :(

    • Frerich Raabe says:

      Recent clcache versions actually *do* support invoking the compiler with multiple source files. The only case where this is not supported is when you also pass /Tc or /Tp on the commandline.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>