• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Linux Speeding up recompilation with ccache

Lordfire

Intermediate OT User
TFS Developer
Joined
Jul 16, 2008
Messages
248
Solutions
3
Reaction score
138
GitHub
ranisalt
ccache is a compiler cache designed to speed up subsequent compilations when it detects the same code is being recompiled.

You will have to install ccache in your favorite Linux flavor using the package manager, along with all the other software needed to compile TFS, such as CMake and GCC.

Once you have installed all the required software, create a directory with the name "build" or clean your previous one (remove everything except configuration and data) and enter it. Now, run the following line if using bash or zsh:

Code:
CXX="ccache g++" CCACHE_SLOPPINESS="pch_defines,time_macros" cmake ..

Or if using fish:

Code:
set -x CXX "ccache g++"
set -x CCACHE_SLOPPINESS "pch_defines,time_macros"
cmake ..

Then just compile using make as you would do before.

The first compilation will take the same amount of time as before. Subsequent compilations of the same code can take up to 15x less time to build. For instance, compiling TFS in an i7 processor with 4 cores and 5 jobs:

Without ccache:
Code:
real 113.68
user 285.67
sys 14.81

With ccache:
Code:
real 7.32
user 13.10
sys 1.77
(times are measured in seconds)

This works for any building that uses cmake, notably TFS, OTClient and RME.

Additionally, if you are curious, you might replace make with ninja, a faster build system that I might write about later :)
 
:O This is godly! Thanks man!
 
Back
Top