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