[mythtv] Using ccache for native builds in win32 build script

Jonathan Martens jonathan at snetram.nl
Sat Feb 19 22:21:45 UTC 2011


Lawrence, e.a.,

I have been trying to implement ccache in building under MinGW as 
recompiling takes quite some time, since this can be installed natively 
on Linux when cross compiling I think this tweak is only needed when 
compiling under MinGW on Windows.

For now I have been using a relatively old version of ccache and 
additional patches as provided at https://github.com/ramiropolla/ccache 
as that is the only version I have been able to get to compile under 
MinGW until now.

My workflow basically was like this:

git clone git://github.com/ramiropolla/ccache.git ccache
pushd ccache
./autogen.sh
./configure
make
make install
popd
pushd /usr/local/bin
for c in cpp c++ gcc g++
do
   echo "#!/bin/bash" > $c
   echo "ccache $c.exe \"\$@\"" >> $c
   chmod a+x $c
done
popd /usr/local/bin

A first build (of YASM only) shows that the cache is being populated but 
since it was empty no hits are recorded.

$ ccache -s
cache directory                     ~/.ccache
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                            97
called for link                        9
files in cache                       273
cache size                           3.2 Mbytes
max cache size                       1.0 Gbytes

A second build (after removing ~/mythbuild/yasm and ~/ mythinstall shows 
that the cache is used, 96+1 = 97 hits and no misses.

cache directory                     ~/.ccache
cache hit (direct)                    96
cache hit (preprocessed)               1
cache miss                            97
called for link                       18
files in cache                       273
cache size                           3.2 Mbytes
max cache size                       1.0 Gbytes

Apart from that the time make takes also decreases drastically:

First build:

make
...
make[2]: Leaving directory `/home/Administrator/mythbuild/yasm-1.1.0'
make[1]: Leaving directory `/home/Administrator/mythbuild/yasm-1.1.0'

real    1m29.219s
user    0m9.676s
sys     0m15.329s

Subsequent build:

make
...
make[2]: Leaving directory `/home/Administrator/mythbuild/yasm-1.1.0'
make[1]: Leaving directory `/home/Administrator/mythbuild/yasm-1.1.0'

real    0m29.672s
user    0m9.041s
sys     0m15.143s

The total compilation time is reduced with about a minute (~60%) on a 
minute and a half. Imagine what that could do for long builds like Qt 
when rebuilding with the -C option.

Since I was already tracking Lawrence Rust changes in my personal github 
clone I also created a branch for the new changes.

You can download the latest version of Lawrence Rust's script including 
my ccache addition at:

https://github.com/jmartens/packaging/raw/win32-build-script-ccache/Win32/build/mythbuild.sh

Kind regards,

Jonathan



More information about the mythtv-dev mailing list