summaryrefslogtreecommitdiffstats
path: root/docs/ccache_mac.md
blob: cd5492d502265e0f7fffec53b6e330f438a4393a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Using CCache on Mac

[ccache](http://ccache.samba.org/) is a compiler cache. It speeds up
recompilation of C/C++ code by caching previous compilations and detecting when
the same compilation is being done again. This often results in a significant
speedup in common compilations, especially when switching between branches. This
page is about using ccache on Mac with clang and the NinjaBuild system.

[TOC]

## Installation

In order to use [ccache](http://ccache.samba.org) with
[clang](clang.md), you need to use the
current [git HEAD](http://ccache.samba.org/repo.html), since the most recent
version (3.1.9) doesn't contain the
[patch needed](https://github.com/jrosdahl/ccache/pull/4) for using
[the chromium style plugin](clang.md#Using_plugins).

To install ccache with [homebrew](http://mxcl.github.com/homebrew/), use the
following command:

```shell
brew install --HEAD ccache
```

You can also download and install yourself (with GNU automake, autoconf and
libtool installed):

```shell
git clone git://git.samba.org/ccache.git cd ccache
./autogen.sh
./configure && make && make install
```

Make sure ccache can be found in your `$PATH`.

You can also just use the current released version of ccache (3.1.8 or 3.1.9)
and disable the chromium style plugin with `clang_use_chrome_plugins=0` in your
`GYP_DEFINES`.

## Use with GYP

We have to set two environment variables (`CC` and `CXX`) before calling
`gclient runhooks` or `build/gyp_chromium`, given you are currently in the
`chromium/src` directory:

```shell
export CC="ccache clang -Qunused-arguments"
export CXX="ccache clang++ -Qunused-arguments"
```

Then run:

```shell
GYP_GENERATORS="ninja" ./build/gyp_chromium
```

or

```shell
GYP_GENERATORS="ninja" gclient runhooks
```

(Instead of relying on the clang/clang++ for building chromium in your `$PATH`,
you can also use the absolute path here.)

## Use with GN

You just need to set the use\_ccache variable. Do so like the following:

```shell
gn gen out-gn --args='cc_wrapper="ccache"'
```

## Build

In the build phase, the following environment variables must be set (assuming
you are in `chromium/src`):

```shell
export CCACHE_CPP2=yes
export CCACHE_SLOPPINESS=time_macros
export PATH=`pwd`/third_party/llvm-build/Release+Asserts/bin:$PATH
```

Then you can just run ninja as normal:

```shell
ninja -C out/Release chrome
```

## Optional Steps

*   Configure ccache to use a different cache size with `ccache -M <max size>`.
    You can see a list of configuration options by calling ccache alone.  * The
    default ccache directory is `~/.ccache`. You might want to symlink it to
    another directory (for example, when using FileVault for your home
    directory).