1 # Tips for improving build speed on Linux
3 This list is sorted such that the largest speedup is first; see
4 [Linux build instructions](linux_build_instructions.md) for context and
5 [Faster Builds](common_build_tasks.md) for non-Linux-specific techniques.
11 If you work at Google, you can use goma for distributed builds; this is similar
12 to [distcc](http://en.wikipedia.org/wiki/Distcc). See [go/ma](http://go/ma) for
15 Even without goma, you can do distributed builds with distcc (if you have access
16 to other machines), or a parallel build locally if have multiple cores.
18 Whether using goma, distcc, or parallel building, you can specify the number of
19 build processes with `-jX` where `X` is the number of processes to start.
23 [Icecc](https://github.com/icecc/icecream) is the distributed compiler with a
24 central scheduler to share build load. Currently, many external contributors use
25 it. e.g. Intel, Opera, Samsung.
27 When you use Icecc, you need to set some gyp variables.
29 linux_use_bundled_binutils=0**
31 `-B` option is not supported.
32 [relevant commit](https://github.com/icecc/icecream/commit/b2ce5b9cc4bd1900f55c3684214e409fa81e7a92)
34 linux_use_debug_fission=0
36 [debug fission](http://gcc.gnu.org/wiki/DebugFission) is not supported.
37 [bug](https://github.com/icecc/icecream/issues/86)
41 Icecc doesn't support clang yet.
43 ## Build only specific targets
45 If you specify just the target(s) you want built, the build will only walk that
46 portion of the dependency graph:
49 ninja -C out/Debug base_unittests
55 We normally statically link everything into one final executable, which produces
56 enormous (nearly 1gb in debug mode) files. If you dynamically link, you save a
57 lot of time linking for a bit of time during startup, which is fine especially
58 when you're in an edit/compile/test cycle.
60 Run gyp with the `-Dcomponent=shared_library` flag to put it in this
61 configuration. (Or set those flags via the `GYP_DEFINES` environment variable.)
65 build/gyp_chromium -D component=shared_library
66 ninja -C out/Debug chrome
69 [component build page](http://www.chromium.org/developers/how-tos/component-build)
72 ### Linking using gold
74 The experimental "gold" linker is much faster than the standard BFD linker.
76 On some systems (including Debian experimental, Ubuntu Karmic and beyond), there
77 exists a `binutils-gold` package. Do not install this version! Having gold as
78 the default linker is known to break kernel / kernel module builds.
80 The Chrome tree now includes a binary of gold compiled for x64 Linux. It is used
81 by default on those systems.
83 On other systems, to safely install gold, make sure the final binary is named
84 `ld` and then set `CC/CXX` appropriately, e.g.
85 `export CC="gcc -B/usr/local/gold/bin"` and similarly for `CXX`. Alternatively,
86 you can add `/usr/local/gold/bin` to your `PATH` in front of `/usr/bin`.
90 ### Build WebKit without debug symbols
92 WebKit is about half our weight in terms of debug symbols. (Lots of templates!)
93 If you're working on UI bits where you don't care to trace into WebKit you can
94 cut down the size and slowness of debug builds significantly by building WebKit
95 without debug symbols.
97 Set the gyp variable `remove_webcore_debug_symbols=1`, either via the
98 `GYP_DEFINES` environment variable, the `-D` flag to gyp, or by adding the
99 following to `~/.gyp/include.gypi`:
104 'remove_webcore_debug_symbols': 1,
109 ## Tune ccache for multiple working directories
111 (Ignore this if you use goma.)
113 Increase your ccache hit rate by setting `CCACHE_BASEDIR` to a parent directory
114 that the working directories all have in common (e.g.,
115 `/home/yourusername/development`). Consider using
116 `CCACHE_SLOPPINESS=include_file_mtime` (since if you are using multiple working
117 directories, header times in svn sync'ed portions of your trees will be
119 [the ccache troubleshooting section](http://ccache.samba.org/manual.html#_troubleshooting)
120 for additional information). If you use symbolic links from your home directory
121 to get to the local physical disk directory where you keep those working
122 development directories, consider putting
126 in your `.bashrc` so that `$PWD` or `cwd` always refers to a physical, not
127 logical directory (and make sure `CCACHE_BASEDIR` also refers to a physical
130 If you tune ccache correctly, a second working directory that uses a branch
131 tracking trunk and is up-to-date with trunk and was gclient sync'ed at about the
132 same time should build chrome in about 1/3 the time, and the cache misses as
133 reported by `ccache -s` should barely increase.
135 This is especially useful if you use `git-new-workdir` and keep multiple local
136 working directories going at once.
140 You can use tmpfs for the build output to reduce the amount of disk writes
141 required. I.e. mount tmpfs to the output directory where the build output goes:
145 mount -t tmpfs -o size=20G,nr_inodes=40k,mode=1777 tmpfs /path/to/out
148 **Caveat:** You need to have enough RAM + swap to back the tmpfs. For a full
149 debug build, you will need about 20 GB. Less for just building the chrome target
150 or for a release build.
153 Quick and dirty benchmark numbers on a HP Z600 (Intel core i7, 16 cores
154 hyperthreaded, 12 GB RAM)