Speeding up Compilation


Or rather recompilation to be specific!

Install ccache package http://ccache.samba.org/ using,

$ sudo yum install ccache


$ sudo apt-get install ccache

This should create a soft link to ccache for gcc (and cc as well) in /usr/lib/ccache directory.

If you are using external cross-compiler toolchain, create similar soft-link in /usr/lib/ccache directory and export this directory to PATH variable.

$ ln -s ../../bin/ccache arm-none-eabi-gcc

Verify that right command will be picked for compilation:

$ which arm-none-eabi-gcc

Now you are good to go! Just make clean and make, and see the difference!


Distributed compilation to make effective use of processing powers of machines (sitting idle) in network.

$ yum install distcc distcc-server

Distcc server deamon runs on remote machine and distcc client on the machines which will use remote server to distribute compilation job. See man pages for more details on configuration.

On server side:

$ distccd --allow <client_ip_address_list> --daemon

Make sure firewall/iptable rules are disabled for port 3332, as that will be used to listen for incoming requests from clients.

On client side:

$ export DISTCC_HOSTS="localhost <server_ip_address>"
$ make -j4 CC=distcc

For cross-compilation use following instead

$ make -j4 CC="distcc arm-none-eabi-gcc"

Run following command to monitor job status:

$ distccmon-text  5

Effect of distributed network compilation is more visible for kernel soruce compilation, improvements of order of 40%. This little tricks have made me more productive!

This entry was posted in Linux and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s