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 | |
Bruce Dawson | c266172 | 2024-06-12 19:44:29 | [diff] [blame] | 15 | * An x86-64 machine with at least 8GB of RAM. More than 16GB is highly |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 16 | recommended. If your machine has an SSD, it is recommended to have |
| 17 | \>=32GB/>=16GB of swap for machines with 8GB/16GB of RAM respectively. |
| 18 | * At least 100GB of free disk space. It does not have to be on the same drive; |
| 19 | Allocate ~50-80GB on HDD for build. |
zhoupeng | 6ebd49d | 2025-04-03 20:45:00 | [diff] [blame] | 20 | * You must have Git and Python v3.9+ installed already (and `python3` must point |
| 21 | to a Python v3.9+ binary). Depot_tools bundles an appropriate version |
Dirk Pranke | 8766b622c | 2023-08-30 23:19:36 | [diff] [blame] | 22 | of Python in `$depot_tools/python-bin`, if you don't have an appropriate |
| 23 | version already on your system. |
Junji Watanabe | dab18d1 | 2025-04-09 04:04:01 | [diff] [blame] | 24 | * Chromium's build infrastructure and `depot_tools` currently use Python 3.11. |
| 25 | If something is broken with an older Python version, feel free to report or |
| 26 | send us fixes. |
Peter Kasting | beb265c | 2024-10-31 20:22:56 | [diff] [blame] | 27 | * `libc++` is currently the only supported STL. `clang` is the only |
| 28 | officially-supported compiler, though external community members generally |
| 29 | keep things building with `gcc`. For more details, see the |
| 30 | [supported toolchains doc](../toolchain_support.md). |
Ben Pastene | d89a45b | 2023-06-28 22:57:34 | [diff] [blame] | 31 | |
| 32 | Most development is done on Ubuntu (Chromium's build infrastructure currently |
| 33 | runs 22.04, Jammy Jellyfish). There are some instructions for other distros |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 34 | below, but they are mostly unsupported, but installation instructions can be found in [Docker](#docker). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 35 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 36 | ## Install `depot_tools` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 37 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 38 | Clone the `depot_tools` repository: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 39 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 40 | ```shell |
| 41 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 42 | ``` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 43 | |
mark a. foltz | 89670afb | 2023-08-20 18:14:07 | [diff] [blame] | 44 | Add `depot_tools` to the beginning of your `PATH` (you will probably want to put |
| 45 | this in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 46 | `/path/to/depot_tools`: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 47 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 48 | ```shell |
mark a. foltz | 89670afb | 2023-08-20 18:14:07 | [diff] [blame] | 49 | $ export PATH="/path/to/depot_tools:$PATH" |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 50 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 51 | |
Claudio DeSouza | ae44ac1 | 2018-02-13 16:11:45 | [diff] [blame] | 52 | When cloning `depot_tools` to your home directory **do not** use `~` on PATH, |
| 53 | otherwise `gclient runhooks` will fail to run. Rather, you should use either |
| 54 | `$HOME` or the absolute path: |
| 55 | |
| 56 | ```shell |
mark a. foltz | 89670afb | 2023-08-20 18:14:07 | [diff] [blame] | 57 | $ export PATH="${HOME}/depot_tools:$PATH" |
Claudio DeSouza | ae44ac1 | 2018-02-13 16:11:45 | [diff] [blame] | 58 | ``` |
| 59 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 60 | ## Get the code |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 61 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 62 | Create a `chromium` directory for the checkout and change to it (you can call |
| 63 | this whatever you like and put it wherever you like, as long as the full path |
| 64 | has no spaces): |
| 65 | |
| 66 | ```shell |
| 67 | $ mkdir ~/chromium && cd ~/chromium |
| 68 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 69 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 70 | Run the `fetch` tool from depot_tools to check out the code and its |
| 71 | dependencies. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 72 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 73 | ```shell |
| 74 | $ fetch --nohooks chromium |
| 75 | ``` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 76 | |
Delan Azabani | 43eefa3d | 2024-05-09 03:39:33 | [diff] [blame] | 77 | *** note |
| 78 | **NixOS users:** tools like `fetch` won’t work without a Nix shell. Clone [the |
| 79 | tools repo](https://chromium.googlesource.com/chromium/src/tools) with `git`, |
| 80 | then run `nix-shell tools/nix/shell.nix`. |
| 81 | *** |
| 82 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 83 | 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] | 84 | adding the `--no-history` flag to `fetch`. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 85 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 86 | Expect the command to take 30 minutes on even a fast connection, and many |
| 87 | hours on slower ones. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 88 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 89 | If you've already installed the build dependencies on the machine (from another |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 90 | checkout, for example), you can omit the `--nohooks` flag and `fetch` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 91 | will automatically execute `gclient runhooks` at the end. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 92 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 93 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
| 94 | directory called `src` in the working directory. The remaining instructions |
| 95 | assume you have switched to the `src` directory: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 96 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 97 | ```shell |
| 98 | $ cd src |
| 99 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 100 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 101 | ### Install additional build dependencies |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 102 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 103 | Once you have checked out the code, and assuming you're using Ubuntu, run |
| 104 | [build/install-build-deps.sh](/build/install-build-deps.sh) |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 105 | |
Aaron Gable | 3bc9368 | 2019-01-11 02:16:07 | [diff] [blame] | 106 | ```shell |
| 107 | $ ./build/install-build-deps.sh |
| 108 | ``` |
| 109 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 110 | You may need to adjust the build dependencies for other distros. There are |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 111 | some [notes](#notes-for-other-distros) at the end of this document, but we make no guarantees |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 112 | for their accuracy. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 113 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 114 | ### Run the hooks |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 115 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 116 | 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] | 117 | Chromium-specific hooks, which will download additional binaries and other |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 118 | things you might need: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 119 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 120 | ```shell |
| 121 | $ gclient runhooks |
| 122 | ``` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 123 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 124 | *Optional*: You can also [install API |
| 125 | keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your |
| 126 | build to talk to some Google services, but this is not necessary for most |
| 127 | development and testing purposes. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 128 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 129 | ## Setting up the build |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 130 | |
Fumitoshi Ukai | c9f326d | 2025-04-24 01:06:28 | [diff] [blame] | 131 | Chromium uses [Siso](https://pkg.go.dev/go.chromium.org/infra/build/siso#section-readme) |
| 132 | as its main build tool along with |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 133 | 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] | 134 | to generate `.ninja` files. You can create any number of *build directories* |
| 135 | with different configurations. To create a build directory, run: |
andybons | 8c02a1f | 2015-09-04 17:02:32 | [diff] [blame] | 136 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 137 | ```shell |
| 138 | $ gn gen out/Default |
| 139 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 140 | |
Fumitoshi Ukai | c9f326d | 2025-04-24 01:06:28 | [diff] [blame] | 141 | * You only have to run this once for each new build directory, Siso will |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 142 | update the build files as needed. |
| 143 | * You can replace `Default` with another name, but |
| 144 | it should be a subdirectory of `out`. |
| 145 | * For other build arguments, including release settings, see [GN build |
| 146 | configuration](https://www.chromium.org/developers/gn-build-configuration). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 147 | The default will be a debug component build matching the current host |
| 148 | operating system and CPU. |
| 149 | * 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] | 150 | [quick start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 151 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 152 | ### Faster builds |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 153 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 154 | This section contains some things you can change to speed up your builds, |
| 155 | sorted so that the things that make the biggest difference are first. |
| 156 | |
Fumitoshi Ukai | 33465857 | 2025-04-09 00:59:30 | [diff] [blame] | 157 | #### Use Remote Execution |
Takuto Ikuta | 66f5de8 | 2023-09-08 03:55:44 | [diff] [blame] | 158 | |
Takuto Ikuta | 77654728 | 2023-11-10 01:42:33 | [diff] [blame] | 159 | *** note |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 160 | **Warning:** If you are a Google employee, do not follow the instructions below. |
Andrew Williams | 54da9cc | 2024-01-09 17:32:23 | [diff] [blame] | 161 | See |
| 162 | [go/chrome-linux-build#setup-remote-execution](https://goto.google.com/chrome-linux-build#setup-remote-execution) |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 163 | instead. |
Takuto Ikuta | 77654728 | 2023-11-10 01:42:33 | [diff] [blame] | 164 | *** |
| 165 | |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 166 | Chromium's build can be sped up significantly by using a remote execution system |
| 167 | compatible with [REAPI](https://github.com/bazelbuild/remote-apis). This allows |
| 168 | you to benefit from remote caching and executing many build actions in parallel |
| 169 | on a shared cluster of workers. |
Fumitoshi Ukai | 8c123e9 | 2025-04-23 06:06:44 | [diff] [blame] | 170 | Chromium's build uses a client developed by Google called |
| 171 | [Siso](https://pkg.go.dev/go.chromium.org/infra/build/siso#section-readme) |
| 172 | to remotely execute build actions. |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 173 | |
Fumitoshi Ukai | 8c123e9 | 2025-04-23 06:06:44 | [diff] [blame] | 174 | To get started, you need access to an REAPI-compatible backend. |
| 175 | |
| 176 | The following instructions assume that you received an invitation from Google |
| 177 | to use Chromium's RBE service and were granted access to it. |
Takuto Ikuta | 1b118a8 | 2023-11-28 05:55:25 | [diff] [blame] | 178 | For contributors who have |
| 179 | [tryjob access](https://www.chromium.org/getting-involved/become-a-committer/#try-job-access) |
| 180 | , please ask a Googler to email [email protected] on your behalf to access |
Fumitoshi Ukai | 8c123e9 | 2025-04-23 06:06:44 | [diff] [blame] | 181 | RBE backend paid by Google. Note that remote execution for external |
| 182 | contributors is a best-effort process. We do not guarantee when you will be |
| 183 | invited. |
Takuto Ikuta | 1b118a8 | 2023-11-28 05:55:25 | [diff] [blame] | 184 | |
Fumitoshi Ukai | 8c123e9 | 2025-04-23 06:06:44 | [diff] [blame] | 185 | For others who have no access to Google's RBE backends, you are welcome |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 186 | to use any of the |
| 187 | [other compatible backends](https://github.com/bazelbuild/remote-apis#servers), |
| 188 | in which case you will have to adapt the following instructions regarding the |
| 189 | authentication method, instance name, etc. to work with your backend. |
| 190 | |
Fumitoshi Ukai | 8c123e9 | 2025-04-23 06:06:44 | [diff] [blame] | 191 | If you would like to use `siso` with Google's RBE, |
Fumitoshi Ukai | 33465857 | 2025-04-09 00:59:30 | [diff] [blame] | 192 | you'll first need to: |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 193 | |
Fumitoshi Ukai | 33465857 | 2025-04-09 00:59:30 | [diff] [blame] | 194 | 1. Run `siso login` and login with your authorized account. |
Fumitoshi Ukai | 8c123e9 | 2025-04-23 06:06:44 | [diff] [blame] | 195 | If it is blocked in OAuth2 flow, run `gcloud auth login` instead. |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 196 | |
| 197 | Next, you'll have to specify your `rbe_instance` in your `.gclient` |
| 198 | configuration to use the correct one for Chromium contributors: |
| 199 | |
Michael Savigny | 9560099 | 2024-04-10 13:59:10 | [diff] [blame] | 200 | *** note |
| 201 | **Warning:** If you are a Google employee, do not follow the instructions below. |
| 202 | See |
| 203 | [go/chrome-linux-build#setup-remote-execution](https://goto.google.com/chrome-linux-build#setup-remote-execution) |
| 204 | instead. |
| 205 | *** |
| 206 | |
Takuto Ikuta | 66f5de8 | 2023-09-08 03:55:44 | [diff] [blame] | 207 | ``` |
| 208 | solutions = [ |
| 209 | { |
| 210 | ..., |
| 211 | "custom_vars": { |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 212 | # This is the correct instance name for using Chromium's RBE service. |
| 213 | # You can only use it if you were granted access to it. If you use your |
| 214 | # own REAPI-compatible backend, you will need to change this accordingly |
| 215 | # to its requirements. |
| 216 | "rbe_instance": "projects/rbe-chromium-untrusted/instances/default_instance", |
Takuto Ikuta | 66f5de8 | 2023-09-08 03:55:44 | [diff] [blame] | 217 | }, |
| 218 | }, |
| 219 | ] |
| 220 | ``` |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 221 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 222 | And run `gclient sync`. This will regenerate the config files in |
Fumitoshi Ukai | 33465857 | 2025-04-09 00:59:30 | [diff] [blame] | 223 | `build/config/siso/backend_config/backend.star` to use the `rbe_instance` |
| 224 | that you just added to your `.gclient` file. |
Fumitoshi Ukai | 8c123e9 | 2025-04-23 06:06:44 | [diff] [blame] | 225 | |
Fumitoshi Ukai | 33465857 | 2025-04-09 00:59:30 | [diff] [blame] | 226 | If `rbe_instance` is not owned by Google, you may need to create your |
| 227 | own `backend.star`. See |
| 228 | [build/config/siso/backend_config/README.md](../../build/config/siso/backend_config/README.md). |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 229 | |
| 230 | Then, add the following GN args to your `args.gn`: |
| 231 | |
Takuto Ikuta | 66f5de8 | 2023-09-08 03:55:44 | [diff] [blame] | 232 | ``` |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 233 | use_remoteexec = true |
Fumitoshi Ukai | 33465857 | 2025-04-09 00:59:30 | [diff] [blame] | 234 | use_siso = true |
Takuto Ikuta | 66f5de8 | 2023-09-08 03:55:44 | [diff] [blame] | 235 | ``` |
| 236 | |
Fumitoshi Ukai | 8c123e9 | 2025-04-23 06:06:44 | [diff] [blame] | 237 | If `args.gn` contains `use_reclient=true`, drop it or replace it with |
| 238 | `use_reclient=false`. |
| 239 | |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 240 | That's it. Remember to always use `autoninja` for building Chromium as described |
Fumitoshi Ukai | c9f326d | 2025-04-24 01:06:28 | [diff] [blame] | 241 | below, instead of directly invoking `siso` or `ninja`. |
Philipp Wollermann | 43f9cb8 | 2023-11-27 05:33:19 | [diff] [blame] | 242 | |
Fumitoshi Ukai | 8c123e9 | 2025-04-23 06:06:44 | [diff] [blame] | 243 | Reach out to |
| 244 | [[email protected]](https://groups.google.com/a/chromium.org/g/build) |
| 245 | if you have any questions about remote execution usage. |
| 246 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 247 | #### Include fewer debug symbols |
| 248 | |
| 249 | By default GN produces a build with all of the debug assertions enabled |
| 250 | (`is_debug=true`) and including full debug info (`symbol_level=2`). Setting |
| 251 | `symbol_level=1` will produce enough information for stack traces, but not |
| 252 | line-by-line debugging. Setting `symbol_level=0` will include no debug |
| 253 | symbols at all. Either will speed up the build compared to full symbols. |
| 254 | |
Bruce Dawson | 63e0be7 | 2021-11-29 20:34:41 | [diff] [blame] | 255 | #### Disable debug symbols for Blink and v8 |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 256 | |
| 257 | Due to its extensive use of templates, the Blink code produces about half |
| 258 | 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] | 259 | the GN arg `blink_symbol_level=0`. Similarly, if you don't need to debug v8 you |
| 260 | can improve build speeds by setting the GN arg `v8_symbol_level=0`. |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 261 | |
| 262 | #### Use Icecc |
| 263 | |
| 264 | [Icecc](https://github.com/icecc/icecream) is the distributed compiler with a |
| 265 | central scheduler to share build load. Currently, many external contributors use |
Fumitoshi Ukai | 33465857 | 2025-04-09 00:59:30 | [diff] [blame] | 266 | it. e.g. Intel, Opera, Samsung (this is not useful if you're using Siso). |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 267 | |
| 268 | In order to use `icecc`, set the following GN args: |
| 269 | |
| 270 | ``` |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 271 | use_debug_fission=false |
| 272 | is_clang=false |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 273 | ``` |
| 274 | |
Victor Costan | 44af72b | 2017-11-13 20:01:30 | [diff] [blame] | 275 | See these links for more on the |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 276 | [bundled_binutils limitation](https://github.com/icecc/icecream/commit/b2ce5b9cc4bd1900f55c3684214e409fa81e7a92), |
| 277 | the [debug fission limitation](http://gcc.gnu.org/wiki/DebugFission). |
| 278 | |
| 279 | Using the system linker may also be necessary when using glibc 2.21 or newer. |
| 280 | See [related bug](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=808181). |
| 281 | |
| 282 | #### ccache |
| 283 | |
David Sanders | ddc9a7f | 2022-01-28 03:19:19 | [diff] [blame] | 284 | You can use [ccache](https://ccache.dev) to speed up local builds (again, |
Fumitoshi Ukai | 33465857 | 2025-04-09 00:59:30 | [diff] [blame] | 285 | this is not useful if you're using Siso). |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 286 | |
| 287 | Increase your ccache hit rate by setting `CCACHE_BASEDIR` to a parent directory |
| 288 | that the working directories all have in common (e.g., |
| 289 | `/home/yourusername/development`). Consider using |
| 290 | `CCACHE_SLOPPINESS=include_file_mtime` (since if you are using multiple working |
| 291 | directories, header times in svn sync'ed portions of your trees will be |
| 292 | different - see |
David Sanders | ddc9a7f | 2022-01-28 03:19:19 | [diff] [blame] | 293 | [the ccache troubleshooting section](https://ccache.dev/manual/latest.html#_troubleshooting) |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 294 | for additional information). If you use symbolic links from your home directory |
| 295 | to get to the local physical disk directory where you keep those working |
| 296 | development directories, consider putting |
| 297 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 298 | ``` |
| 299 | alias cd="cd -P" |
| 300 | ``` |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 301 | |
| 302 | in your `.bashrc` so that `$PWD` or `cwd` always refers to a physical, not |
| 303 | logical directory (and make sure `CCACHE_BASEDIR` also refers to a physical |
| 304 | parent). |
| 305 | |
| 306 | If you tune ccache correctly, a second working directory that uses a branch |
| 307 | tracking trunk and is up to date with trunk and was gclient sync'ed at about the |
| 308 | same time should build chrome in about 1/3 the time, and the cache misses as |
| 309 | reported by `ccache -s` should barely increase. |
| 310 | |
Song Fangzhen | 4b68a6e3 | 2021-07-14 05:53:40 | [diff] [blame] | 311 | This is especially useful if you use |
| 312 | [git-worktree](http://git-scm.com/docs/git-worktree) and keep multiple local |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 313 | working directories going at once. |
| 314 | |
| 315 | #### Using tmpfs |
| 316 | |
| 317 | You can use tmpfs for the build output to reduce the amount of disk writes |
| 318 | required. I.e. mount tmpfs to the output directory where the build output goes: |
| 319 | |
| 320 | As root: |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 321 | ``` |
| 322 | mount -t tmpfs -o size=20G,nr_inodes=40k,mode=1777 tmpfs /path/to/out |
| 323 | ``` |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 324 | |
| 325 | *** note |
| 326 | **Caveat:** You need to have enough RAM + swap to back the tmpfs. For a full |
| 327 | debug build, you will need about 20 GB. Less for just building the chrome target |
| 328 | or for a release build. |
| 329 | *** |
| 330 | |
| 331 | Quick and dirty benchmark numbers on a HP Z600 (Intel core i7, 16 cores |
| 332 | hyperthreaded, 12 GB RAM) |
| 333 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 334 | * With tmpfs: |
| 335 | * 12m:20s |
| 336 | * Without tmpfs |
| 337 | * 15m:40s |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 338 | |
Bruce Dawson | be82320 | 2022-03-10 23:40:50 | [diff] [blame] | 339 | ### Smaller builds |
| 340 | |
| 341 | The Chrome binary contains embedded symbols by default. You can reduce its size |
| 342 | 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] | 343 | also reduce binary size and turn on all optimizations by enabling official build |
| 344 | mode, with the GN arg `is_official_build = true`. |
Bruce Dawson | be82320 | 2022-03-10 23:40:50 | [diff] [blame] | 345 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 346 | ## Build Chromium |
| 347 | |
Fumitoshi Ukai | c9f326d | 2025-04-24 01:06:28 | [diff] [blame] | 348 | Build Chromium (the "chrome" target) with Siso or Ninja using the command: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 349 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 350 | ```shell |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 351 | $ autoninja -C out/Default chrome |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 352 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 353 | |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 354 | (`autoninja` is a wrapper that automatically provides optimal values for the |
Fumitoshi Ukai | c9f326d | 2025-04-24 01:06:28 | [diff] [blame] | 355 | arguments passed to `siso` or `ninja`.) |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 356 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 357 | You can get a list of all of the other build targets from GN by running `gn ls |
Fumitoshi Ukai | c9f326d | 2025-04-24 01:06:28 | [diff] [blame] | 358 | out/Default` from the command line. To compile one, pass the GN label to |
| 359 | Siso/Ninja with no preceding "//" (so, for `//chrome/test:unit_tests` use |
| 360 | `autoninja -C out/Default chrome/test:unit_tests`). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 361 | |
Junji Watanabe | 7037b95f | 2024-04-22 06:14:15 | [diff] [blame] | 362 | ## Compile a single file |
| 363 | |
Fumitoshi Ukai | c9f326d | 2025-04-24 01:06:28 | [diff] [blame] | 364 | Siso/Ninja supports a special [syntax `^`][ninja hat syntax] to compile a single object file specifying |
Junji Watanabe | 7037b95f | 2024-04-22 06:14:15 | [diff] [blame] | 365 | the source file. For example, `autoninja -C out/Default ../../base/logging.cc^` |
| 366 | compiles `obj/base/base/logging.o`. |
| 367 | |
| 368 | [ninja hat syntax]: https://ninja-build.org/manual.html#:~:text=There%20is%20also%20a%20special%20syntax%20target%5E%20for%20specifying%20a%20target%20as%20the%20first%20output%20of%20some%20rule%20containing%20the%20source%20you%20put%20in%20the%20command%20line%2C%20if%20one%20exists.%20For%20example%2C%20if%20you%20specify%20target%20as%20foo.c%5E%20then%20foo.o%20will%20get%20built%20(assuming%20you%20have%20those%20targets%20in%20your%20build%20files) |
| 369 | |
| 370 | In addition to `foo.cc^`, Siso also supports `foo.h^` syntax to compile |
| 371 | the corresponding `foo.o` if it exists. |
| 372 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 373 | ## Run Chromium |
| 374 | |
| 375 | Once it is built, you can simply run the browser: |
| 376 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 377 | ```shell |
| 378 | $ out/Default/chrome |
| 379 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 380 | |
Victor Vianna | eda6fcc4 | 2023-03-14 17:18:22 | [diff] [blame] | 381 | If you're using a remote machine that supports Chrome Remote Desktop, you can |
| 382 | add this to your .bashrc / .bash_profile. |
| 383 | |
| 384 | ```shell |
| 385 | if [[ -z "${DISPLAY}" ]]; then |
Victor Hugo Vianna Silva | 451142c2 | 2024-07-08 21:37:41 | [diff] [blame] | 386 | # In reality, Chrome Remote Desktop starts with 20 and increases until it |
| 387 | # finds an available ID [1]. So this isn't guaranteed to always work, but |
| 388 | # should work on the vast majoriy of cases. |
| 389 | # |
| 390 | # [1] https://source.chromium.org/chromium/chromium/src/+/main:remoting/host/linux/linux_me2me_host.py;l=112;drc=464a632e21bcec76c743930d4db8556613e21fd8 |
| 391 | export DISPLAY=:20 |
Victor Vianna | eda6fcc4 | 2023-03-14 17:18:22 | [diff] [blame] | 392 | fi |
| 393 | ``` |
| 394 | |
| 395 | This means if you launch Chrome from an SSH session, the UI output will be |
| 396 | available in Chrome Remote Desktop. |
| 397 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 398 | ## Running test targets |
| 399 | |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 400 | Tests are split into multiple test targets based on their type and where they |
| 401 | exist in the directory structure. To see what target a given unit test or |
| 402 | browser test file corresponds to, the following command can be used: |
| 403 | |
| 404 | ```shell |
| 405 | $ gn refs out/Default --testonly=true --type=executable --all chrome/browser/ui/browser_list_unittest.cc |
| 406 | //chrome/test:unit_tests |
| 407 | ``` |
| 408 | |
| 409 | In the example above, the target is unit_tests. The unit_tests binary can be |
| 410 | built by running the following command: |
Fred Shih | 865fb8f | 2022-02-03 03:54:19 | [diff] [blame] | 411 | |
| 412 | ```shell |
| 413 | $ autoninja -C out/Default unit_tests |
| 414 | ``` |
| 415 | |
| 416 | You can run the tests by running the unit_tests binary. You can also limit which |
| 417 | tests are run using the `--gtest_filter` arg, e.g.: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 418 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 419 | ```shell |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 420 | $ out/Default/unit_tests --gtest_filter="BrowserListUnitTest.*" |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 421 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 422 | |
| 423 | You can find out more about GoogleTest at its |
| 424 | [GitHub page](https://github.com/google/googletest). |
| 425 | |
| 426 | ## Update your checkout |
| 427 | |
| 428 | To update an existing checkout, you can run |
| 429 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 430 | ```shell |
| 431 | $ git rebase-update |
| 432 | $ gclient sync |
| 433 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 434 | |
| 435 | The first command updates the primary Chromium source repository and rebases |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 436 | 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] | 437 | `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] | 438 | `git pull` or other common Git commands to update the repo. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 439 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 440 | The second command syncs dependencies to the appropriate versions and re-runs |
| 441 | hooks as needed. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 442 | |
| 443 | ## Tips, tricks, and troubleshooting |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 444 | |
| 445 | ### Linker Crashes |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 446 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 447 | If, during the final link stage: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 448 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 449 | ``` |
| 450 | LINK out/Debug/chrome |
| 451 | ``` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 452 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 453 | You get an error like: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 454 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 455 | ``` |
| 456 | collect2: ld terminated with signal 6 Aborted terminate called after throwing an instance of 'std::bad_alloc' |
| 457 | collect2: ld terminated with signal 11 [Segmentation fault], core dumped |
| 458 | ``` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 459 | |
Song Qinglin | 5ac3cf92 | 2022-11-09 04:12:22 | [diff] [blame] | 460 | or: |
| 461 | |
| 462 | ``` |
| 463 | LLVM ERROR: out of memory |
| 464 | ``` |
| 465 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 466 | you are probably running out of memory when linking. You *must* use a 64-bit |
| 467 | system to build. Try the following build settings (see [GN build |
| 468 | configuration](https://www.chromium.org/developers/gn-build-configuration) for |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 469 | other settings): |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 470 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 471 | * Build in release mode (debugging symbols require more memory): |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 472 | `is_debug = false` |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 473 | * Turn off symbols: `symbol_level = 0` |
| 474 | * Build in component mode (this is for development only, it will be slower and |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 475 | may have broken functionality): `is_component_build = true` |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 476 | * For official (ThinLTO) builds on Linux, increase the vm.max_map_count kernel |
Song Qinglin | 5ac3cf92 | 2022-11-09 04:12:22 | [diff] [blame] | 477 | parameter: increase the `vm.max_map_count` value from default (like 65530) |
| 478 | to for example 262144. You can run the `sudo sysctl -w vm.max_map_count=262144` |
| 479 | command to set it in the current session from the shell, or add the |
| 480 | `vm.max_map_count=262144` to /etc/sysctl.conf to save it permanently. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 481 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 482 | ### More links |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 483 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 484 | * Information about [building with Clang](../clang.md). |
| 485 | * You may want to [use a chroot](using_a_chroot.md) to |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 486 | isolate yourself from versioning or packaging conflicts. |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 487 | * Cross-compiling for ARM? See [LinuxChromiumArm](chromium_arm.md). |
| 488 | * Want to use Eclipse as your IDE? See |
Tom Anderson | 93e49e49 | 2019-12-23 19:55:37 | [diff] [blame] | 489 | [LinuxEclipseDev](eclipse_dev.md). |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 490 | * Want to use your built version as your default browser? See |
Tom Anderson | 93e49e49 | 2019-12-23 19:55:37 | [diff] [blame] | 491 | [LinuxDevBuildAsDefaultBrowser](dev_build_as_default_browser.md). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 492 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 493 | ## Next Steps |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 494 | |
| 495 | 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] | 496 | Linux, please check out the [Linux Development page](development.md) for |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 497 | more information. |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 498 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 499 | ## Notes for other distros |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 500 | |
| 501 | ### Arch Linux |
| 502 | |
| 503 | Instead of running `install-build-deps.sh` to install build dependencies, run: |
| 504 | |
| 505 | ```shell |
| 506 | $ sudo pacman -S --needed python perl gcc gcc-libs bison flex gperf pkgconfig \ |
Tom Anderson | 761687a | 2023-06-14 17:27:39 | [diff] [blame] | 507 | nss alsa-lib glib2 gtk3 nspr freetype2 cairo dbus xorg-server-xvfb \ |
| 508 | xorg-xdpyinfo |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 509 | ``` |
| 510 | |
| 511 | For the optional packages on Arch Linux: |
| 512 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 513 | * `php-cgi` is provided with `pacman` |
| 514 | * `wdiff` is not in the main repository but `dwdiff` is. You can get `wdiff` |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 515 | in AUR/`yaourt` |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 516 | |
Kenneth Russell | 5629377 | 2018-09-21 01:46:15 | [diff] [blame] | 517 | ### Crostini (Debian based) |
| 518 | |
David Munro | 9b5f4c4f | 2019-07-24 08:23:27 | [diff] [blame] | 519 | 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] | 520 | |
| 521 | ```shell |
David Munro | 9b5f4c4f | 2019-07-24 08:23:27 | [diff] [blame] | 522 | $ sudo apt-get install file lsb-release |
Kenneth Russell | 5629377 | 2018-09-21 01:46:15 | [diff] [blame] | 523 | ``` |
| 524 | |
| 525 | Then invoke install-build-deps.sh with the `--no-arm` argument, |
| 526 | because the ARM toolchain doesn't exist for this configuration: |
| 527 | |
| 528 | ```shell |
| 529 | $ sudo install-build-deps.sh --no-arm |
| 530 | ``` |
| 531 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 532 | ### Fedora |
| 533 | |
| 534 | Instead of running `build/install-build-deps.sh`, run: |
| 535 | |
| 536 | ```shell |
| 537 | su -c 'yum install git python bzip2 tar pkgconfig atk-devel alsa-lib-devel \ |
| 538 | bison binutils brlapi-devel bluez-libs-devel bzip2-devel cairo-devel \ |
| 539 | cups-devel dbus-devel dbus-glib-devel expat-devel fontconfig-devel \ |
Tom Anderson | 287339e | 2018-08-22 21:52:02 | [diff] [blame] | 540 | freetype-devel gcc-c++ glib2-devel glibc.i686 gperf glib2-devel \ |
Tim Brown | 36312fc | 2017-12-15 22:56:20 | [diff] [blame] | 541 | gtk3-devel java-1.*.0-openjdk-devel libatomic libcap-devel libffi-devel \ |
Tom Anderson | 761687a | 2023-06-14 17:27:39 | [diff] [blame] | 542 | libgcc.i686 libjpeg-devel libstdc++.i686 libX11-devel libXScrnSaver-devel \ |
| 543 | libXtst-devel libxkbcommon-x11-devel ncurses-compat-libs nspr-devel nss-devel \ |
| 544 | pam-devel pango-devel pciutils-devel pulseaudio-libs-devel zlib.i686 httpd \ |
| 545 | mod_ssl php php-cli python-psutil wdiff xorg-x11-server-Xvfb' |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 546 | ``` |
| 547 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 548 | 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] | 549 | instructions](https://gist.github.com/pwnall/32a3b11c2b10f6ae5c6a6de66c1e12ae). |
| 550 | For the optional packages: |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 551 | |
| 552 | * `php-cgi` is provided by the `php-cli` package. |
Victor Costan | 44af72b | 2017-11-13 20:01:30 | [diff] [blame] | 553 | * `sun-java6-fonts` is covered by the instructions linked above. |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 554 | |
| 555 | ### Gentoo |
| 556 | |
| 557 | You can just run `emerge www-client/chromium`. |
| 558 | |
Delan Azabani | 43eefa3d | 2024-05-09 03:39:33 | [diff] [blame] | 559 | ### NixOS |
| 560 | |
| 561 | To get a shell with the dev environment: |
| 562 | |
| 563 | ```sh |
| 564 | $ nix-shell tools/nix/shell.nix |
| 565 | ``` |
| 566 | |
| 567 | To run a command in the dev environment: |
| 568 | |
| 569 | ```sh |
| 570 | $ NIX_SHELL_RUN='autoninja -C out/Default chrome' nix-shell tools/nix/shell.nix |
| 571 | ``` |
| 572 | |
| 573 | To set up clangd with remote indexing support, run the command below, then copy |
| 574 | the path into your editor config: |
| 575 | |
| 576 | ```sh |
| 577 | $ NIX_SHELL_RUN='readlink /usr/bin/clangd' nix-shell tools/nix/shell.nix |
| 578 | ``` |
| 579 | |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 580 | ### OpenSUSE |
| 581 | |
| 582 | Use `zypper` command to install dependencies: |
| 583 | |
| 584 | (openSUSE 11.1 and higher) |
| 585 | |
| 586 | ```shell |
Tim Brown | 36312fc | 2017-12-15 22:56:20 | [diff] [blame] | 587 | sudo zypper in subversion pkg-config python perl bison flex gperf \ |
| 588 | mozilla-nss-devel glib2-devel gtk-devel wdiff lighttpd gcc gcc-c++ \ |
| 589 | mozilla-nspr mozilla-nspr-devel php5-fastcgi alsa-devel libexpat-devel \ |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 590 | libjpeg-devel libbz2-devel |
| 591 | ``` |
| 592 | |
| 593 | 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] | 594 | `mozilla-nspr-devel`, and use `php5-cgi` instead of `php5-fastcgi`. |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 595 | |
| 596 | (openSUSE 11.0) |
| 597 | |
| 598 | ```shell |
| 599 | sudo zypper in subversion pkg-config python perl \ |
| 600 | bison flex gperf mozilla-nss-devel glib2-devel gtk-devel \ |
| 601 | libnspr4-0d libnspr4-dev wdiff lighttpd gcc gcc-c++ libexpat-devel \ |
Tom Anderson | 287339e | 2018-08-22 21:52:02 | [diff] [blame] | 602 | php5-cgi alsa-devel gtk3-devel jpeg-devel |
dpranke | 2989a78 | 2016-12-02 02:57:12 | [diff] [blame] | 603 | ``` |
| 604 | |
| 605 | The Ubuntu package `sun-java6-fonts` contains a subset of Java of the fonts used. |
| 606 | Since this package requires Java as a prerequisite anyway, we can do the same |
| 607 | thing by just installing the equivalent openSUSE Sun Java package: |
| 608 | |
| 609 | ```shell |
| 610 | sudo zypper in java-1_6_0-sun |
| 611 | ``` |
| 612 | |
| 613 | WebKit is currently hard-linked to the Microsoft fonts. To install these using `zypper` |
| 614 | |
| 615 | ```shell |
| 616 | sudo zypper in fetchmsttfonts pullin-msttf-fonts |
| 617 | ``` |
| 618 | |
| 619 | To make the fonts installed above work, as the paths are hardcoded for Ubuntu, |
| 620 | create symlinks to the appropriate locations: |
| 621 | |
| 622 | ```shell |
| 623 | sudo mkdir -p /usr/share/fonts/truetype/msttcorefonts |
| 624 | sudo ln -s /usr/share/fonts/truetype/arial.ttf /usr/share/fonts/truetype/msttcorefonts/Arial.ttf |
| 625 | sudo ln -s /usr/share/fonts/truetype/arialbd.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf |
| 626 | sudo ln -s /usr/share/fonts/truetype/arialbi.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf |
| 627 | sudo ln -s /usr/share/fonts/truetype/ariali.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf |
| 628 | sudo ln -s /usr/share/fonts/truetype/comic.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf |
| 629 | sudo ln -s /usr/share/fonts/truetype/comicbd.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf |
| 630 | sudo ln -s /usr/share/fonts/truetype/cour.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf |
| 631 | sudo ln -s /usr/share/fonts/truetype/courbd.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf |
| 632 | sudo ln -s /usr/share/fonts/truetype/courbi.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf |
| 633 | sudo ln -s /usr/share/fonts/truetype/couri.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf |
| 634 | sudo ln -s /usr/share/fonts/truetype/impact.ttf /usr/share/fonts/truetype/msttcorefonts/Impact.ttf |
| 635 | sudo ln -s /usr/share/fonts/truetype/times.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf |
| 636 | sudo ln -s /usr/share/fonts/truetype/timesbd.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf |
| 637 | sudo ln -s /usr/share/fonts/truetype/timesbi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttf |
| 638 | sudo ln -s /usr/share/fonts/truetype/timesi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttf |
| 639 | sudo ln -s /usr/share/fonts/truetype/verdana.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana.ttf |
| 640 | sudo ln -s /usr/share/fonts/truetype/verdanab.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf |
| 641 | sudo ln -s /usr/share/fonts/truetype/verdanai.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttf |
| 642 | sudo ln -s /usr/share/fonts/truetype/verdanaz.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf |
| 643 | ``` |
| 644 | |
| 645 | The Ubuntu package `sun-java6-fonts` contains a subset of Java of the fonts used. |
| 646 | Since this package requires Java as a prerequisite anyway, we can do the same |
| 647 | thing by just installing the equivalent openSUSE Sun Java package: |
| 648 | |
| 649 | ```shell |
| 650 | sudo zypper in java-1_6_0-sun |
| 651 | ``` |
| 652 | |
| 653 | WebKit is currently hard-linked to the Microsoft fonts. To install these using `zypper` |
| 654 | |
| 655 | ```shell |
| 656 | sudo zypper in fetchmsttfonts pullin-msttf-fonts |
| 657 | ``` |
| 658 | |
| 659 | To make the fonts installed above work, as the paths are hardcoded for Ubuntu, |
| 660 | create symlinks to the appropriate locations: |
| 661 | |
| 662 | ```shell |
| 663 | sudo mkdir -p /usr/share/fonts/truetype/msttcorefonts |
| 664 | sudo ln -s /usr/share/fonts/truetype/arial.ttf /usr/share/fonts/truetype/msttcorefonts/Arial.ttf |
| 665 | sudo ln -s /usr/share/fonts/truetype/arialbd.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf |
| 666 | sudo ln -s /usr/share/fonts/truetype/arialbi.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf |
| 667 | sudo ln -s /usr/share/fonts/truetype/ariali.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf |
| 668 | sudo ln -s /usr/share/fonts/truetype/comic.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf |
| 669 | sudo ln -s /usr/share/fonts/truetype/comicbd.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf |
| 670 | sudo ln -s /usr/share/fonts/truetype/cour.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf |
| 671 | sudo ln -s /usr/share/fonts/truetype/courbd.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf |
| 672 | sudo ln -s /usr/share/fonts/truetype/courbi.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf |
| 673 | sudo ln -s /usr/share/fonts/truetype/couri.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf |
| 674 | sudo ln -s /usr/share/fonts/truetype/impact.ttf /usr/share/fonts/truetype/msttcorefonts/Impact.ttf |
| 675 | sudo ln -s /usr/share/fonts/truetype/times.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf |
| 676 | sudo ln -s /usr/share/fonts/truetype/timesbd.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf |
| 677 | sudo ln -s /usr/share/fonts/truetype/timesbi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttf |
| 678 | sudo ln -s /usr/share/fonts/truetype/timesi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttf |
| 679 | sudo ln -s /usr/share/fonts/truetype/verdana.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana.ttf |
| 680 | sudo ln -s /usr/share/fonts/truetype/verdanab.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf |
| 681 | sudo ln -s /usr/share/fonts/truetype/verdanai.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttf |
| 682 | sudo ln -s /usr/share/fonts/truetype/verdanaz.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf |
| 683 | ``` |
| 684 | |
| 685 | And then for the Java fonts: |
| 686 | |
| 687 | ```shell |
| 688 | sudo mkdir -p /usr/share/fonts/truetype/ttf-lucida |
| 689 | sudo find /usr/lib*/jvm/java-1.6.*-sun-*/jre/lib -iname '*.ttf' -print \ |
| 690 | -exec ln -s {} /usr/share/fonts/truetype/ttf-lucida \; |
| 691 | ``` |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 692 | |
| 693 | ### Docker |
| 694 | |
| 695 | #### Prerequisites |
| 696 | |
| 697 | While it is not a common setup, Chromium compilation should work from within a |
| 698 | Docker container. If you choose to compile from within a container for whatever |
| 699 | reason, you will need to make sure that the following tools are available: |
| 700 | |
| 701 | * `curl` |
| 702 | * `git` |
| 703 | * `lsb_release` |
| 704 | * `python3` |
| 705 | * `sudo` |
| 706 | * `file` |
| 707 | |
| 708 | There may be additional Docker-specific issues during compilation. See |
| 709 | [this bug](https://crbug.com/1377520) for additional details on this. |
| 710 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 711 | Note: [Clone depot_tools](#install-depot_tools) first. |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 712 | |
| 713 | #### Build Steps |
| 714 | |
| 715 | 1. Put the following Dockerfile in `/path/to/chromium/`. |
| 716 | |
| 717 | ```docker |
| 718 | # Use an official Ubuntu base image with Docker already installed |
| 719 | FROM ubuntu:22.04 |
| 720 | |
| 721 | # Set environment variables |
| 722 | ENV DEBIAN_FRONTEND=noninteractive |
| 723 | |
| 724 | # Install Mantatory tools (curl git python3) and optional tools (vim sudo) |
| 725 | RUN apt-get update && \ |
| 726 | apt-get install -y curl git lsb-release python3 git file vim sudo && \ |
| 727 | rm -rf /var/lib/apt/lists/* |
| 728 | |
| 729 | # Export depot_tools path |
| 730 | ENV PATH="/depot_tools:${PATH}" |
| 731 | |
| 732 | # Configure git for safe.directory |
Ho Cheung | 7c53eaf | 2024-05-31 00:31:26 | [diff] [blame] | 733 | RUN git config --global --add safe.directory /depot_tools && \ |
| 734 | git config --global --add safe.directory /chromium/src |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 735 | |
Ho Cheung | 7c53eaf | 2024-05-31 00:31:26 | [diff] [blame] | 736 | # Set the working directory to the existing Chromium source directory. |
| 737 | # This can be either "/chromium/src" or "/chromium". |
| 738 | WORKDIR /chromium/src |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 739 | |
| 740 | # Expose any necessary ports (if needed) |
| 741 | # EXPOSE 8080 |
mohamedhany01 | 5ae3480 | 2024-10-16 16:34:41 | [diff] [blame] | 742 | |
| 743 | # Create a dummy user and group to avoid permission issues |
| 744 | RUN groupadd -g 1001 chrom-d && \ |
| 745 | useradd -u 1000 -g 1001 -m chrom-d |
Ho Cheung | 7c53eaf | 2024-05-31 00:31:26 | [diff] [blame] | 746 | |
| 747 | # Create normal user with name "chrom-d". Optional and you can use root but |
| 748 | # not advised. |
| 749 | USER chrom-d |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 750 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 751 | # Start Chromium Builder "chrom-d" (modify this command as needed) |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 752 | # CMD ["autoninja -C out/Default chrome"] |
| 753 | CMD ["bash"] |
| 754 | ``` |
| 755 | |
| 756 | 2. Build Container |
| 757 | |
| 758 | ```shell |
| 759 | # chrom-b is just a name; You can change it but you must reflect the renaming |
| 760 | # in all commands below |
| 761 | $ docker build -t chrom-b . |
| 762 | ``` |
| 763 | |
| 764 | 3. Run container as root to install dependencies |
| 765 | |
| 766 | ```shell |
mohamedhany01 | 5ae3480 | 2024-10-16 16:34:41 | [diff] [blame] | 767 | $ docker run |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 768 | -it \ # Run docker interactively |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 769 | --name chrom-b \ # with name "chrom-b" |
| 770 | -u root \ # with user root |
| 771 | -v /path/on/machine/to/chromium:/chromium \ # With chromium folder mounted |
| 772 | -v /path/on/machine/to/depot_tools:/depot_tools \ # With depot_tools mounted |
| 773 | chrom-b # Run container with image name "chrom-b" |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 774 | ``` |
| 775 | |
mohamedhany01 | 5ae3480 | 2024-10-16 16:34:41 | [diff] [blame] | 776 | *** note |
| 777 | **Note:** When running the command as a single line in bash, please remove the |
| 778 | comments (after the `#`) to avoid breaking the command. |
| 779 | *** |
| 780 | |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 781 | 4. Install dependencies: |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 782 | |
| 783 | ```shell |
Ho Cheung | 7c53eaf | 2024-05-31 00:31:26 | [diff] [blame] | 784 | ./build/install-build-deps.sh |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 785 | ``` |
| 786 | |
Ho Cheung | 7c53eaf | 2024-05-31 00:31:26 | [diff] [blame] | 787 | 5. [Run hooks](#run-the-hooks) (On docker or machine if you installed depot_tools on machine) |
| 788 | |
mohamedhany01 | 5ae3480 | 2024-10-16 16:34:41 | [diff] [blame] | 789 | *** note |
| 790 | **Before running hooks:** Ensure that all directories within |
| 791 | `third_party` are added as safe directories in Git. This is required |
| 792 | when running in the container because the ownership of the `src/` |
| 793 | directory (e.g., `chrom-b`) differs from the current user |
| 794 | (e.g., `root`). To prevent Git **warnings** about "dubious ownership" |
| 795 | run the following command after installing the dependencies: |
| 796 | |
| 797 | ```shell |
| 798 | # Loop through each directory in /chromium/src/third_party and add |
| 799 | # them as safe directories in Git |
| 800 | $ for dir in /chromium/src/third_party/*; do |
| 801 | if [ -d "$dir" ]; then |
| 802 | git config --global --add safe.directory "$dir" |
| 803 | fi |
| 804 | done |
| 805 | ``` |
| 806 | *** |
| 807 | |
Ho Cheung | 7c53eaf | 2024-05-31 00:31:26 | [diff] [blame] | 808 | 6. Exit container |
| 809 | |
| 810 | 7. Save container image with tag-id name `dpv1.0`. Run this on the machine, not in container |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 811 | |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 812 | ```shell |
mohamedhany01 | 5ae3480 | 2024-10-16 16:34:41 | [diff] [blame] | 813 | # Get docker running/stopped containers, copy the "chrom-b" id |
| 814 | $ docker container ls -a |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 815 | # Save/tag running docker container with name "chrom-b" with "dpv1.0" |
| 816 | # You can choose any tag name you want but propagate name accordingly |
| 817 | # You will need to create new tags when working on different parts of |
| 818 | # chromium which requires installing additional dependencies |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 819 | $ docker commit <ID from above step> chrom-b:dpv1.0 |
| 820 | # Optional, just saves space by deleting unnecessary images |
| 821 | $ docker image rmi chrom-b:latest && docker image prune \ |
| 822 | && docker container prune && docker builder prune |
| 823 | ``` |
| 824 | |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 825 | #### Run container |
| 826 | |
| 827 | ```shell |
| 828 | $ docker run --rm \ # close instance upon exit |
| 829 | -it \ # Run docker interactively |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 830 | --name chrom-b \ # with name "chrom-b" |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 831 | -u $(id -u):$(id -g) \ # Run container as a non-root user with same UID & GID |
Omar Shawky | 971848ce | 2024-04-17 21:47:30 | [diff] [blame] | 832 | -v /path/on/machine/to/chromium:/chromium \ # With chromium folder mounted |
| 833 | -v /path/on/machine/to/depot_tools:/depot_tools \ # With depot_tools mounted |
| 834 | chrom-b:dpv1.0 # Run container with image name "chrom-b" and tag dpv1.0 |
Omar Shawky | 08b259c | 2024-03-27 19:52:17 | [diff] [blame] | 835 | ``` |
mohamedhany01 | 5ae3480 | 2024-10-16 16:34:41 | [diff] [blame] | 836 | |
| 837 | *** note |
| 838 | **Note:** When running the command as a single line in bash, please remove the |
| 839 | comments (after the `#`) to avoid breaking the command. |
| 840 | *** |