Speed up Compiling with ccache - pete4abw/lrzip-next GitHub Wiki
Using ccache when compiling
The ccache
application can speed up compilation by caching object file info. Even if you use make clean
, and build again, it will pull in already compiled code (assuming no changes).
However, ccache cannot be used reliably with configure
. Also, care must be taken when compiling using sudo
or su
since ccache will cache files under the user account directory, but with the root account permissions. This type of conflict causes unpredictable results!
Set up Environment variables
Export the following:
Variable Name and Value | Meaning |
---|---|
USE_CCACHE=1 |
1=yes, 0=no |
CCACHE_COMPRESS=1 |
optional, but will compress cached output. 1=yes, 0=no |
CCACHE_DIR=cache dir |
optional cache directory per user. Default is ~/.ccache. Useful in group projects e.g. /var/cache/ . |
CCACHE_UMASK=mask |
optional cache read/write mask settings. 022=user read/write, group, other read. 000 Global read/write |
Set up the cache using a ccache.conf file in the CCACHE_DIR
directory (see ccache manpage).
Start ccache with ccache -M size
where size specifies the maximum cache size. 0 means unlimited. This value will be stored in ccache.conf. Only has to be run once or if you wish to enlarge or reduce the max cache size.
Do not embed ccache compiler command in the environment variables CC=
or CXX=
as that will affect configure
.
Using ccache with lrzip-next
Once autogen.sh
has run and configure
has run, the make
command can be amended slightly as follows in order to cache output.
make CC='ccache gcc' CXX='ccache g++' [make options, such as -j#]
Then next time you compile lrzip-next
it may go faster, especially with the library files, such as zpaq which are slower to build because of the -O3
compile time option.