blob: 7eed51a6d72a7bf25e7f58359e0c9316cd8d6b5d [file] [log] [blame] [view]
andybons3322f762015-08-24 21:37:091# Using CCache on Mac
2
3[ccache](http://ccache.samba.org/) is a compiler cache. It speeds up
4recompilation of C/C++ code by caching previous compilations and detecting when
5the same compilation is being done again. This often results in a significant
6speedup in common compilations, especially when switching between branches. This
7page is about using ccache on Mac with clang and the NinjaBuild system.
8
9[TOC]
10
11## Installation
12
13In order to use [ccache](http://ccache.samba.org) with
sbc9f033f82015-11-26 00:50:5214[clang](clang.md), you need to use the
andybons3322f762015-08-24 21:37:0915current [git HEAD](http://ccache.samba.org/repo.html), since the most recent
16version (3.1.9) doesn't contain the
17[patch needed](https://github.com/jrosdahl/ccache/pull/4) for using
18[the chromium style plugin](clang.md#Using_plugins).
19
20To install ccache with [homebrew](http://mxcl.github.com/homebrew/), use the
21following command:
22
23```shell
24brew install --HEAD ccache
25```
26
27You can also download and install yourself (with GNU automake, autoconf and
28libtool installed):
29
30```shell
31git clone git://git.samba.org/ccache.git cd ccache
32./autogen.sh
33./configure && make && make install
34```
35
36Make sure ccache can be found in your `$PATH`.
37
38You can also just use the current released version of ccache (3.1.8 or 3.1.9)
39and disable the chromium style plugin with `clang_use_chrome_plugins=0` in your
40`GYP_DEFINES`.
41
andybons3322f762015-08-24 21:37:0942## Use with GN
43
44You just need to set the use\_ccache variable. Do so like the following:
45
46```shell
dongseong.hwange279af12016-02-24 09:27:5447gn gen out-gn --args='cc_wrapper="ccache"'
andybons3322f762015-08-24 21:37:0948```
49
50## Build
51
52In the build phase, the following environment variables must be set (assuming
53you are in `chromium/src`):
54
55```shell
56export CCACHE_CPP2=yes
57export CCACHE_SLOPPINESS=time_macros
58export PATH=`pwd`/third_party/llvm-build/Release+Asserts/bin:$PATH
59```
60
61Then you can just run ninja as normal:
62
63```shell
64ninja -C out/Release chrome
65```
66
67## Optional Steps
68
69* Configure ccache to use a different cache size with `ccache -M <max size>`.
70 You can see a list of configuration options by calling ccache alone. * The
71 default ccache directory is `~/.ccache`. You might want to symlink it to
72 another directory (for example, when using FileVault for your home
73 directory).