views:

218

answers:

1

Hi,

I was thinking about using ccache with gcc compiled code on the team wide base (same ccache's cache will be used by all developers on the same machine).

Since we're talking about commercial product, "correctness" of compilation is a top priority.

Here come questions:

  1. Is the compilation using ccache is safe/reproducible? Is there some exception situations that ccache supposes cache hit mistakenly.

    If I checkout a source code and compile it, I expect to receive the same products (exactly same libraries/binaries) each time I repeat a fresh compilation process. This is must to for commercial product.

  2. Is there're open source/commercial products using ccache an integral part of their build system? This will make it easier to convince my colleagues to use ccache.

Thanks

+3  A: 

According to its manual, ccache determines whether it has compiled some object before on the following:

  • the pre-processor output from running the compiler with -E
  • the command line options
  • the real compilers size and modification time
  • any stderr output generated by the compiler

If some PHB is still worried about any assumed risk you take because of ccache, only use it for development builds and build the final product using the compiler without any front-end. Or you could clear the cache before building the final product.

Update: I don't know about products using ccache as an integral part of their build system, but it is really trivial to integrate into any environment where you can set the compiler's path. I.e. for autoconf:

CC="ccache gcc" ./configure

And after looking at the author's name, I'd say it's a pretty safe assumption that it has been widely used within the Samba team.

Update in response to Ringding's comment about usage of stderr: From ccache's point of view, one interesting bit of information is the C compiler's version and configuration string. gcc outputs that to the standard error file:

$ gcc -v 2>err
$ cat err
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.4-2' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.4 (Debian 4.3.4-2)

I'd bet that ccache uses this or a similar output. But, hey, you can always look at its source code. :-)

hillu
It cannot make a decision based on the compiler's stderr output because it would have to call the compiler first. But the other 3 are correct, IIRC.
Ringding
Guys, do you know answer to 2nd item of my question?@hillu +1 for "safety" advises. A nice part of your answer is that also developer can perform a "safe" build if cleaning cache beforehand
dimba