OLD | NEW |
1 # Checking out and building Chromium on Linux | 1 # Checking out and building Chromium on Linux |
2 | 2 |
3 **See also [the old version of this page](old_linux_build_instructions.md).** | 3 **See also [the old version of this page](old_linux_build_instructions.md).** |
4 | 4 |
5 Google employee? See [go/building-chrome](https://goto.google.com/building-chrom
e) instead. | 5 Google employee? See [go/building-chrome](https://goto.google.com/building-chrom
e) instead. |
6 | 6 |
7 [TOC] | 7 [TOC] |
8 | 8 |
9 ## System requirements | 9 ## System requirements |
10 | 10 |
11 * A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly | 11 * A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly |
12 recommended. | 12 recommended. |
13 * At least 100GB of free disk space. | 13 * At least 100GB of free disk space. |
14 * You must have Git and Python installed already. | 14 * You must have Git and Python installed already. |
15 | 15 |
16 Most development is done on Ubuntu (currently 14.04, Trusty Tahr). There are | 16 Most development is done on Ubuntu (currently 14.04, Trusty Tahr). There are |
17 some instructions for other distros below, but they are mostly unsupported. | 17 some instructions for other distros below, but they are mostly unsupported. |
18 | 18 |
19 ## Install `depot_tools` | 19 ## Install `depot_tools` |
20 | 20 |
21 Clone the depot_tools repository: | 21 Clone the `depot_tools` repository: |
22 | 22 |
23 $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git | 23 ```shell |
| 24 $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 25 ``` |
24 | 26 |
25 Add depot_tools to the end of your PATH (you will probably want to put this | 27 Add `depot_tools` to the end of your PATH (you will probably want to put this |
26 in your ~/.bashrc or ~/.zshrc). Assuming you cloned depot_tools | 28 in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to |
27 to /path/to/depot_tools: | 29 `/path/to/depot_tools`: |
28 | 30 |
29 $ export PATH=$PATH:/path/to/depot_tools | 31 ```shell |
| 32 $ export PATH="$PATH:/path/to/depot_tools" |
| 33 ``` |
30 | 34 |
31 ## Get the code | 35 ## Get the code |
32 | 36 |
33 Create a chromium directory for the checkout and change to it (you can call | 37 Create a `chromium` directory for the checkout and change to it (you can call |
34 this whatever you like and put it wherever you like, as | 38 this whatever you like and put it wherever you like, as long as the full path |
35 long as the full path has no spaces): | 39 has no spaces): |
36 | 40 |
37 $ mkdir chromium | 41 ```shell |
38 $ cd chromium | 42 $ mkdir ~/chromium && cd ~/chromium |
| 43 ``` |
39 | 44 |
40 Run the `fetch` tool from depot_tools to check out the code and its | 45 Run the `fetch` tool from depot_tools to check out the code and its |
41 dependencies. | 46 dependencies. |
42 | 47 |
43 $ fetch --nohooks chromium | 48 ```shell |
| 49 $ fetch --nohooks chromium |
| 50 ``` |
44 | 51 |
45 If you don't want the full repo history, you can save a lot of time by | 52 If you don't want the full repo history, you can save a lot of time by |
46 adding the `--no-history` flag to fetch. | 53 adding the `--no-history` flag to `fetch`. |
47 | 54 |
48 Expect the command to take 30 minutes on even a fast connection, and many | 55 Expect the command to take 30 minutes on even a fast connection, and many |
49 hours on slower ones. | 56 hours on slower ones. |
50 | 57 |
51 If you've already installed the build dependencies on the machine (from another | 58 If you've already installed the build dependencies on the machine (from another |
52 checkout, for example), you can omit the `--nohooks` flag and fetch | 59 checkout, for example), you can omit the `--nohooks` flag and `fetch` |
53 will automatically execute `gclient runhooks` at the end. | 60 will automatically execute `gclient runhooks` at the end. |
54 | 61 |
55 When fetch completes, it will have created a directory called `src`. | 62 When `fetch` completes, it will have created a hidden `.gclient` file and a |
56 The remaining instructions assume you are now in that directory: | 63 directory called `src` in the working directory. The remaining instructions |
| 64 assume you have switched to the `src` directory: |
57 | 65 |
58 $ cd src | 66 ```shell |
| 67 $ cd src |
| 68 ``` |
59 | 69 |
60 ### Install additional build dependencies | 70 ### Install additional build dependencies |
61 | 71 |
62 Once you have checked out the code, and assuming you're using Ubuntu, run | 72 Once you have checked out the code, and assuming you're using Ubuntu, run |
63 [build/install-build-deps.sh](/build/install-build-deps.sh) | 73 [build/install-build-deps.sh](/build/install-build-deps.sh) |
64 | 74 |
65 Here are some instructions for what to do instead for | 75 Here are some instructions for what to do instead for |
66 | 76 |
67 * [Debian](linux_debian_build_instructions.md) | 77 * [Debian](linux_debian_build_instructions.md) |
68 * [Fedora](linux_fedora_build_instructions.md) | 78 * [Fedora](linux_fedora_build_instructions.md) |
69 * [Arch Linux](linux_arch_build_instructions.md) | 79 * [Arch Linux](linux_arch_build_instructions.md) |
70 * [Open SUSE](linux_open_suse_build_instrctions.md) | 80 * [Open SUSE](linux_open_suse_build_instrctions.md) |
71 * [Mandriva](linux_mandriva_build_instrctions.md) | 81 * [Mandriva](linux_mandriva_build_instrctions.md) |
72 | 82 |
73 For Gentoo, you can just run `emerge www-client/chromium`. | 83 For Gentoo, you can just run `emerge www-client/chromium`. |
74 | 84 |
75 ### Run the hooks | 85 ### Run the hooks |
76 | 86 |
77 Once you've run `install-build-deps` at least once, you can now run the | 87 Once you've run `install-build-deps` at least once, you can now run the |
78 chromium-specific hooks, which will download additional binaries and other | 88 Chromium-specific hooks, which will download additional binaries and other |
79 things you might need: | 89 things you might need: |
80 | 90 |
81 $ gclient runhooks | 91 ```shell |
| 92 $ gclient runhooks |
| 93 ``` |
82 | 94 |
83 *Optional*: You can also [install API keys](https://www.chromium.org/developers/
how-tos/api-keys) | 95 *Optional*: You can also [install API |
84 if you want to talk to some of the Google services, but this is not necessary | 96 keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your |
85 for most development and testing purposes. | 97 build to talk to some Google services, but this is not necessary for most |
| 98 development and testing purposes. |
86 | 99 |
87 ## Seting up the Build | 100 ## Setting up the Build |
88 | 101 |
89 Chromium uses [Ninja](https://ninja-build.org) as its main build tool, and | 102 Chromium uses [Ninja](https://ninja-build.org) as its main build tool along |
90 a tool called [GN](../tools/gn/docs/quick_start.md) to generate | 103 with a tool called [GN](../tools/gn/docs/quick_start.md) to generate `.ninja` |
91 the .ninja files to do the build. To create a build directory, run: | 104 files. You can create any number of *build directories* with different |
| 105 configurations. To create a build directory, run: |
92 | 106 |
93 $ gn gen out/Default | 107 ```shell |
| 108 $ gn gen out/Default |
| 109 ``` |
94 | 110 |
95 * You only have to do run this command once, it will self-update the build | 111 * You only have to run this once for each new build directory, Ninja will |
96 files as needed after that. | 112 update the build files as needed. |
97 * You can replace `out/Default` with another directory name, but we recommend | 113 * You can replace `Default` with another name, but |
98 it should still be a subdirectory of `out`. | 114 it should be a subdirectory of `out`. |
99 * To specify build parameters for GN builds, including release settings, | 115 * For other build arguments, including release settings, see [GN build |
100 see [GN build configuration](https://www.chromium.org/developers/gn-build-conf
iguration). | 116 configuration](https://www.chromium.org/developers/gn-build-configuration). |
101 The default will be a debug component build matching the current host | 117 The default will be a debug component build matching the current host |
102 operating system and CPU. | 118 operating system and CPU. |
103 * For more info on GN, run `gn help` on the command line or read the | 119 * For more info on GN, run `gn help` on the command line or read the |
104 [quick start guide](../tools/gn/docs/quick_start.md). | 120 [quick start guide](../tools/gn/docs/quick_start.md). |
105 | 121 |
106 ### Faster builds | 122 ### Faster builds |
107 | 123 |
108 See [faster builds on Linux](linux_faster_builds.md) for various tips and | 124 See [faster builds on Linux](linux_faster_builds.md) for various tips and |
109 settings that may speed up your build. | 125 settings that may speed up your build. |
110 | 126 |
111 ## Build Chromium | 127 ## Build Chromium |
112 | 128 |
113 Build Chromium (the "chrome" target) with Ninja using the command: | 129 Build Chromium (the "chrome" target) with Ninja using the command: |
114 | 130 |
115 $ ninja -C out/Default chrome | 131 ```shell |
| 132 $ ninja -C out/Default chrome |
| 133 ``` |
116 | 134 |
117 You can get a list of all of the other build targets from GN by running | 135 You can get a list of all of the other build targets from GN by running `gn ls |
118 `gn ls out/Default` from the command line. To compile one, pass to Ninja | 136 out/Default` from the command line. To compile one, pass the GN label to Ninja |
119 the GN label with no preceding "//" (so for `//chrome/test:unit_tests` | 137 with no preceding "//" (so, for `//chrome/test:unit_tests` use `ninja -C |
120 use ninja -C out/Default chrome/test:unit_tests`). | 138 out/Default chrome/test:unit_tests`). |
121 | 139 |
122 ## Run Chromium | 140 ## Run Chromium |
123 | 141 |
124 Once it is built, you can simply run the browser: | 142 Once it is built, you can simply run the browser: |
125 | 143 |
126 $ out/Default/chrome | 144 ```shell |
| 145 $ out/Default/chrome |
| 146 ``` |
127 | 147 |
128 ## Running test targets | 148 ## Running test targets |
129 | 149 |
130 You can run the tests in the same way. You can also limit which tests are | 150 You can run the tests in the same way. You can also limit which tests are |
131 run using the `--gtest_filter` arg, e.g.: | 151 run using the `--gtest_filter` arg, e.g.: |
132 | 152 |
133 $ ninja -C out/Default unit_tests --gtest_filter="PushClientTest.*" | 153 ```shell |
| 154 $ ninja -C out/Default unit_tests --gtest_filter="PushClientTest.*" |
| 155 ``` |
134 | 156 |
135 You can find out more about GoogleTest at its | 157 You can find out more about GoogleTest at its |
136 [GitHub page](https://github.com/google/googletest). | 158 [GitHub page](https://github.com/google/googletest). |
137 | 159 |
138 ## Update your checkout | 160 ## Update your checkout |
139 | 161 |
140 To update an existing checkout, you can run | 162 To update an existing checkout, you can run |
141 | 163 |
142 $ git rebase-update | 164 ```shell |
143 $ gclient sync | 165 $ git rebase-update |
| 166 $ gclient sync |
| 167 ``` |
144 | 168 |
145 The first command updates the primary Chromium source repository and rebases | 169 The first command updates the primary Chromium source repository and rebases |
146 any of your local branches on top of tip-of-tree (aka the Git branch `origin/mas
ter`). | 170 any of your local branches on top of tip-of-tree (aka the Git branch |
147 If you don't want to use this script, you can also just use `git pull` or | 171 `origin/master`). If you don't want to use this script, you can also just use |
148 other common Git commands to update the repo. | 172 `git pull` or other common Git commands to update the repo. |
149 | 173 |
150 The second command syncs the subrepositories to the appropriate versions and | 174 The second command syncs dependencies to the appropriate versions and re-runs |
151 re-runs the hooks as needed. | 175 hooks as needed. |
152 | 176 |
153 ## Tips, tricks, and troubleshooting | 177 ## Tips, tricks, and troubleshooting |
154 | 178 |
155 ### Linker Crashes | 179 ### Linker Crashes |
156 | 180 |
157 If, during the final link stage: | 181 If, during the final link stage: |
158 | 182 |
159 LINK out/Debug/chrome | 183 ``` |
| 184 LINK out/Debug/chrome |
| 185 ``` |
160 | 186 |
161 You get an error like: | 187 You get an error like: |
162 | 188 |
163 collect2: ld terminated with signal 6 Aborted terminate called after throwin
g an | 189 ``` |
164 instance of 'std::bad_alloc' | 190 collect2: ld terminated with signal 6 Aborted terminate called after throwing an
instance of 'std::bad_alloc' |
165 | 191 collect2: ld terminated with signal 11 [Segmentation fault], core dumped |
166 collect2: ld terminated with signal 11 [Segmentation fault], core dumped | 192 ``` |
167 | 193 |
168 you are probably running out of memory when linking. You *must* use a 64-bit | 194 you are probably running out of memory when linking. You *must* use a 64-bit |
169 system to build. Try the following build settings (see [GN build | 195 system to build. Try the following build settings (see [GN build |
170 configuration](https://www.chromium.org/developers/gn-build-configuration) for | 196 configuration](https://www.chromium.org/developers/gn-build-configuration) for |
171 setting): | 197 other settings): |
172 | 198 |
173 * Build in release mode (debugging symbols require more memory). | 199 * Build in release mode (debugging symbols require more memory): |
174 `is_debug = false` | 200 `is_debug = false` |
175 * Turn off symbols. `symbol_level = 0` | 201 * Turn off symbols: `symbol_level = 0` |
176 * Build in component mode (this is for developers only, it will be slower and | 202 * Build in component mode (this is for development only, it will be slower and |
177 may have broken functionality). `is_component_build = true` | 203 may have broken functionality): `is_component_build = true` |
178 | 204 |
179 ### More links | 205 ### More links |
180 | 206 |
181 * Information about [building with Clang](clang.md). | 207 * Information about [building with Clang](clang.md). |
182 * You may want to [use a chroot](using_a_linux_chroot.md) to | 208 * You may want to [use a chroot](using_a_linux_chroot.md) to |
183 isolate yourself from versioning or packaging conflicts. | 209 isolate yourself from versioning or packaging conflicts. |
184 * Cross-compiling for ARM? See [LinuxChromiumArm](linux_chromium_arm.md). | 210 * Cross-compiling for ARM? See [LinuxChromiumArm](linux_chromium_arm.md). |
185 * Want to use Eclipse as your IDE? See | 211 * Want to use Eclipse as your IDE? See |
186 [LinuxEclipseDev](linux_eclipse_dev.md). | 212 [LinuxEclipseDev](linux_eclipse_dev.md). |
187 * Want to use your built version as your default browser? See | 213 * Want to use your built version as your default browser? See |
188 [LinuxDevBuildAsDefaultBrowser](linux_dev_build_as_default_browser.md). | 214 [LinuxDevBuildAsDefaultBrowser](linux_dev_build_as_default_browser.md). |
189 | 215 |
190 ### Next Steps | 216 ### Next Steps |
191 | 217 |
192 If you want to contribute to the effort toward a Chromium-based browser for | 218 If you want to contribute to the effort toward a Chromium-based browser for |
193 Linux, please check out the [Linux Development page](linux_development.md) for | 219 Linux, please check out the [Linux Development page](linux_development.md) for |
194 more information. | 220 more information. |
OLD | NEW |