dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 1 | # Checking out and Building Chromium for Windows |
| 2 | |
Bruce Dawson | 4d1de59 | 2017-09-08 00:24:00 | [diff] [blame] | 3 | There are instructions for other platforms linked from the |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 4 | [get the code](get_the_code.md) page. |
tfarina | 502f388 | 2016-03-23 12:48:10 | [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 |
scottmg | 292538ae | 2017-01-12 00:10:55 | [diff] [blame] | 9 | [go/building-chrome-win](https://goto.google.com/building-chrome-win) instead. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 10 | |
| 11 | [TOC] |
| 12 | |
| 13 | ## System requirements |
| 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 |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 16 | recommended. |
dpranke | 4b470c5b | 2017-01-19 17:38:04 | [diff] [blame] | 17 | * At least 100GB of free disk space on an NTFS-formatted hard drive. FAT32 |
| 18 | will not work, as some of the Git packfiles are larger than 4GB. |
Bruce Dawson | 97367b7 | 2017-10-18 00:47:49 | [diff] [blame] | 19 | * An appropriate version of Visual Studio, as described below. |
Bruce Dawson | 52c749c | 2020-12-03 16:44:26 | [diff] [blame] | 20 | * Windows 10 or newer. |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 21 | |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 22 | ## Setting up Windows |
| 23 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 24 | ### Visual Studio |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 25 | |
Bruce Dawson | d95ceb6 | 2023-02-17 01:39:30 | [diff] [blame] | 26 | Chromium requires [Visual Studio 2022](https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-notes) (>=17.0.0) |
| 27 | to build. Visual Studio can also be used to debug Chromium. |
Raul Tambre | 1bb5c1a | 2018-12-29 00:57:12 | [diff] [blame] | 28 | The clang-cl compiler is used but Visual Studio's header files, libraries, and |
| 29 | some tools are required. Visual Studio Community Edition should work if its |
| 30 | license is appropriate for you. You must install the "Desktop development with |
| 31 | C++" component and the "MFC/ATL support" sub-components. This can be done from |
| 32 | the command line by passing these arguments to the Visual Studio installer (see |
| 33 | below for ARM64 instructions): |
Bruce Dawson | 1c0979a6 | 2017-09-13 17:47:21 | [diff] [blame] | 34 | ```shell |
Bruce Dawson | e42d764 | 2018-12-10 23:50:00 | [diff] [blame] | 35 | $ PATH_TO_INSTALLER.EXE ^ |
| 36 | --add Microsoft.VisualStudio.Workload.NativeDesktop ^ |
| 37 | --add Microsoft.VisualStudio.Component.VC.ATLMFC ^ |
| 38 | --includeRecommended |
Bruce Dawson | 1c0979a6 | 2017-09-13 17:47:21 | [diff] [blame] | 39 | ``` |
pwnall | 43b43ba | 2016-08-22 19:29:29 | [diff] [blame] | 40 | |
Bruce Dawson | e42d764 | 2018-12-10 23:50:00 | [diff] [blame] | 41 | If you want to build for ARM64 Win32 then some extra arguments are needed. The |
| 42 | full set for that case is: |
| 43 | ```shell |
| 44 | $ PATH_TO_INSTALLER.EXE ^ |
| 45 | --add Microsoft.VisualStudio.Workload.NativeDesktop ^ |
| 46 | --add Microsoft.VisualStudio.Component.VC.ATLMFC ^ |
| 47 | --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ^ |
| 48 | --add Microsoft.VisualStudio.Component.VC.MFC.ARM64 ^ |
| 49 | --includeRecommended |
| 50 | ``` |
| 51 | |
Solomon Kinard | 4542707 | 2023-06-22 18:21:01 | [diff] [blame] | 52 | Required |
Bruce Dawson | e9f20fff | 2018-03-03 01:58:38 | [diff] [blame] | 53 | |
Solomon Kinard | 4542707 | 2023-06-22 18:21:01 | [diff] [blame] | 54 | * [Windows 11 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) |
Devon Loehr | 0f6eaa5 | 2024-10-16 16:22:01 | [diff] [blame^] | 55 | version 10.0.26100.1742. This can be installed separately or by checking the |
Solomon Kinard | 4542707 | 2023-06-22 18:21:01 | [diff] [blame] | 56 | appropriate box in the Visual Studio Installer. |
Devon Loehr | 0f6eaa5 | 2024-10-16 16:22:01 | [diff] [blame^] | 57 | * (Windows 11) SDK Debugging Tools 10.0.26100.1742 or higher. This version of the |
Bruce Dawson | 7ff6e7d | 2024-03-15 22:31:20 | [diff] [blame] | 58 | Debugging tools is needed in order to support reading the large-page PDBs that |
| 59 | Chrome uses to allow greater-than 4 GiB PDBs. This can be installed after the |
| 60 | matching Windows SDK version is installed, from: Control Panel -> Programs and |
| 61 | Features |
Solomon Kinard | 4542707 | 2023-06-22 18:21:01 | [diff] [blame] | 62 | -> Windows Software Development Kit [version] -> Change -> Debugging Tools for |
Bruce Dawson | 9588daa | 2023-10-18 22:07:25 | [diff] [blame] | 63 | Windows. If building on ARM64 Windows then you will need to manually copy the |
| 64 | Debuggers\x64 directory from another machine because it does not get installed |
| 65 | on ARM64 and is needed, whether you are building Chromium for x64 or ARM64 on |
| 66 | ARM64. |
Robert Sesek | c8ffa1b | 2017-08-04 19:55:22 | [diff] [blame] | 67 | |
Devon Loehr | 0f6eaa5 | 2024-10-16 16:22:01 | [diff] [blame^] | 68 | WARNING: On sufficiently old versions of Windows (1909 or earlier), dawn (or related |
| 69 | components) may fail with a D3d-related error when using the 26100 SDK. This is because the |
| 70 | d3dcompiler_47.dll file in the new SDK attempts to dynamically link versions of the Universal |
| 71 | C Runtime which are not present by default on older systems. If you experience these errors, |
| 72 | you can either update the UCRT on your system, or install the 22612 SDK and use the |
| 73 | d3dcompiler_47.dll file included there, which statically links the UCRT. |
| 74 | |
Anne Redulla | 7b37005 | 2024-09-09 00:39:35 | [diff] [blame] | 75 | ## git installation |
| 76 | |
| 77 | ### Install git |
| 78 | |
| 79 | If you haven't installed `git` directly before, you can download a standalone |
| 80 | installer for the latest version of Git For Windows from the Git website at |
| 81 | https://git-scm.com/download/win. |
| 82 | |
| 83 | For more information on Git for Windows (which is a separate project from Git), |
| 84 | see https://gitforwindows.org. |
| 85 | |
Fumitoshi Ukai | 9284cff4 | 2024-09-11 01:59:29 | [diff] [blame] | 86 | Note: if you are a Google employee, see [go/building-chrome-win#install-git](https://goto.google.com/building-chrome-win#install-git). |
Anne Redulla | 7b37005 | 2024-09-09 00:39:35 | [diff] [blame] | 87 | |
| 88 | ### Update git |
| 89 | |
| 90 | Note: this section is about updating a direct installation of `git` because |
| 91 | `depot_tools` will soon stop bundling `git`. |
| 92 | |
| 93 | If you have already set up `depot_tools` and would like to update an existing |
| 94 | directly-installed `git`, you must first |
| 95 | [modify your PATH](#modify-path-for-git) to prefer the non-`depot_tools` `git`. |
| 96 | |
| 97 | Updating to the latest version of `git` will depend on which version you |
| 98 | currently have installed. First, check your `git` version. From a cmd.exe shell, |
| 99 | run: |
| 100 | ```shell |
| 101 | $ git version |
| 102 | ``` |
| 103 | |
| 104 | | Current version | How to update to latest | |
| 105 | | --- | --- | |
| 106 | | `2.14.1` or earlier | You will need to manually uninstall Git, then follow the instructions above to [install git](#install-git) | |
| 107 | | `2.14.2` to `2.16.1` | In a cmd.exe shell, run: `git update` | |
| 108 | | `2.16.1(2)` and later | In a cmd.exe shell, run: `git update-git-for-windows` | |
| 109 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 110 | ## Install `depot_tools` |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 111 | |
Anne Redulla | 7b37005 | 2024-09-09 00:39:35 | [diff] [blame] | 112 | *** |
| 113 | **Warning:** `depot_tools` will stop bundling Git for Windows from Sep 23, 2024 |
| 114 | onwards. To prepare for this change, Windows users should |
| 115 | [install Git](#git-installation) directly before then. |
| 116 | *** |
| 117 | |
Solomon Kinard | 4542707 | 2023-06-22 18:21:01 | [diff] [blame] | 118 | Download the |
| 119 | [depot_tools bundle](https://storage.googleapis.com/chrome-infra/depot_tools.zip) |
Eric Waldman | c469ba7b | 2022-03-02 20:33:00 | [diff] [blame] | 120 | and extract it somewhere (eg: C:\src\depot_tools). |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 121 | |
Solomon Kinard | 4542707 | 2023-06-22 18:21:01 | [diff] [blame] | 122 | *** |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 123 | **Warning:** **DO NOT** use drag-n-drop or copy-n-paste extract from Explorer, |
| 124 | this will not extract the hidden “.git” folder which is necessary for |
Bruce Dawson | 4d1de59 | 2017-09-08 00:24:00 | [diff] [blame] | 125 | depot_tools to autoupdate itself. You can use “Extract all…” from the |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 126 | context menu though. |
| 127 | *** |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 128 | |
Bruce Dawson | 4d1de59 | 2017-09-08 00:24:00 | [diff] [blame] | 129 | Add depot_tools to the start of your PATH (must be ahead of any installs of |
Eric Waldman | c469ba7b | 2022-03-02 20:33:00 | [diff] [blame] | 130 | Python. Note that environment variable names are case insensitive). |
Anne Redulla | 7b37005 | 2024-09-09 00:39:35 | [diff] [blame] | 131 | * Assuming you unzipped the bundle to `C:\src\depot_tools`, open: |
| 132 | Control Panel → System and Security → System |
| 133 | * Select which PATH variable to edit. |
| 134 | * If you have Administrator access, you can edit the **system** PATH. Click |
| 135 | Advanced system settings → Environment Variables. Under "System variables", |
| 136 | select the Path variable for editing. |
| 137 | * If you don't have Administrator access, you can edit your **user-level** |
| 138 | PATH. Search for "Edit environment variables for your account". Under "User |
| 139 | variables for %USER%", select the Path variable for editing. |
| 140 | * Modify the Path variable by adding `C:\src\depot_tools` at the front (or at |
| 141 | least in front of any directory that might already have a copy of Python). |
| 142 | Note: If you can only modify your user-level PATH and the system PATH has a |
| 143 | Python in it, you will be out of luck. |
| 144 | |
| 145 | *** |
| 146 | ### Modify PATH for git |
| 147 | **Optional:** You can modify your PATH to prefer using an independently installed |
| 148 | `git` over the version currently bundled with `depot_tools`. If you are happy to |
| 149 | keep using the bundled `git` within `depot_tools` until it is removed, you can |
| 150 | skip this step. |
| 151 | |
| 152 | * Assuming you installed Git at `C:\Program Files\Git`, edit your system or |
| 153 | user-level PATH in the same way when `C:\src\depot_tools` was added. |
| 154 | Modify the Path variable by adding the following *before* |
| 155 | `C:\src\depot_tools`: |
| 156 | * `C:\Program Files\Git\cmd` |
| 157 | * `C:\Program Files\Git\mingw64\bin` |
| 158 | * `C:\Program Files\Git\usr\bin` |
| 159 | *** |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 160 | |
Wan-Teh Chang | 0391287 | 2022-03-14 23:07:34 | [diff] [blame] | 161 | Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN environment variable in the same way, and set |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 162 | it to 0. This tells depot_tools to use your locally installed version of Visual |
Aaron Gable | dad9e0f | 2020-01-09 19:38:52 | [diff] [blame] | 163 | Studio (by default, depot_tools will try to use a google-internal version). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 164 | |
Bruce Dawson | d95ceb6 | 2023-02-17 01:39:30 | [diff] [blame] | 165 | You may also have to set variable `vs2022_install` to your installation path of |
| 166 | Visual Studio 2022, like |
| 167 | `set vs2022_install=C:\Program Files\Microsoft Visual Studio\2022\Professional`. |
Andreas Papacharalampous | 1d22c961 | 2020-06-13 23:11:17 | [diff] [blame] | 168 | |
Reilly Grant | 07ff22e | 2021-10-19 19:21:20 | [diff] [blame] | 169 | From a cmd.exe shell, run: |
Reilly Grant | 07ff22e | 2021-10-19 19:21:20 | [diff] [blame] | 170 | ```shell |
| 171 | $ gclient |
| 172 | ``` |
| 173 | |
| 174 | On first run, gclient will install all the Windows-specific bits needed to work |
| 175 | with the code, including msysgit and python. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 176 | |
| 177 | * If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell), |
| 178 | it may appear to run properly, but msysgit, python, and other tools |
| 179 | may not get installed correctly. |
| 180 | * If you see strange errors with the file system on the first run of gclient, |
Yuma Takai | d4809d55 | 2022-02-15 03:48:19 | [diff] [blame] | 181 | you may want to [disable Windows Indexing](https://tortoisesvn.net/faq.html#cantmove2). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 182 | |
Will Harris | 1c8f89c | 2021-03-08 22:53:43 | [diff] [blame] | 183 | ## Check python install |
| 184 | |
henrika | b232d89 | 2024-04-05 14:53:31 | [diff] [blame] | 185 | After running gclient open a command prompt and type `where python3` and |
| 186 | confirm that the depot_tools `python3.bat` comes ahead of any copies of |
| 187 | python3.exe. Failing to ensure this can lead to overbuilding when |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 188 | using gn - see [crbug.com/611087](https://crbug.com/611087). |
| 189 | |
Will Harris | 1c8f89c | 2021-03-08 22:53:43 | [diff] [blame] | 190 | [App Execution Aliases](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-extensions#alias) |
| 191 | can conflict with other installations of python on the system so disable |
| 192 | these for 'python.exe' and 'python3.exe' by opening 'App execution aliases' |
| 193 | section of Control Panel and unticking the boxes next to both of these |
| 194 | that point to 'App Installer'. |
| 195 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 196 | ## Get the code |
| 197 | |
Leonard Mosescu | 718c9ac | 2017-06-20 18:06:32 | [diff] [blame] | 198 | First, configure Git: |
| 199 | |
| 200 | ```shell |
| 201 | $ git config --global user.name "My Name" |
| 202 | $ git config --global user.email "[email protected]" |
| 203 | $ git config --global core.autocrlf false |
| 204 | $ git config --global core.filemode false |
| 205 | $ git config --global branch.autosetuprebase always |
| 206 | ``` |
| 207 | |
Bruce Dawson | c2c02e5 | 2023-11-22 04:43:15 | [diff] [blame] | 208 | While not necessarily required it can be helpful to configure git to allow long |
| 209 | path support (beyond the Windows MAX_PATH limit): |
| 210 | |
| 211 | ```shell |
| 212 | git config --global core.longpaths true |
| 213 | ``` |
| 214 | |
Sonja Laurila | c894937 | 2023-06-27 10:09:23 | [diff] [blame] | 215 | Create a `chromium` directory for the checkout and change to it. You can call |
| 216 | this whatever you like and put it wherever you like, as long as the full path |
| 217 | has no spaces. However there are some performance benefits for Googlers in |
| 218 | placing the directory under `C:\src\` |
| 219 | (See [Why is my build slow?](https://chromium.googlesource.com/chromium/src/+/main/docs/windows_build_instructions.md#why-is-my-build-slow)). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 220 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 221 | ```shell |
| 222 | $ mkdir chromium && cd chromium |
| 223 | ``` |
| 224 | |
| 225 | Run the `fetch` tool from `depot_tools` to check out the code and its |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 226 | dependencies. |
| 227 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 228 | ```shell |
xiaoyin.l | 802e4b3e | 2016-12-04 22:17:30 | [diff] [blame] | 229 | $ fetch chromium |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 230 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 231 | |
| 232 | 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] | 233 | adding the `--no-history` flag to `fetch`. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 234 | |
Bruce Dawson | 2c83223e | 2022-10-25 21:08:22 | [diff] [blame] | 235 | Expect the command to take over an hour on even a fast connection, and many |
| 236 | hours on slower ones. You should configure your PC so that it doesn't sleep |
| 237 | or hibernate during the fetch or else errors may occur. If errors occur while |
| 238 | fetching sub-repos then you can start over, or you may be able to correct them |
| 239 | by going to the chromium/src directory and running this command: |
| 240 | |
| 241 | ```shell |
| 242 | $ gclient sync |
| 243 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 244 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 245 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
| 246 | directory called `src` in the working directory. The remaining instructions |
| 247 | assume you have switched to the `src` directory: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 248 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 249 | ```shell |
| 250 | $ cd src |
| 251 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 252 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 253 | *Optional*: You can also [install API |
| 254 | keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your |
| 255 | build to talk to some Google services, but this is not necessary for most |
| 256 | development and testing purposes. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 257 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 258 | ## Setting up the build |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 259 | |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 260 | 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] | 261 | 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] | 262 | to generate `.ninja` files. You can create any number of *build directories* |
| 263 | with different configurations. To create a build directory: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 264 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 265 | ```shell |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 266 | $ gn gen out\Default |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 267 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 268 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 269 | * You only have to run this once for each new build directory, Ninja will |
| 270 | update the build files as needed. |
| 271 | * You can replace `Default` with another name, but |
| 272 | it should be a subdirectory of `out`. |
Aaron Gable | dad9e0f | 2020-01-09 19:38:52 | [diff] [blame] | 273 | * For other build arguments, including release settings or using an alternate |
| 274 | version of Visual Studio, see [GN build |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 275 | configuration](https://www.chromium.org/developers/gn-build-configuration). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 276 | The default will be a debug component build matching the current host |
| 277 | operating system and CPU. |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 278 | * For more info on GN, run `gn help` on the command line or read the [quick |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 279 | start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md). |
Juan Cruz Viotti | 9c7622d | 2021-06-30 00:27:23 | [diff] [blame] | 280 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 281 | ### Faster builds |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 282 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 283 | * Reduce file system overhead by excluding build directories from |
| 284 | antivirus and indexing software. |
| 285 | * Store the build tree on a fast disk (preferably SSD). |
brucedawson | cfc7fd5 | 2017-07-06 18:41:01 | [diff] [blame] | 286 | * The more cores the better (20+ is not excessive) and lots of RAM is needed |
| 287 | (64 GB is not excessive). |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 288 | |
brucedawson | cfc7fd5 | 2017-07-06 18:41:01 | [diff] [blame] | 289 | There are some gn flags that can improve build speeds. You can specify these |
| 290 | in the editor that appears when you create your output directory |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 291 | (`gn args out\Default`) or on the gn gen command line |
| 292 | (`gn gen out\Default --args="is_component_build = true is_debug = true"`). |
brucedawson | cfc7fd5 | 2017-07-06 18:41:01 | [diff] [blame] | 293 | Some helpful settings to consider using include: |
Bruce Dawson | 2c83223e | 2022-10-25 21:08:22 | [diff] [blame] | 294 | * `is_component_build = true` - this uses more, smaller DLLs, and may avoid |
| 295 | having to relink chrome.dll after every change. |
Bruce Dawson | fcd3deb1 | 2017-07-28 17:12:20 | [diff] [blame] | 296 | * `enable_nacl = false` - this disables Native Client which is usually not |
| 297 | needed for local builds. |
Bruce Dawson | 2c83223e | 2022-10-25 21:08:22 | [diff] [blame] | 298 | * `target_cpu = "x86"` - x86 builds may be slightly faster than x64 builds. Note |
| 299 | that if you set this but don't set `enable_nacl = false` then build times may |
| 300 | get worse. |
James Cook | 26699a9 | 2019-03-12 22:23:10 | [diff] [blame] | 301 | * `blink_symbol_level = 0` - turn off source-level debugging for |
brucedawson | cfc7fd5 | 2017-07-06 18:41:01 | [diff] [blame] | 302 | blink to reduce build times, appropriate if you don't plan to debug blink. |
Bruce Dawson | 63e0be7 | 2021-11-29 20:34:41 | [diff] [blame] | 303 | * `v8_symbol_level = 0` - turn off source-level debugging for v8 to reduce |
| 304 | build times, appropriate if you don't plan to debug v8. |
brucedawson | cfc7fd5 | 2017-07-06 18:41:01 | [diff] [blame] | 305 | |
Bruce Dawson | 817f47fb | 2020-05-01 22:29:08 | [diff] [blame] | 306 | In order to speed up linking you can set `symbol_level = 1` or |
| 307 | `symbol_level = 0` - these options reduce the work the compiler and linker have |
| 308 | to do. With `symbol_level = 1` the compiler emits file name and line number |
| 309 | information so you can still do source-level debugging but there will be no |
| 310 | local variable or type information. With `symbol_level = 0` there is no |
| 311 | source-level debugging but call stacks still have function names. Changing |
| 312 | `symbol_level` requires recompiling everything. |
brucedawson | cfc7fd5 | 2017-07-06 18:41:01 | [diff] [blame] | 313 | |
Andrew Williams | 54da9cc | 2024-01-09 17:32:23 | [diff] [blame] | 314 | When invoking ninja, specify 'chrome' as the target to avoid building all test |
| 315 | binaries as well. |
| 316 | |
Ben Segall | 4a89ec5 | 2023-09-26 15:02:56 | [diff] [blame] | 317 | #### Use Reclient |
| 318 | |
Andrew Williams | 54da9cc | 2024-01-09 17:32:23 | [diff] [blame] | 319 | In addition, Google employees should use Reclient, a distributed compilation system. |
Ben Segall | 4a89ec5 | 2023-09-26 15:02:56 | [diff] [blame] | 320 | Detailed information is available internally but the relevant gn arg is: |
| 321 | * `use_remoteexec = true` |
| 322 | |
Solomon Kinard | 5cd0076 | 2023-11-04 00:47:19 | [diff] [blame] | 323 | Google employees can visit |
Andrew Williams | 54da9cc | 2024-01-09 17:32:23 | [diff] [blame] | 324 | [go/building-chrome-win#setup-remote-execution](https://goto.google.com/building-chrome-win#setup-remote-execution) |
| 325 | for more information. For external contributors, Reclient does not support |
| 326 | Windows builds. |
Ben Segall | 4a89ec5 | 2023-09-26 15:02:56 | [diff] [blame] | 327 | |
Juan Cruz Viotti | 9c7622d | 2021-06-30 00:27:23 | [diff] [blame] | 328 | #### Use SCCACHE |
| 329 | |
| 330 | You might be able to use [sccache](https://github.com/mozilla/sccache) for the |
| 331 | build process by enabling the following arguments: |
| 332 | |
| 333 | * `cc_wrapper = "sccache"` - assuming the `sccache` binary is in your `%PATH%` |
| 334 | * `chrome_pgo_phase = 0` |
| 335 | |
Bruce Dawson | e9f20fff | 2018-03-03 01:58:38 | [diff] [blame] | 336 | ### Why is my build slow? |
| 337 | |
| 338 | Many things can make builds slow, with Windows Defender slowing process startups |
| 339 | being a frequent culprit. Have you ensured that the entire Chromium src |
Bruce Dawson | 0bbe2d4 | 2018-03-06 19:45:55 | [diff] [blame] | 340 | directory is excluded from antivirus scanning (on Google machines this means |
Bruce Dawson | e9f20fff | 2018-03-03 01:58:38 | [diff] [blame] | 341 | putting it in a ``src`` directory in the root of a drive)? Have you tried the |
| 342 | different settings listed above, including different link settings and -j |
| 343 | values? Have you asked on the chromium-dev mailing list to see if your build is |
| 344 | slower than expected for your machine's specifications? |
| 345 | |
Bruce Dawson | 1510478 | 2023-10-19 20:06:23 | [diff] [blame] | 346 | If you suspect that Defender is slowing your build then you can try Microsoft's |
| 347 | [Performance analyzer for Microsoft Defender Antivirus](https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/tune-performance-defender-antivirus?view=o365-worldwide) |
| 348 | to investigate in detail. |
| 349 | |
Bruce Dawson | 8939017 | 2019-05-08 09:51:18 | [diff] [blame] | 350 | The next step is to gather some data. If you set the ``NINJA_SUMMARIZE_BUILD`` |
Bruce Dawson | b9988e9 | 2019-09-16 17:01:10 | [diff] [blame] | 351 | environment variable to 1 then ``autoninja`` will do three things. First, it |
| 352 | will set the [NINJA_STATUS](https://ninja-build.org/manual.html#_environment_variables) |
Bruce Dawson | 8939017 | 2019-05-08 09:51:18 | [diff] [blame] | 353 | environment variable so that ninja will print additional information while |
| 354 | building Chrome. It will show how many build processes are running at any given |
| 355 | time, how many build steps have completed, how many build steps have completed |
| 356 | per second, and how long the build has been running, as shown here: |
Bruce Dawson | e9f20fff | 2018-03-03 01:58:38 | [diff] [blame] | 357 | |
| 358 | ```shell |
Bruce Dawson | 8939017 | 2019-05-08 09:51:18 | [diff] [blame] | 359 | $ set NINJA_SUMMARIZE_BUILD=1 |
Bruce Dawson | e9f20fff | 2018-03-03 01:58:38 | [diff] [blame] | 360 | $ autoninja -C out\Default base |
| 361 | ninja: Entering directory `out\Default' |
| 362 | [1 processes, 86/86 @ 2.7/s : 31.785s ] LINK(DLL) base.dll base.dll.lib base.dll.pdb |
| 363 | ``` |
| 364 | |
Bruce Dawson | 8939017 | 2019-05-08 09:51:18 | [diff] [blame] | 365 | This makes slow process creation immediately obvious and lets you tell quickly |
| 366 | if a build is running more slowly than normal. |
| 367 | |
| 368 | In addition, setting ``NINJA_SUMMARIZE_BUILD=1`` tells ``autoninja`` to print a |
| 369 | build performance summary when the build completes, showing the slowest build |
| 370 | steps and slowest build-step types, as shown here: |
Bruce Dawson | e9f20fff | 2018-03-03 01:58:38 | [diff] [blame] | 371 | |
| 372 | ```shell |
| 373 | $ set NINJA_SUMMARIZE_BUILD=1 |
| 374 | $ autoninja -C out\Default base |
Bruce Dawson | 2721f0b | 2019-11-08 18:41:27 | [diff] [blame] | 375 | Longest build steps: |
| 376 | 0.1 weighted s to build obj/base/base/trace_log.obj (6.7 s elapsed time) |
| 377 | 0.2 weighted s to build nasm.exe, nasm.exe.pdb (0.2 s elapsed time) |
| 378 | 0.3 weighted s to build obj/base/base/win_util.obj (12.4 s elapsed time) |
| 379 | 1.2 weighted s to build base.dll, base.dll.lib (1.2 s elapsed time) |
| 380 | Time by build-step type: |
| 381 | 0.0 s weighted time to generate 6 .lib files (0.3 s elapsed time sum) |
| 382 | 0.1 s weighted time to generate 25 .stamp files (1.2 s elapsed time sum) |
| 383 | 0.2 s weighted time to generate 20 .o files (2.8 s elapsed time sum) |
| 384 | 1.7 s weighted time to generate 4 PEFile (linking) files (2.0 s elapsed |
| 385 | time sum) |
| 386 | 23.9 s weighted time to generate 770 .obj files (974.8 s elapsed time sum) |
| 387 | 26.1 s weighted time (982.9 s elapsed time sum, 37.7x parallelism) |
| 388 | 839 build steps completed, average of 32.17/s |
Bruce Dawson | e9f20fff | 2018-03-03 01:58:38 | [diff] [blame] | 389 | ``` |
| 390 | |
Bruce Dawson | 2721f0b | 2019-11-08 18:41:27 | [diff] [blame] | 391 | The "weighted" time is the elapsed time of each build step divided by the number |
| 392 | of tasks that were running in parallel. This makes it an excellent approximation |
| 393 | of how "important" a slow step was. A link that is entirely or mostly serialized |
| 394 | will have a weighted time that is the same or similar to its elapsed time. A |
| 395 | compile that runs in parallel with 999 other compiles will have a weighted time |
| 396 | that is tiny. |
| 397 | |
Bruce Dawson | 0bbe2d4 | 2018-03-06 19:45:55 | [diff] [blame] | 398 | You can also generate these reports by manually running the script after a build: |
| 399 | |
| 400 | ```shell |
| 401 | $ python depot_tools\post_build_ninja_summary.py -C out\Default |
| 402 | ``` |
| 403 | |
Bruce Dawson | b9988e9 | 2019-09-16 17:01:10 | [diff] [blame] | 404 | Finally, setting ``NINJA_SUMMARIZE_BUILD=1`` tells autoninja to tell Ninja to |
| 405 | report on its own overhead by passing "-d stats". This can be helpful if, for |
| 406 | instance, process creation (which shows up in the StartEdge metric) is making |
| 407 | builds slow, perhaps due to antivirus interference due to clang-cl not being in |
| 408 | an excluded directory: |
Bruce Dawson | e9f20fff | 2018-03-03 01:58:38 | [diff] [blame] | 409 | |
| 410 | ```shell |
Bruce Dawson | b9988e9 | 2019-09-16 17:01:10 | [diff] [blame] | 411 | $ set NINJA_SUMMARIZE_BUILD=1 |
| 412 | $ autoninja -C out\Default base |
Bruce Dawson | e9f20fff | 2018-03-03 01:58:38 | [diff] [blame] | 413 | metric count avg (us) total (ms) |
| 414 | .ninja parse 3555 1539.4 5472.6 |
| 415 | canonicalize str 1383032 0.0 12.7 |
| 416 | canonicalize path 1402349 0.0 11.2 |
| 417 | lookup node 1398245 0.0 8.1 |
| 418 | .ninja_log load 2 118.0 0.2 |
| 419 | .ninja_deps load 2 67.5 0.1 |
| 420 | node stat 2516 29.6 74.4 |
| 421 | depfile load 2 1132.0 2.3 |
| 422 | StartEdge 88 3508.1 308.7 |
| 423 | FinishCommand 87 1670.9 145.4 |
| 424 | CLParser::Parse 45 1889.1 85.0 |
| 425 | ``` |
| 426 | |
Bruce Dawson | b9988e9 | 2019-09-16 17:01:10 | [diff] [blame] | 427 | You can also get a visual report of the build performance with |
| 428 | [ninjatracing](https://github.com/nico/ninjatracing). This converts the |
Chunbo Hua | ea6a9cf | 2022-07-20 03:01:10 | [diff] [blame] | 429 | .ninja_log file into a .json file which can be loaded into [chrome://tracing](chrome://tracing): |
Bruce Dawson | b9988e9 | 2019-09-16 17:01:10 | [diff] [blame] | 430 | |
| 431 | ```shell |
| 432 | $ python ninjatracing out\Default\.ninja_log >build.json |
| 433 | ``` |
| 434 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 435 | ## Build Chromium |
| 436 | |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 437 | Build Chromium (the "chrome" target) with Ninja using the command: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 438 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 439 | ```shell |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 440 | $ autoninja -C out\Default chrome |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 441 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 442 | |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 443 | `autoninja` is a wrapper that automatically provides optimal values for the |
| 444 | arguments passed to `ninja`. |
| 445 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 446 | You can get a list of all of the other build targets from GN by running |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 447 | `gn ls out\Default` from the command line. To compile one, pass to Ninja |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 448 | the GN label with no preceding "//" (so for `//chrome/test:unit_tests` |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 449 | use `autoninja -C out\Default chrome/test:unit_tests`). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 450 | |
Junji Watanabe | db7caa6 | 2024-04-22 08:15:34 | [diff] [blame] | 451 | ## Compile a single file |
| 452 | |
Lalit Rana | 8bd378e | 2024-08-19 19:34:37 | [diff] [blame] | 453 | Ninja supports a special [syntax `^`][ninja hat syntax] to compile a single |
| 454 | object file specifying the source file. For example, `ninja -C |
| 455 | out/Default ../../base/logging.cc^` compiles `obj/base/base/logging.o`. |
Junji Watanabe | db7caa6 | 2024-04-22 08:15:34 | [diff] [blame] | 456 | |
| 457 | [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) |
| 458 | |
| 459 | With autoninja, you need to add `^^` to preserve the trailing `^`. |
| 460 | |
| 461 | ```shell |
| 462 | $ autoninja -C out\Default ..\..\base\logging.cc^^ |
| 463 | ``` |
| 464 | |
| 465 | In addition to `foo.cc^^`, Siso also supports `foo.h^^` syntax to compile |
| 466 | the corresponding `foo.o` if it exists. |
| 467 | |
Peter Kasting | a8ddeee | 2024-08-09 08:42:33 | [diff] [blame] | 468 | If you run a `bash` shell, you can use the following script to ease invocation: |
| 469 | |
| 470 | ```shell |
| 471 | #!/bin/sh |
| 472 | files=("${@/#/..\/..\/}") |
| 473 | autoninja -C out/Default ${files[@]/%/^^} |
| 474 | ``` |
| 475 | |
| 476 | This script assumes it is run from `src` and your output dir is `out/Default`; |
| 477 | it invokes `autoninja` to compile all given files. If you place it in your |
| 478 | `$PATH` and name it e.g. `compile`, you can invoke like this: |
| 479 | |
| 480 | ```shell |
| 481 | $ pwd # Just to illustrate where this is run from |
| 482 | /c/src |
| 483 | $ compile base/time/time.cc base/time/time_unittest.cc |
| 484 | ... |
| 485 | [0/47] 5.56s S CXX obj/base/base/time.obj |
| 486 | ... |
| 487 | [2/3] 9.27s S CXX obj/base/base_unittests/time_unittest.obj |
| 488 | ... |
| 489 | ``` |
| 490 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 491 | ## Run Chromium |
| 492 | |
| 493 | Once it is built, you can simply run the browser: |
| 494 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 495 | ```shell |
| 496 | $ out\Default\chrome.exe |
| 497 | ``` |
| 498 | |
| 499 | (The ".exe" suffix in the command is actually optional). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 500 | |
| 501 | ## Running test targets |
| 502 | |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 503 | Tests are split into multiple test targets based on their type and where they |
| 504 | exist in the directory structure. To see what target a given unit test or |
| 505 | browser test file corresponds to, the following command can be used: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 506 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 507 | ```shell |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 508 | $ gn refs out\Default --testonly=true --type=executable --all chrome\browser\ui\browser_list_unittest.cc |
| 509 | //chrome/test:unit_tests |
| 510 | ``` |
| 511 | |
| 512 | In the example above, the target is unit_tests. The unit_tests binary can be |
| 513 | built by running the following command: |
| 514 | |
| 515 | ```shell |
| 516 | $ autoninja -C out\Default unit_tests |
| 517 | ``` |
| 518 | |
| 519 | You can run the tests by running the unit_tests binary. You can also limit which |
| 520 | tests are run using the `--gtest_filter` arg, e.g.: |
| 521 | |
| 522 | ```shell |
| 523 | $ out\Default\unit_tests.exe --gtest_filter="BrowserListUnitTest.*" |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 524 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 525 | |
| 526 | You can find out more about GoogleTest at its |
| 527 | [GitHub page](https://github.com/google/googletest). |
| 528 | |
Greg Thompson | 530c2a9 | 2024-07-16 14:03:33 | [diff] [blame] | 529 | ## Build an Installer |
| 530 | |
| 531 | Build the `mini_installer` target to create a self-contained installer. This |
| 532 | has everything needed to install your browser on a machine. |
| 533 | |
| 534 | ```shell |
| 535 | $ autoninja -C out\Default mini_installer |
| 536 | ``` |
| 537 | |
| 538 | See [//chrome/installer/setup/README.md](../chrome/installer/setup/README.md) |
| 539 | and [//chrome/installer/mini_installer/README.md](../chrome/installer/mini_installer/README.md) |
| 540 | for more information. |
| 541 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 542 | ## Update your checkout |
| 543 | |
| 544 | To update an existing checkout, you can run |
| 545 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 546 | ```shell |
| 547 | $ git rebase-update |
Bruce Dawson | ef0b545 | 2020-10-03 00:13:09 | [diff] [blame] | 548 | $ gclient sync -D |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 549 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 550 | |
| 551 | The first command updates the primary Chromium source repository and rebases |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 552 | any of your local branches on top of tip-of-tree (aka the Git branch |
| 553 | `origin/main`). If you don't want to use this script, you can also just use |
| 554 | `git pull` or other common Git commands to update the repo. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 555 | |
Bruce Dawson | ef0b545 | 2020-10-03 00:13:09 | [diff] [blame] | 556 | The second command syncs the subrepositories to the appropriate versions, |
| 557 | deleting those that are no longer needed, and re-runs the hooks as needed. |
| 558 | |
| 559 | ### Editing and Debugging With the Visual Studio IDE |
| 560 | |
| 561 | You can use the Visual Studio IDE to edit and debug Chrome, with or without |
| 562 | Intellisense support. |
| 563 | |
| 564 | #### Using Visual Studio Intellisense |
| 565 | |
| 566 | If you want to use Visual Studio Intellisense when developing Chromium, use the |
| 567 | `--ide` command line argument to `gn gen` when you generate your output |
| 568 | directory (as described on the [get the code](https://dev.chromium.org/developers/how-tos/get-the-code) |
Junji Watanabe | 0f6489c7 | 2023-02-01 04:02:11 | [diff] [blame] | 569 | page). This is an example when your checkout is `C:\src\chromium` and your |
| 570 | output directory is `out\Default`: |
Bruce Dawson | ef0b545 | 2020-10-03 00:13:09 | [diff] [blame] | 571 | |
| 572 | ```shell |
Junji Watanabe | 0f6489c7 | 2023-02-01 04:02:11 | [diff] [blame] | 573 | $ gn gen --ide=vs --ninja-executable=C:\src\chromium\src\third_party\ninja\ninja.exe out\Default |
Bruce Dawson | ef0b545 | 2020-10-03 00:13:09 | [diff] [blame] | 574 | $ devenv out\Default\all.sln |
| 575 | ``` |
| 576 | |
| 577 | GN will produce a file `all.sln` in your build directory. It will internally |
| 578 | use Ninja to compile while still allowing most IDE functions to work (there is |
| 579 | no native Visual Studio compilation mode). If you manually run "gen" again you |
| 580 | will need to resupply this argument, but normally GN will keep the build and |
| 581 | IDE files up to date automatically when you build. |
| 582 | |
| 583 | The generated solution will contain several thousand projects and will be very |
| 584 | slow to load. Use the `--filters` argument to restrict generating project files |
| 585 | for only the code you're interested in. Although this will also limit what |
| 586 | files appear in the project explorer, debugging will still work and you can |
| 587 | set breakpoints in files that you open manually. A minimal solution that will |
| 588 | let you compile and run Chrome in the IDE but will not show any source files |
| 589 | is: |
| 590 | |
| 591 | ``` |
Junji Watanabe | 0f6489c7 | 2023-02-01 04:02:11 | [diff] [blame] | 592 | $ gn gen --ide=vs --ninja-executable=C:\src\chromium\src\third_party\ninja\ninja.exe --filters=//chrome --no-deps out\Default |
Bruce Dawson | ef0b545 | 2020-10-03 00:13:09 | [diff] [blame] | 593 | ``` |
| 594 | |
| 595 | You can selectively add other directories you care about to the filter like so: |
| 596 | `--filters=//chrome;//third_party/WebKit/*;//gpu/*`. |
| 597 | |
| 598 | There are other options for controlling how the solution is generated, run `gn |
| 599 | help gen` for the current documentation. |
| 600 | |
| 601 | #### Using Visual Studio without Intellisense |
| 602 | |
| 603 | It is also possible to debug and develop Chrome in Visual Studio without the |
| 604 | overhead of a multi-project solution file. Simply "open" your chrome.exe binary |
| 605 | with `File->Open->Project/Solution`, or from a Visual Studio command prompt like |
| 606 | so: `devenv /debugexe out\Debug\chrome.exe <your arguments>`. Many of Visual |
| 607 | Studio's code exploration features will not work in this configuration, but by |
| 608 | installing the [VsChromium Visual Studio Extension](https://chromium.github.io/vs-chromium/) |
| 609 | you can get the source code to appear in the solution explorer window along |
| 610 | with other useful features such as code search. You can add multiple executables |
| 611 | of interest (base_unittests.exe, browser_tests.exe) to your solution with |
| 612 | `File->Add->Existing Project...` and change which one will be debugged by |
| 613 | right-clicking on them in `Solution Explorer` and selecting `Set as Startup |
| 614 | Project`. You can also change their properties, including command line |
| 615 | arguments, by right-clicking on them in `Solution Explorer` and selecting |
| 616 | `Properties`. |
| 617 | |
| 618 | By default when you start debugging in Visual Studio the debugger will only |
| 619 | attach to the main browser process. To debug all of Chrome, install |
| 620 | [Microsoft's Child Process Debugging Power Tool](https://blogs.msdn.microsoft.com/devops/2014/11/24/introducing-the-child-process-debugging-power-tool/). |
| 621 | You will also need to run Visual Studio as administrator, or it will silently |
| 622 | fail to attach to some of Chrome's child processes. |
| 623 | |
Bruce Dawson | 425d4ab | 2023-06-25 01:36:15 | [diff] [blame] | 624 | ### Improving performance of git commands |
Avi Drissman | c0f6793ac | 2023-05-26 19:22:44 | [diff] [blame] | 625 | |
| 626 | #### Configure git to use an untracked cache |
| 627 | |
Bruce Dawson | 2154274a | 2023-06-17 22:24:29 | [diff] [blame] | 628 | Try running |
Avi Drissman | c0f6793ac | 2023-05-26 19:22:44 | [diff] [blame] | 629 | |
| 630 | ```shell |
| 631 | $ git update-index --test-untracked-cache |
| 632 | ``` |
| 633 | |
| 634 | If the output ends with `OK`, then the following may also improve performance of |
| 635 | `git status`: |
| 636 | |
| 637 | ```shell |
| 638 | $ git config core.untrackedCache true |
| 639 | ``` |
| 640 | |
Avi Drissman | c0f6793ac | 2023-05-26 19:22:44 | [diff] [blame] | 641 | #### Configure git to use fsmonitor |
| 642 | |
Bruce Dawson | 2154274a | 2023-06-17 22:24:29 | [diff] [blame] | 643 | You can significantly speed up git by using [fsmonitor.](https://github.blog/2022-06-29-improve-git-monorepo-performance-with-a-file-system-monitor/) |
| 644 | You should enable fsmonitor in large repos, such as Chromium and v8. Enabling |
| 645 | it globally will launch many processes and consume excess commit/memory and |
| 646 | probably isn't worthwhile. The command to enable fsmonitor in the current repo |
| 647 | is: |
Avi Drissman | c0f6793ac | 2023-05-26 19:22:44 | [diff] [blame] | 648 | |
| 649 | ```shell |
| 650 | $ git config core.fsmonitor true |
| 651 | ``` |