0

[docs] Update ccache on Mac instructions

Change-Id: I619ef54353c23cfeadc91df3bbc28fdf0d825006
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3426041
Auto-Submit: David Sanders <dsanders11@ucsbalum.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#969711}
This commit is contained in:
David Sanders
2022-02-11 00:13:23 +00:00
committed by Chromium LUCI CQ
parent d6530d5816
commit e7cc34c2bd

@ -1,73 +1,38 @@
# Using CCache on Mac
[ccache](http://ccache.samba.org/) is a compiler cache. It speeds up
[ccache](https://ccache.dev/) 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.
page is about using ccache on Mac with clang and the Ninja build 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
```
To install ccache with [Homebrew](https://brew.sh/), run `brew install ccache`.
With [MacPorts](https://macports.org/), run `port install ccache`. You can also
download and install yourself, using the
[instructions in
the repository](https://github.com/ccache/ccache/blob/master/doc/INSTALL.md).
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 = false`
in your args.gn.
## 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"'
```
You just need to set the `cc_wrapper` GN variable. You can do so by running
`gn args out/Default` and adding
`cc_wrapper="env CCACHE_SLOPPINESS=time_macros ccache"` to the build arguments.
## Build
In the build phase, the following environment variables must be set (assuming
you are in `chromium/src`):
After setting the `cc_wrapper` GN variable you can just run ninja as normal:
```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
ninja -C out/Default 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).
You can see a list of configuration options by calling `ccache` alone.