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