dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 1 | # Checking out and building Chromium on Linux |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 2 | |
Victor Costan | 44af72b | 2017-11-13 20:01:30 | [diff] [blame] | 3 | There are instructions for other platforms linked from the |
Nicolas Norvez | ba04006 | 2020-01-15 01:17:26 | [diff] [blame] | 4 | [get the code](../get_the_code.md) page. |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 5 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 6 | ## Instructions for Google Employees |
| 7 | |
| 8 | Are you a Google employee? See |
| 9 | [go/building-chrome](https://goto.google.com/building-chrome) instead. |
andybons | 8c02a1f | 2015-09-04 17:02:32 | [diff] [blame] | 10 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 11 | [TOC] |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 12 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 13 | ## System requirements |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 14 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 15 | * A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly |
| 16 | recommended. |
| 17 | * At least 100GB of free disk space. |
Mike Taylor | fe7d72e | 2021-10-11 15:03:11 | [diff] [blame] | 18 | * You must have Git and Python v3.6+ installed already (and `python3` must point |
| 19 | to a Python v3.6+ binary). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 20 | |
Johann | 112b198b | 2021-07-01 00:25:33 | [diff] [blame] | 21 | Most development is done on Ubuntu (currently 18.04, Bionic Beaver). There are |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 22 | some instructions for other distros below, but they are mostly unsupported. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 23 | |
Brian Sheedy | cadbcd2 | 2022-11-09 23:50:15 | [diff] [blame] | 24 | ### Docker requirements |
| 25 | |
| 26 | While it is not a common setup, Chromium compilation should work from within a |
| 27 | Docker container. If you choose to compile from within a container for whatever |
| 28 | reason, you will need to make sure that the following tools are available: |
| 29 | |
| 30 | * `curl` |
| 31 | * `git` |
| 32 | * `lsb_release` |
| 33 | * `python3` |
| 34 | * `sudo` |
| 35 | |
| 36 | There may be additional Docker-specific issues during compilation. See |
| 37 | [this bug](https://crbug.com/1377520) for additional details on this. |
| 38 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 39 | ## Install `depot_tools` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 40 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 41 | Clone the `depot_tools` repository: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 42 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 43 | ```shell |
| 44 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 45 | ``` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 46 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 47 | Add `depot_tools` to the end of your PATH (you will probably want to put this |
| 48 | in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to |
| 49 | `/path/to/depot_tools`: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 50 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 51 | ```shell |
| 52 | $ export PATH="$PATH:/path/to/depot_tools" |
| 53 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 54 | |
Claudio DeSouza | ae44ac1 | 2018-02-13 16:11:45 | [diff] [blame] | 55 | When cloning `depot_tools` to your home directory **do not** use `~` on PATH, |
| 56 | otherwise `gclient runhooks` will fail to run. Rather, you should use either |
| 57 | `$HOME` or the absolute path: |
| 58 | |
| 59 | ```shell |
| 60 | $ export PATH="$PATH:${HOME}/depot_tools" |
| 61 | ``` |
| 62 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 63 | ## Get the code |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 64 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 65 | Create a `chromium` directory for the checkout and change to it (you can call |
| 66 | this whatever you like and put it wherever you like, as long as the full path |
| 67 | has no spaces): |
| 68 | |
| 69 | ```shell |
| 70 | $ mkdir ~/chromium && cd ~/chromium |
| 71 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 72 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 73 | Run the `fetch` tool from depot_tools to check out the code and its |
| 74 | dependencies. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 75 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 76 | ```shell |
| 77 | $ fetch --nohooks chromium |
| 78 | ``` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 79 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 80 | If you don't want the full repo history, you can save a lot of time by |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 81 | adding the `--no-history` flag to `fetch`. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 82 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 83 | Expect the command to take 30 minutes on even a fast connection, and many |
| 84 | hours on slower ones. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 85 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 86 | If you've already installed the build dependencies on the machine (from another |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 87 | checkout, for example), you can omit the `--nohooks` flag and `fetch` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 88 | will automatically execute `gclient runhooks` at the end. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 89 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 90 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
| 91 | directory called `src` in the working directory. The remaining instructions |
| 92 | assume you have switched to the `src` directory: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 93 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 94 | ```shell |
| 95 | $ cd src |
| 96 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 97 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 98 | ### Install additional build dependencies |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 99 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 100 | Once you have checked out the code, and assuming you're using Ubuntu, run |
| 101 | [build/install-build-deps.sh](/build/install-build-deps.sh) |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 102 | |
Aaron Gable | 3bc9368 | 2019-01-11 02:16:07 | [diff] [blame] | 103 | ```shell |
| 104 | $ ./build/install-build-deps.sh |
| 105 | ``` |
| 106 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 107 | You may need to adjust the build dependencies for other distros. There are |
| 108 | some [notes](#notes) at the end of this document, but we make no guarantees |
| 109 | for their accuracy. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 110 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 111 | ### Run the hooks |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 112 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 113 | Once you've run `install-build-deps` at least once, you can now run the |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 114 | Chromium-specific hooks, which will download additional binaries and other |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 115 | things you might need: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 116 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 117 | ```shell |
| 118 | $ gclient runhooks |
| 119 | ``` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 120 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 121 | *Optional*: You can also [install API |
| 122 | keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your |
| 123 | build to talk to some Google services, but this is not necessary for most |
| 124 | development and testing purposes. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 125 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 126 | ## Setting up the build |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 127 | |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 128 | Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 129 | a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md) |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 130 | to generate `.ninja` files. You can create any number of *build directories* |
| 131 | with different configurations. To create a build directory, run: |
andybons | 8c02a1f | 2015-09-04 17:02:32 | [diff] [blame] | 132 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 133 | ```shell |
| 134 | $ gn gen out/Default |
| 135 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 136 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 137 | * You only have to run this once for each new build directory, Ninja will |
| 138 | update the build files as needed. |
| 139 | * You can replace `Default` with another name, but |
| 140 | it should be a subdirectory of `out`. |
| 141 | * For other build arguments, including release settings, see [GN build |
| 142 | configuration](https://www.chromium.org/developers/gn-build-configuration). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 143 | The default will be a debug component build matching the current host |
| 144 | operating system and CPU. |
| 145 | * For more info on GN, run `gn help` on the command line or read the |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 146 | [quick start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 147 | |
amoylan | a960fa5 | 2016-12-09 22:47:28 | [diff] [blame] | 148 | ### <a name="faster-builds"></a>Faster builds |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 149 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 150 | This section contains some things you can change to speed up your builds, |
| 151 | sorted so that the things that make the biggest difference are first. |
| 152 | |
Fumitoshi Ukai | e15fd78 | 2019-10-15 05:52:48 | [diff] [blame] | 153 | #### Use Goma |
| 154 | |
| 155 | Google developed the distributed compiler called |
| 156 | [Goma](https://chromium.googlesource.com/infra/goma/client). |
Fumitoshi Ukai | e15fd78 | 2019-10-15 05:52:48 | [diff] [blame] | 157 | |
Yoshisato Yanagisawa | b66864e | 2021-03-11 21:22:48 | [diff] [blame] | 158 | If you would like to use `Goma` provisioned by Google, |
| 159 | please follow [Goma for Chromium contributors](https://chromium.googlesource.com/infra/goma/client/+/HEAD/doc/early-access-guide.md). |
Fumitoshi Ukai | e15fd78 | 2019-10-15 05:52:48 | [diff] [blame] | 160 | |
Yoshisato Yanagisawa | b66864e | 2021-03-11 21:22:48 | [diff] [blame] | 161 | If you are a Google employee, see |
| 162 | [go/building-chrome](https://goto.google.com/building-chrome) instead. |
Fumitoshi Ukai | e15fd78 | 2019-10-15 05:52:48 | [diff] [blame] | 163 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 164 | #### Disable NaCl |
| 165 | |
| 166 | By default, the build includes support for |
| 167 | [Native Client (NaCl)](https://developer.chrome.com/native-client), but |
Victor Costan | 44af72b | 2017-11-13 20:01:30 | [diff] [blame] | 168 | most of the time you won't need it. You can set the GN argument |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 169 | `enable_nacl=false` and it won't be built. |
| 170 | |
| 171 | #### Include fewer debug symbols |
| 172 | |
| 173 | By default GN produces a build with all of the debug assertions enabled |
| 174 | (`is_debug=true`) and including full debug info (`symbol_level=2`). Setting |
| 175 | `symbol_level=1` will produce enough information for stack traces, but not |
| 176 | line-by-line debugging. Setting `symbol_level=0` will include no debug |
| 177 | symbols at all. Either will speed up the build compared to full symbols. |
| 178 | |
Bruce Dawson | 63e0be7 | 2021-11-29 20:34:41 | [diff] [blame] | 179 | #### Disable debug symbols for Blink and v8 |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 180 | |
| 181 | Due to its extensive use of templates, the Blink code produces about half |
| 182 | of our debug symbols. If you don't ever need to debug Blink, you can set |
Bruce Dawson | 63e0be7 | 2021-11-29 20:34:41 | [diff] [blame] | 183 | the GN arg `blink_symbol_level=0`. Similarly, if you don't need to debug v8 you |
| 184 | can improve build speeds by setting the GN arg `v8_symbol_level=0`. |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 185 | |
| 186 | #### Use Icecc |
| 187 | |
| 188 | [Icecc](https://github.com/icecc/icecream) is the distributed compiler with a |
| 189 | central scheduler to share build load. Currently, many external contributors use |
Fumitoshi Ukai | e15fd78 | 2019-10-15 05:52:48 | [diff] [blame] | 190 | it. e.g. Intel, Opera, Samsung (this is not useful if you're using Goma). |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 191 | |
| 192 | In order to use `icecc`, set the following GN args: |
| 193 | |
| 194 | ``` |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 195 | use_debug_fission=false |
| 196 | is_clang=false |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 197 | ``` |
| 198 | |
Victor Costan | 44af72b | 2017-11-13 20:01:30 | [diff] [blame] | 199 | See these links for more on the |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 200 | [bundled_binutils limitation](https://github.com/icecc/icecream/commit/b2ce5b9cc4bd1900f55c3684214e409fa81e7a92), |
| 201 | the [debug fission limitation](http://gcc.gnu.org/wiki/DebugFission). |
| 202 | |
| 203 | Using the system linker may also be necessary when using glibc 2.21 or newer. |
| 204 | See [related bug](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=808181). |
| 205 | |
| 206 | #### ccache |
| 207 | |
David Sanders | ddc9a7f | 2022-01-28 03:19:19 | [diff] [blame] | 208 | You can use [ccache](https://ccache.dev) to speed up local builds (again, |
Fumitoshi Ukai | e15fd78 | 2019-10-15 05:52:48 | [diff] [blame] | 209 | this is not useful if you're using Goma). |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 210 | |
| 211 | Increase your ccache hit rate by setting `CCACHE_BASEDIR` to a parent directory |
| 212 | that the working directories all have in common (e.g., |
| 213 | `/home/yourusername/development`). Consider using |
| 214 | `CCACHE_SLOPPINESS=include_file_mtime` (since if you are using multiple working |
| 215 | directories, header times in svn sync'ed portions of your trees will be |
| 216 | different - see |
David Sanders | ddc9a7f | 2022-01-28 03:19:19 | [diff] [blame] | 217 | [the ccache troubleshooting section](https://ccache.dev/manual/latest.html#_troubleshooting) |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 218 | for additional information). If you use symbolic links from your home directory |
| 219 | to get to the local physical disk directory where you keep those working |
| 220 | development directories, consider putting |
| 221 | |
| 222 | alias cd="cd -P" |
| 223 | |
| 224 | in your `.bashrc` so that `$PWD` or `cwd` always refers to a physical, not |
| 225 | logical directory (and make sure `CCACHE_BASEDIR` also refers to a physical |
| 226 | parent). |
| 227 | |
| 228 | If you tune ccache correctly, a second working directory that uses a branch |
| 229 | tracking trunk and is up to date with trunk and was gclient sync'ed at about the |
| 230 | same time should build chrome in about 1/3 the time, and the cache misses as |
| 231 | reported by `ccache -s` should barely increase. |
| 232 | |
Song Fangzhen | 4b68a6e3 | 2021-07-14 05:53:40 | [diff] [blame] | 233 | This is especially useful if you use |
| 234 | [git-worktree](http://git-scm.com/docs/git-worktree) and keep multiple local |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 235 | working directories going at once. |
| 236 | |
| 237 | #### Using tmpfs |
| 238 | |
| 239 | You can use tmpfs for the build output to reduce the amount of disk writes |
| 240 | required. I.e. mount tmpfs to the output directory where the build output goes: |
| 241 | |
| 242 | As root: |
| 243 | |
| 244 | mount -t tmpfs -o size=20G,nr_inodes=40k,mode=1777 tmpfs /path/to/out |
| 245 | |
| 246 | *** note |
| 247 | **Caveat:** You need to have enough RAM + swap to back the tmpfs. For a full |
| 248 | debug build, you will need about 20 GB. Less for just building the chrome target |
| 249 | or for a release build. |
| 250 | *** |
| 251 | |
| 252 | Quick and dirty benchmark numbers on a HP Z600 (Intel core i7, 16 cores |
| 253 | hyperthreaded, 12 GB RAM) |
| 254 | |
| 255 | * With tmpfs: |
| 256 | * 12m:20s |
| 257 | * Without tmpfs |
| 258 | * 15m:40s |
| 259 | |
Bruce Dawson | be82320 | 2022-03-10 23:40:50 | [diff] [blame] | 260 | ### Smaller builds |
| 261 | |
| 262 | The Chrome binary contains embedded symbols by default. You can reduce its size |
| 263 | by using the Linux `strip` command to remove this debug information. You can |
| 264 | also reduce binary size by disabling debug mode, disabling dchecks, and turning |
| 265 | on all optimizations by enabling official build mode, with these GN args: |
| 266 | |
| 267 | ``` |
| 268 | is_debug = false |
| 269 | dcheck_always_on = false |
| 270 | is_official_build = true |
| 271 | ``` |
| 272 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 273 | ## Build Chromium |
| 274 | |
| 275 | Build Chromium (the "chrome" target) with Ninja using the command: |
| 276 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 277 | ```shell |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 278 | $ autoninja -C out/Default chrome |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 279 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 280 | |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 281 | (`autoninja` is a wrapper that automatically provides optimal values for the |
| 282 | arguments passed to `ninja`.) |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 283 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 284 | You can get a list of all of the other build targets from GN by running `gn ls |
| 285 | out/Default` from the command line. To compile one, pass the GN label to Ninja |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 286 | with no preceding "//" (so, for `//chrome/test:unit_tests` use `autoninja -C |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 287 | out/Default chrome/test:unit_tests`). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 288 | |
| 289 | ## Run Chromium |
| 290 | |
| 291 | Once it is built, you can simply run the browser: |
| 292 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 293 | ```shell |
| 294 | $ out/Default/chrome |
| 295 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 296 | |
| 297 | ## Running test targets |
| 298 | |
Fred Shih | 865fb8f | 2022-02-03 03:54:19 | [diff] [blame] | 299 | First build the unit_tests binary by running the command: |
| 300 | |
| 301 | ```shell |
| 302 | $ autoninja -C out/Default unit_tests |
| 303 | ``` |
| 304 | |
| 305 | You can run the tests by running the unit_tests binary. You can also limit which |
| 306 | tests are run using the `--gtest_filter` arg, e.g.: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 307 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 308 | ```shell |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 309 | $ out/Default/unit_tests --gtest_filter="PushClientTest.*" |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 310 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 311 | |
| 312 | You can find out more about GoogleTest at its |
| 313 | [GitHub page](https://github.com/google/googletest). |
| 314 | |
| 315 | ## Update your checkout |
| 316 | |
| 317 | To update an existing checkout, you can run |
| 318 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 319 | ```shell |
| 320 | $ git rebase-update |
| 321 | $ gclient sync |
| 322 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 323 | |
| 324 | The first command updates the primary Chromium source repository and rebases |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 325 | any of your local branches on top of tip-of-tree (aka the Git branch |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 326 | `origin/main`). If you don't want to use this script, you can also just use |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 327 | `git pull` or other common Git commands to update the repo. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 328 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 329 | The second command syncs dependencies to the appropriate versions and re-runs |
| 330 | hooks as needed. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 331 | |
| 332 | ## Tips, tricks, and troubleshooting |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 333 | |
| 334 | ### Linker Crashes |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 335 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 336 | If, during the final link stage: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 337 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 338 | ``` |
| 339 | LINK out/Debug/chrome |
| 340 | ``` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 341 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 342 | You get an error like: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 343 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 344 | ``` |
| 345 | collect2: ld terminated with signal 6 Aborted terminate called after throwing an instance of 'std::bad_alloc' |
| 346 | collect2: ld terminated with signal 11 [Segmentation fault], core dumped |
| 347 | ``` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 348 | |
Song Qinglin | 5ac3cf92 | 2022-11-09 04:12:22 | [diff] [blame] | 349 | or: |
| 350 | |
| 351 | ``` |
| 352 | LLVM ERROR: out of memory |
| 353 | ``` |
| 354 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 355 | you are probably running out of memory when linking. You *must* use a 64-bit |
| 356 | system to build. Try the following build settings (see [GN build |
| 357 | configuration](https://www.chromium.org/developers/gn-build-configuration) for |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 358 | other settings): |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 359 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 360 | * Build in release mode (debugging symbols require more memory): |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 361 | `is_debug = false` |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 362 | * Turn off symbols: `symbol_level = 0` |
| 363 | * Build in component mode (this is for development only, it will be slower and |
| 364 | may have broken functionality): `is_component_build = true` |
Song Qinglin | 5ac3cf92 | 2022-11-09 04:12:22 | [diff] [blame] | 365 | * For official (ThinLTO) builds on Linux, increase the vm.max_map_count kernel |
| 366 | parameter: increase the `vm.max_map_count` value from default (like 65530) |
| 367 | to for example 262144. You can run the `sudo sysctl -w vm.max_map_count=262144` |
| 368 | command to set it in the current session from the shell, or add the |
| 369 | `vm.max_map_count=262144` to /etc/sysctl.conf to save it permanently. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 370 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 371 | ### More links |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 372 | |
Nicolas Norvez | ba04006 | 2020-01-15 01:17:26 | [diff] [blame] | 373 | * Information about [building with Clang](../clang.md). |
Tom Anderson | abdbd6a | 2020-01-09 16:59:27 | [diff] [blame] | 374 | * You may want to [use a chroot](using_a_chroot.md) to |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 375 | isolate yourself from versioning or packaging conflicts. |
Tom Anderson | 93e49e49 | 2019-12-23 19:55:37 | [diff] [blame] | 376 | * Cross-compiling for ARM? See [LinuxChromiumArm](chromium_arm.md). |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 377 | * Want to use Eclipse as your IDE? See |
Tom Anderson | 93e49e49 | 2019-12-23 19:55:37 | [diff] [blame] | 378 | [LinuxEclipseDev](eclipse_dev.md). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 379 | * Want to use your built version as your default browser? See |
Tom Anderson | 93e49e49 | 2019-12-23 19:55:37 | [diff] [blame] | 380 | [LinuxDevBuildAsDefaultBrowser](dev_build_as_default_browser.md). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 381 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 382 | ## Next Steps |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 383 | |
| 384 | If you want to contribute to the effort toward a Chromium-based browser for |
Tom Anderson | 93e49e49 | 2019-12-23 19:55:37 | [diff] [blame] | 385 | Linux, please check out the [Linux Development page](development.md) for |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 386 | more information. |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 387 | |
| 388 | ## Notes for other distros <a name="notes"></a> |
| 389 | |
| 390 | ### Arch Linux |
| 391 | |
| 392 | Instead of running `install-build-deps.sh` to install build dependencies, run: |
| 393 | |
| 394 | ```shell |
| 395 | $ sudo pacman -S --needed python perl gcc gcc-libs bison flex gperf pkgconfig \ |
Timothy Gu | fe67f0b | 2021-05-20 22:07:04 | [diff] [blame] | 396 | nss alsa-lib glib2 gtk3 nspr freetype2 cairo dbus libgnome-keyring \ |
| 397 | xorg-server-xvfb xorg-xdpyinfo |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 398 | ``` |
| 399 | |
| 400 | For the optional packages on Arch Linux: |
| 401 | |
| 402 | * `php-cgi` is provided with `pacman` |
| 403 | * `wdiff` is not in the main repository but `dwdiff` is. You can get `wdiff` |
| 404 | in AUR/`yaourt` |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 405 | |
Kenneth Russell | 5629377 | 2018-09-21 01:46:15 | [diff] [blame] | 406 | ### Crostini (Debian based) |
| 407 | |
David Munro | 9b5f4c4f | 2019-07-24 08:23:27 | [diff] [blame] | 408 | First install the `file` and `lsb-release` commands for the script to run properly: |
Kenneth Russell | 5629377 | 2018-09-21 01:46:15 | [diff] [blame] | 409 | |
| 410 | ```shell |
David Munro | 9b5f4c4f | 2019-07-24 08:23:27 | [diff] [blame] | 411 | $ sudo apt-get install file lsb-release |
Kenneth Russell | 5629377 | 2018-09-21 01:46:15 | [diff] [blame] | 412 | ``` |
| 413 | |
| 414 | Then invoke install-build-deps.sh with the `--no-arm` argument, |
| 415 | because the ARM toolchain doesn't exist for this configuration: |
| 416 | |
| 417 | ```shell |
| 418 | $ sudo install-build-deps.sh --no-arm |
| 419 | ``` |
| 420 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 421 | ### Fedora |
| 422 | |
| 423 | Instead of running `build/install-build-deps.sh`, run: |
| 424 | |
| 425 | ```shell |
| 426 | su -c 'yum install git python bzip2 tar pkgconfig atk-devel alsa-lib-devel \ |
| 427 | bison binutils brlapi-devel bluez-libs-devel bzip2-devel cairo-devel \ |
| 428 | cups-devel dbus-devel dbus-glib-devel expat-devel fontconfig-devel \ |
Tom Anderson | 287339e | 2018-08-22 21:52:02 | [diff] [blame] | 429 | freetype-devel gcc-c++ glib2-devel glibc.i686 gperf glib2-devel \ |
Tim Brown | 36312fc | 2017-12-15 22:56:20 | [diff] [blame] | 430 | gtk3-devel java-1.*.0-openjdk-devel libatomic libcap-devel libffi-devel \ |
| 431 | libgcc.i686 libgnome-keyring-devel libjpeg-devel libstdc++.i686 libX11-devel \ |
| 432 | libXScrnSaver-devel libXtst-devel libxkbcommon-x11-devel ncurses-compat-libs \ |
| 433 | nspr-devel nss-devel pam-devel pango-devel pciutils-devel \ |
| 434 | pulseaudio-libs-devel zlib.i686 httpd mod_ssl php php-cli python-psutil wdiff \ |
| 435 | xorg-x11-server-Xvfb' |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 436 | ``` |
| 437 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 438 | The fonts needed by Blink's web tests can be obtained by following [these |
Victor Costan | 44af72b | 2017-11-13 20:01:30 | [diff] [blame] | 439 | instructions](https://gist.github.com/pwnall/32a3b11c2b10f6ae5c6a6de66c1e12ae). |
| 440 | For the optional packages: |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 441 | |
| 442 | * `php-cgi` is provided by the `php-cli` package. |
Victor Costan | 44af72b | 2017-11-13 20:01:30 | [diff] [blame] | 443 | * `sun-java6-fonts` is covered by the instructions linked above. |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 444 | |
| 445 | ### Gentoo |
| 446 | |
| 447 | You can just run `emerge www-client/chromium`. |
| 448 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 449 | ### OpenSUSE |
| 450 | |
| 451 | Use `zypper` command to install dependencies: |
| 452 | |
| 453 | (openSUSE 11.1 and higher) |
| 454 | |
| 455 | ```shell |
Tim Brown | 36312fc | 2017-12-15 22:56:20 | [diff] [blame] | 456 | sudo zypper in subversion pkg-config python perl bison flex gperf \ |
| 457 | mozilla-nss-devel glib2-devel gtk-devel wdiff lighttpd gcc gcc-c++ \ |
| 458 | mozilla-nspr mozilla-nspr-devel php5-fastcgi alsa-devel libexpat-devel \ |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 459 | libjpeg-devel libbz2-devel |
| 460 | ``` |
| 461 | |
| 462 | For 11.0, use `libnspr4-0d` and `libnspr4-dev` instead of `mozilla-nspr` and |
Tom Anderson | 287339e | 2018-08-22 21:52:02 | [diff] [blame] | 463 | `mozilla-nspr-devel`, and use `php5-cgi` instead of `php5-fastcgi`. |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 464 | |
| 465 | (openSUSE 11.0) |
| 466 | |
| 467 | ```shell |
| 468 | sudo zypper in subversion pkg-config python perl \ |
| 469 | bison flex gperf mozilla-nss-devel glib2-devel gtk-devel \ |
| 470 | libnspr4-0d libnspr4-dev wdiff lighttpd gcc gcc-c++ libexpat-devel \ |
Tom Anderson | 287339e | 2018-08-22 21:52:02 | [diff] [blame] | 471 | php5-cgi alsa-devel gtk3-devel jpeg-devel |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 472 | ``` |
| 473 | |
| 474 | The Ubuntu package `sun-java6-fonts` contains a subset of Java of the fonts used. |
| 475 | Since this package requires Java as a prerequisite anyway, we can do the same |
| 476 | thing by just installing the equivalent openSUSE Sun Java package: |
| 477 | |
| 478 | ```shell |
| 479 | sudo zypper in java-1_6_0-sun |
| 480 | ``` |
| 481 | |
| 482 | WebKit is currently hard-linked to the Microsoft fonts. To install these using `zypper` |
| 483 | |
| 484 | ```shell |
| 485 | sudo zypper in fetchmsttfonts pullin-msttf-fonts |
| 486 | ``` |
| 487 | |
| 488 | To make the fonts installed above work, as the paths are hardcoded for Ubuntu, |
| 489 | create symlinks to the appropriate locations: |
| 490 | |
| 491 | ```shell |
| 492 | sudo mkdir -p /usr/share/fonts/truetype/msttcorefonts |
| 493 | sudo ln -s /usr/share/fonts/truetype/arial.ttf /usr/share/fonts/truetype/msttcorefonts/Arial.ttf |
| 494 | sudo ln -s /usr/share/fonts/truetype/arialbd.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf |
| 495 | sudo ln -s /usr/share/fonts/truetype/arialbi.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf |
| 496 | sudo ln -s /usr/share/fonts/truetype/ariali.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf |
| 497 | sudo ln -s /usr/share/fonts/truetype/comic.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf |
| 498 | sudo ln -s /usr/share/fonts/truetype/comicbd.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf |
| 499 | sudo ln -s /usr/share/fonts/truetype/cour.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf |
| 500 | sudo ln -s /usr/share/fonts/truetype/courbd.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf |
| 501 | sudo ln -s /usr/share/fonts/truetype/courbi.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf |
| 502 | sudo ln -s /usr/share/fonts/truetype/couri.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf |
| 503 | sudo ln -s /usr/share/fonts/truetype/impact.ttf /usr/share/fonts/truetype/msttcorefonts/Impact.ttf |
| 504 | sudo ln -s /usr/share/fonts/truetype/times.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf |
| 505 | sudo ln -s /usr/share/fonts/truetype/timesbd.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf |
| 506 | sudo ln -s /usr/share/fonts/truetype/timesbi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttf |
| 507 | sudo ln -s /usr/share/fonts/truetype/timesi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttf |
| 508 | sudo ln -s /usr/share/fonts/truetype/verdana.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana.ttf |
| 509 | sudo ln -s /usr/share/fonts/truetype/verdanab.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf |
| 510 | sudo ln -s /usr/share/fonts/truetype/verdanai.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttf |
| 511 | sudo ln -s /usr/share/fonts/truetype/verdanaz.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf |
| 512 | ``` |
| 513 | |
| 514 | The Ubuntu package `sun-java6-fonts` contains a subset of Java of the fonts used. |
| 515 | Since this package requires Java as a prerequisite anyway, we can do the same |
| 516 | thing by just installing the equivalent openSUSE Sun Java package: |
| 517 | |
| 518 | ```shell |
| 519 | sudo zypper in java-1_6_0-sun |
| 520 | ``` |
| 521 | |
| 522 | WebKit is currently hard-linked to the Microsoft fonts. To install these using `zypper` |
| 523 | |
| 524 | ```shell |
| 525 | sudo zypper in fetchmsttfonts pullin-msttf-fonts |
| 526 | ``` |
| 527 | |
| 528 | To make the fonts installed above work, as the paths are hardcoded for Ubuntu, |
| 529 | create symlinks to the appropriate locations: |
| 530 | |
| 531 | ```shell |
| 532 | sudo mkdir -p /usr/share/fonts/truetype/msttcorefonts |
| 533 | sudo ln -s /usr/share/fonts/truetype/arial.ttf /usr/share/fonts/truetype/msttcorefonts/Arial.ttf |
| 534 | sudo ln -s /usr/share/fonts/truetype/arialbd.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf |
| 535 | sudo ln -s /usr/share/fonts/truetype/arialbi.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf |
| 536 | sudo ln -s /usr/share/fonts/truetype/ariali.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf |
| 537 | sudo ln -s /usr/share/fonts/truetype/comic.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf |
| 538 | sudo ln -s /usr/share/fonts/truetype/comicbd.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf |
| 539 | sudo ln -s /usr/share/fonts/truetype/cour.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf |
| 540 | sudo ln -s /usr/share/fonts/truetype/courbd.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf |
| 541 | sudo ln -s /usr/share/fonts/truetype/courbi.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf |
| 542 | sudo ln -s /usr/share/fonts/truetype/couri.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf |
| 543 | sudo ln -s /usr/share/fonts/truetype/impact.ttf /usr/share/fonts/truetype/msttcorefonts/Impact.ttf |
| 544 | sudo ln -s /usr/share/fonts/truetype/times.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf |
| 545 | sudo ln -s /usr/share/fonts/truetype/timesbd.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf |
| 546 | sudo ln -s /usr/share/fonts/truetype/timesbi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttf |
| 547 | sudo ln -s /usr/share/fonts/truetype/timesi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttf |
| 548 | sudo ln -s /usr/share/fonts/truetype/verdana.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana.ttf |
| 549 | sudo ln -s /usr/share/fonts/truetype/verdanab.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf |
| 550 | sudo ln -s /usr/share/fonts/truetype/verdanai.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttf |
| 551 | sudo ln -s /usr/share/fonts/truetype/verdanaz.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf |
| 552 | ``` |
| 553 | |
| 554 | And then for the Java fonts: |
| 555 | |
| 556 | ```shell |
| 557 | sudo mkdir -p /usr/share/fonts/truetype/ttf-lucida |
| 558 | sudo find /usr/lib*/jvm/java-1.6.*-sun-*/jre/lib -iname '*.ttf' -print \ |
| 559 | -exec ln -s {} /usr/share/fonts/truetype/ttf-lucida \; |
| 560 | ``` |