Monday, January 28, 2013

Speeding Up Software Rebuilds with CCache

Software developers who routinely rebuild large projects would love ccache. Ccache is a compiler cache. It speeds up software rebuilds by caching the result of previous compilations and detecting when the same compilation is being done again.

I use ccache when compiling Linux kernel, Debian/Ubuntu packages, GNOME applications, Mozilla Firefox, FirefoxOS and Android operating system. You could enable ccache by prefixing ccache to your compilation command or update your system path to include ccache.


# Add the following line to your ~/.bashrc file 
export PATH=/usr/lib/ccache:${PATH}

Alternatively you could create symlinks in ~/bin directory. GNOME 3 jhbuild documentation provides a bash script for this purpose.


cd ~/bin
for cmd in cc gcc c++ g++; do
  ln -s /usr/bin/ccache $cmd
done

To take advantage of ccache while building Mozilla Firefox, append the following line to your .mozconfig.


ac_add_options --with-ccache

If you are compiling Android(ASOP), CyanogenMod or Firefox OS. Android build system includes the ccache program, set the USE_CCACHE environment variable to enable ccache.

$ export USE_CCACHE=1

Further more in-depth information, read the ccache manual page. Please do comment and share your experiences using CCache.






6 comments:

  1. You need to put ccache at the beginning of your path, not at the end.

    ReplyDelete
  2. "would love ccache." i think they already do :)

    ReplyDelete
  3. Is there a way to speed up builds on windows? Always takes >30 minutes for me, even with 8 cores

    ReplyDelete
    Replies
    1. Don't use MS Windows, you might want ask that question in the Mozilla IRC #developers channel

      Delete

You can leave a comment here using your Google account, OpenID or as an anonymous user.

Popular Posts