Speeding-up colored builds… on openSUSE Tumbleweed

More than a blog entry, this is a “let’s store what I did somewhere, so I don’t forget”.

Even better, if would be to put some automation together, I know that very well. 🙂
I plan to do that, actually, but I’m not there yet.

So, basically, I want compile-time warnings and errors to be clearly visible and easy to spot –while logs are flowing in a terminal– and I want to speed-up builds themselves. The tools for the job are, apparently:

I had this setup already a couple of development boxes ago, but had not put it together on the current one (running openSUSE Tumbleweed), yet.


colorgcc, is here:


Just download it, and:

$ sudo zypper install colorgcc-1.4.4-1.12.noarch.rpm


$ cp /etc/colorgccrc $HOME/.colorgccrc

And, in that config file, do what the comment that says to uncomment says, i.e., uncomment the lines following the comment: 🙂

# Uncomment this if you want set up default path to gcc
#g++: /usr/bin/g++
#gcc: /usr/bin/gcc
#c++: /usr/bin/c++
#cc: /usr/bin/cc

And, finally, symlinks. Basically, we want the colorgcc wrapper script to be invoked, instead of one (any) of the GCC compilers. I’ve done it by creating these links in $HOME/bin/, and making sure $HOME/bin is in $PATH (and comes early enough):

$ ls -l /home/dario/bin/
c++ -> /usr/bin/colorgcc
c89-gcc -> /usr/bin/colorgcc
c99-gcc -> /usr/bin/colorgcc
cc -> /usr/bin/colorgcc
g++ -> /usr/bin/colorgcc
g++-7 -> /usr/bin/colorgcc
gcc -> /usr/bin/colorgcc
gcc-7 -> /usr/bin/colorgcc
gcc-8 -> /usr/bin/colorgcc
gccgo -> /usr/bin/colorgcc
gccgo-8 -> /usr/bin/colorgcc
$ echo $PATH

As a test, let’s just give gcc something to complain about. For me, it worked (do you see the colors?!?):

$ cat << EOF > hello.c ; gcc hello.c -o hello

printf("Hello World!\n");
hello.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int]

(If you’re serious with “Hello World”, do the same, but with GNU hello!)


ccache is in openSUSE’s main repos, so installing is just a matter of:

$ sudo zypper install ccache

At this point, ccache config file (and ccache’s cache) is in ~/.ccache/:

$ ccache -s
cache directory /home/dario/.ccache
primary config /home/dario/.ccache/ccache.conf
secondary config (readonly) /etc/ccache.conf
cache hit (direct)          0
cache hit (preprocessed)    0
cache miss                  0
cache hit rate           0.00 %
cleanups performed          0
files in cache              0
cache size                0.0 kB
max cache size            5.0 GB

All that’s remaining to be done is:

    • to go back in $HOME/.colorgcc, and change that same block of lines again
    • to define CCACHE_PATH=/usr/bin
# Uncomment this if you want set up default path to gcc
g++: /usr/lib64/ccache/g++
gcc: /usr/lib64/ccache/gcc
c++: /usr/lib64/ccache/c++
cc: /usr/lib64/ccache/cc
clang: /usr/lib64/ccache/clang
clang++: /usr/lib64/ccache/clang++
gfortran: /usr/lib64/ccache/gfortran
export CCACHE_PATH="/usr/bin"

(The latter, I added it to .bashrc.)

Done. Now you’ll see that, building stuff has an impact in ccache statistics (and it’s also faster, hopefully!! 🙂 )

$ ccache -s
cache hit (direct)                82
cache hit (preprocessed)           1
cache miss                       392
cache hit rate                 17.47 %
called for link                   27
called for preprocessing          27
compiler produced empty output    49
preprocessor error                 2
unsupported compiler option        2
no input file                  79579
cleanups performed                 0
files in cache                  1172
cache size                      59.9 MB
max cache size                   5.0 GB

Just FTR, some links, which were useful when setting this up in the past, on other distros:

About dariofaggioli

Interested in CS, programming and Open Source since like forever, I'm now a very happy Virtualization developer @ SUSE. Much more important, I am a dreamer, a madly in love husband and an enthusiastic & incredibly proud father.
This entry was posted in Linux, openSUSE, SUSE, Technology, Work and tagged , , , , , , , , . Bookmark the permalink.


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

This site uses Akismet to reduce spam. Learn how your comment data is processed.