Re: How to cache output of the compiler aka ccache

From: Robert A Duff (bobduff_at_shell01.TheWorld.com)
Date: 03/17/05


Date: 17 Mar 2005 14:40:48 -0500

i-google-iasuhdkajsh@rf.risimo.net writes:

> Hi
>
> I have a 1mio LOC project and it takes multiple hours to
> build and rebuild. The C/C++ world has a nice tools (ccache
> is well known here) which cache the output of the compiler.
> This especially speeds up the time for a "make clean;make".
>
> Is there such a thing for Ada in general and gcc's gnat
> specially? Any other way to speed up the compilation?

Well, I had never heard of ccache before, so I just went and read about
it. I am rather mystified by the *point* of it. I mean, if I don't
want to recompile stuff that hasn't changed, I just don't type "make
clean". If for some reason I want to rebuild everything from scratch, I
type "make clean" (or rm -rf build_area or whatever) -- but then ccache
*defeats* that, and does *not* rebuild everything from scratch.
I don't see the point of that. It seems like a contradiction -- I want
to rebuild everything from scratch while avoiding rebuilding everything!

The only thing I can think of is that if your makefile is buggy
(missing dependences) it won't rebuild some things that depend
on some .h files, and you'll get mysterious bugs. So rebuilding from
scratch is more reliable. And ccache actually decides whether to run
the compiler *reliably* (whereas 'make' does not). Is *that* why
people use ccache?

Don't people automatically generate the make-file dependences for C code
these days? It seems crazy to try to keep the make file in synch with
the #includes by hand!

Anyway, the buggy make file problem does not happen with Ada. All Ada
compilers come with a build tool that reliably decides what needs to be
recompiled, and does it. In AdaMagic, it's called adabuild. In GNAT
it's called gnatmake. Also, if you try to link an Ada program where the
parts are inconsistently compiled you will get an error at link time.
You never need to invoke the compiler directly -- just use the build
tool.

If you're writing a make file for an Ada program, you should *not* put
in dependencies for the Ada code! Instead, use a .PHONY rule to
unconditionally invoke the build tool. Don't type "make clean"
(except perhaps in your nightly test script, where you don't have
to wait for it), but trust the builder to decide what needs recompiling
and to keep things consistent.

You don't even need to use 'make' with Ada at all, if all you want to do
is rebuild. But it's convenient to have make-file targets like "rebuild
if necessary and run the regression tests".

- Bob



Relevant Pages

  • Re: Current status of Ada?
    ... learning and using this great language. ... The reason why compilers maker can't make their compiler totally free ... I agree with you that most of the links you can find on Ada websites ... AdaCore has contributed a free gnat compiler to ...
    (comp.lang.ada)
  • Re: Ravenscar-compliant bounded buffer
    ... the mid 1980's most compiler are FRONT_END compilers aka ... any system build around GNAT will contain the C code that GNAT ... The XGC Ada which is based on GNAT and uses C for its Real Time ... with VAXes for data processing applications. ...
    (comp.lang.ada)
  • Re: 7E7 Flight Controls Electronics
    ... Given that people had choices and Ada ... the 800 or so programming languages in use by the DoD, ... DoD1 was expected to provide a 'language of last resort', ... need modifications to a compiler to support particular requirements, ...
    (comp.lang.ada)
  • Re: Distributed Computing in Ada
    ... no shared memory. ... Ada tasks /can/ share memory, ... The problem is that the compiler can't know which variables are shared. ... The unit of distribution ...
    (comp.lang.ada)
  • Re: Teaching new tricks to an old dog (C++ -->Ada)
    ... Though I haven't done so recently, back when I used Ada, nowhere close ... This can be ameliorated in a case like GNAT, where the Ada compiler ... _every_ programming language places severe limits on expressiveness; ... Ada's exception handling is also primitive at best (exceptionally so, ...
    (comp.lang.cpp)