This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

compilercache


http://www.erikyyy.de/compilercache/

you can ignore the rest of this email, it is redundant with the URL
(which is much more in detail).

What is compilercache and Why do I want it ?
--------------------------------------------

Compilercache is a wrapperscript around your C and C++ compilers. Each
time you compile something, the wrapperscript puts the result of the
compilation into a cache. And once you compile EXACTLY the same thing
again, with EXACTLY the same command line parameters and EXACTLY the
same sources and included include files, the result will be picked
from the cache instead of being recompiled.

You might wonder why you need this, since there seems to be another
tool for this purpose, "make". But to get "make" working you need to
create a Makefile. You need to take care of your dependencies
manually. If you make a mistake, wrong code will be generated.

Another drawback with "make" is that if you normally compile your
project with -O2 (optimizations) and now want to debug it, you will
have to recompile the whole stuff with -g (debugging). now with "make"
you have to do a "make clean", then change the options, and then
recompile everything. With compilercache you basically do the same,
but if your project has already been compiled with -g in the past, and
now currently you run it with -O2 and want to switch back to -g, the
old compilation results will be picked from the cache. i.e. switching
compiler options goes fast! not like "make" which forces you into a
complete recompilation.

Since compilercache is just a wrapper around your compiler, you can
still use "make" if you want. compilercache does no harm. All it does
is sometimes speed up the compilation run by getting the result out of
the cache.

There is another interesting advantage: suppose you download
foo-1.0.0.tar.gz from the net, unpack, ./configure, make. now the
authors release foo-1.0.1.tar.gz. what do you do? Well, first you
delete your old foo-1.0.0, then you unpack foo-1.0.1, ./configure,
make. but hey with compilercache the compilation goes extremly fast,
because only the changed sources will be recompiled! Now ain't that an
advantage? Just think of linux kernel recompilation! You can now
always do a "make mrproper" and be sure there will be no dependency
problems since you always recompile from scratch. compilercache will
take care of speeding up ;)

And finally as another advantage, if you just fix small typos in your
comments, compilercache will not recompile, even though the sources
have "changed" !

Is it dangerous to use compilercache ?
--------------------------------------

First let's define dangerous. Dangerous means that the compilercache
program returns another result than the normal compiler would have
returned. For example you write a foo.c program, compile it with
compilercache and get a foo.o file that's not equal to what you would
have got if you called the original compiler directly.

I am quite sure that it is not dangerous to use compilercache. If
someone finds a situation where it is dangerous, then please mail me
the constellation so that I can fix compilercache.

But what about dependencies? Well. if foo.c includes bar.h, and you
change bar.h, and then recompile foo.c with compilercache, it will
recompile foo.c, because compilercache takes the complete preprocessor
output for deciding if it already compiled this source. The
preprocessor removes all the #include directives and just generates
one large source file. This source file is taken into account when
deciding if recompilation needs to take place. So there is no problem
with dependencies.

But if I change compiler options like -D_REENTRANT_ or -O2 or -g ?
That's actually an easy point. compilercache puts the commandline
options also into the cache. If you use other commandline options,
recompilation will take place.


Have fun!

Erik

PS: compilercache is just a simple shellscript
PS2: read the website for further information!

-- 
Name:  Erik Thiele                                        \\\\
Email: erikyyy@erikyyy.de                                 o `QQ'_
WWW:   http://www.erikyyy.de/                              /   __8
                                                           '  `


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]