blob: 1c2252939664e91ec0aa0f0711f030b79ea351a6 [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
14[clang](http://code.google.com/p/chromium/wiki/Clang), you need to use the
15current [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
42## Use with GYP
43
44We have to set two environment variables (`CC` and `CXX`) before calling
45`gclient runhooks` or `build/gyp_chromium`, given you are currently in the
46`chromium/src` directory:
47
48```shell
49export CC="ccache clang -Qunused-arguments"
50export CXX="ccache clang++ -Qunused-arguments"
51```
52
53Then run:
54
55```shell
56GYP_GENERATORS="ninja" ./build/gyp_chromium
57```
58
59or
60
61```shell
62GYP_GENERATORS="ninja" gclient runhooks
63```
64
65(Instead of relying on the clang/clang++ for building chromium in your `$PATH`,
66you can also use the absolute path here.)
67
68## Use with GN
69
70You just need to set the use\_ccache variable. Do so like the following:
71
72```shell
73gn gen out-gn --args='use_ccache=true'
74```
75
76## Build
77
78In the build phase, the following environment variables must be set (assuming
79you are in `chromium/src`):
80
81```shell
82export CCACHE_CPP2=yes
83export CCACHE_SLOPPINESS=time_macros
84export PATH=`pwd`/third_party/llvm-build/Release+Asserts/bin:$PATH
85```
86
87Then you can just run ninja as normal:
88
89```shell
90ninja -C out/Release chrome
91```
92
93## Optional Steps
94
95* Configure ccache to use a different cache size with `ccache -M <max size>`.
96 You can see a list of configuration options by calling ccache alone. * The
97 default ccache directory is `~/.ccache`. You might want to symlink it to
98 another directory (for example, when using FileVault for your home
99 directory).