8

I've been wondering...

Are there some limitations with ccache?

If the difference in later compile times are so large, why aren't more Linux developers using ccache more often?

Hakkar
  • 2,391
  • 4
  • 23
  • 33
  • 1
    References for ccache, your information about how many developers use it, and these compile time figures? – Useless Aug 10 '12 at 16:15
  • 2
    @Useless: Some high level info: *ccache* is a tool that is used as a compiler wrapper, it calls the compiler with the given arguments and caches the result of compilation. If the object file is removed and a new compilation is triggered, *ccache* will check the source file and compiler options and pull the result from the cache if available. Basically it allows for 'make clean; make' with the efficiency of just 'make' (mainly useful if the makefile dependencies are not correctly tracked). [There are details missing as to how to determine whether the cached .o can be used or not] – David Rodríguez - dribeas Aug 10 '12 at 16:19
  • 1
    So it's a sticking plaster for people who can't write correct makefiles? If you always have to `make clean`, the build system isn't doing its job. – Useless Aug 10 '12 at 16:33
  • @Useless: There are other use cases, for example in build farms you may want to force cleaning before build, if correctly configured the cached objects (and output from the compiler I failed to mention that) can be shared in different code paths, allowing parallel work in different directories and `ccache` producing the .o for shared unmodified files... Also note that it is not *that* simple to perfectly track the dependencies for large enough projects that are not built in one step (i.e. a header in a library outside of your current project changes) – David Rodríguez - dribeas Aug 10 '12 at 16:36
  • Thy're probably running their builds on the same box they use for WOW/CoD etc. They have RAID-SSDs, 16G of RAM and 8-core watercooled i7's. If a full build takes 12 seconds, not much point in speeding it up – Martin James Aug 10 '12 at 16:39
  • @MartinJames: So all of them have my exact setup? Darn, I thought I was unique! – David Rodríguez - dribeas Aug 10 '12 at 17:01
  • This all makes sense now that I understand how ccache works. This sounds useless on a developers machine then. I'll just have to wait for C++ modules in the next C++ revision (whenever that is). – Hakkar Aug 10 '12 at 23:25

1 Answers1

11

I guess that the simple answer is that ccache is great when the build system is broken (i.e. the dependencies are not correctly tracked, and to get everything built correctly you might need make clean; make). On the other hand, if dependencies are correctly tracked, then ccache will not yield any advantage over plain make, and will actually incur the cost of maintaining the cache and updating it (the size of the cache might be huge depending on the size of the project)

David Rodríguez - dribeas
  • 204,818
  • 23
  • 294
  • 489
  • 3
    +1: write correct, non-recursive makefiles and watch those concurrent builds fly – Useless Aug 10 '12 at 16:36
  • 3
    ccache is also very helpful when you change something in a widely-included header and then change it back. (Or, say, if all you did was fix a spelling error in a comment in such a header.) – SamB Sep 07 '12 at 17:44
  • 6
    A build system I use trips up when I switch branches, and ccache really helps with that. – odinho - Velmont Dec 12 '12 at 13:01
  • 3
    `ccache` is invaluable if you jump back and forth a lot in the history of a large project, like Chromium. Or if you keep multiple checkouts. Or if you're the one who's got to diagnose and fix those incorrect makefiles. – Leif Arne Storset Aug 07 '15 at 15:20