blob: 932b6d5159ec878722da719557dff7167b263984 [file] [log] [blame] [view]
andybons3322f762015-08-24 21:37:091# Using CCache on Mac
2
David Sanderse7cc34c2022-02-11 00:13:233[ccache](https://ccache.dev/) is a compiler cache. It speeds up
andybons3322f762015-08-24 21:37:094recompilation 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
David Sanderse7cc34c2022-02-11 00:13:237page is about using ccache on Mac with clang and the Ninja build system.
andybons3322f762015-08-24 21:37:098
9[TOC]
10
11## Installation
12
David Sanderse7cc34c2022-02-11 00:13:2313To install ccache with [Homebrew](https://brew.sh/), run `brew install ccache`.
14With [MacPorts](https://macports.org/), run `port install ccache`. You can also
15download and install yourself, using the
16[instructions in
17the repository](https://github.com/ccache/ccache/blob/master/doc/INSTALL.md).
andybons3322f762015-08-24 21:37:0918
19Make sure ccache can be found in your `$PATH`.
20
andybons3322f762015-08-24 21:37:0921## Use with GN
22
David Sanderse7cc34c2022-02-11 00:13:2323You just need to set the `cc_wrapper` GN variable. You can do so by running
24`gn args out/Default` and adding
25`cc_wrapper="env CCACHE_SLOPPINESS=time_macros ccache"` to the build arguments.
andybons3322f762015-08-24 21:37:0926
27## Build
28
David Sanderse7cc34c2022-02-11 00:13:2329After setting the `cc_wrapper` GN variable you can just run ninja as normal:
andybons3322f762015-08-24 21:37:0930
31```shell
David Sanderse7cc34c2022-02-11 00:13:2332ninja -C out/Default chrome
andybons3322f762015-08-24 21:37:0933```
34
35## Optional Steps
36
37* Configure ccache to use a different cache size with `ccache -M <max size>`.
David Sanderse7cc34c2022-02-11 00:13:2338 You can see a list of configuration options by calling `ccache` alone.