blob: 88c4dcef9a0bd6292b2d53c653bac4d37fda916b [file] [log] [blame] [view]
dpranke0ae7cad2016-11-30 07:47:581# Checking out and building Chromium on Linux
andybons3322f762015-08-24 21:37:092
dpranke0ae7cad2016-11-30 07:47:583**See also [the old version of this page](old_linux_build_instructions.md).**
andybons3322f762015-08-24 21:37:094
dpranke0ae7cad2016-11-30 07:47:585Google employee? See [go/building-chrome](https://goto.google.com/building-chrome) instead.
andybons8c02a1f2015-09-04 17:02:326
dpranke0ae7cad2016-11-30 07:47:587[TOC]
andybonsad92aa32015-08-31 02:27:448
dpranke0ae7cad2016-11-30 07:47:589## System requirements
andybonsad92aa32015-08-31 02:27:4410
dpranke0ae7cad2016-11-30 07:47:5811* A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly
12 recommended.
13* At least 100GB of free disk space.
14* You must have Git and Python installed already.
andybons3322f762015-08-24 21:37:0915
sdy93387fa2016-12-01 01:03:4416Most development is done on Ubuntu (currently 14.04, Trusty Tahr). There are
dpranke0ae7cad2016-11-30 07:47:5817some instructions for other distros below, but they are mostly unsupported.
andybons3322f762015-08-24 21:37:0918
dpranke0ae7cad2016-11-30 07:47:5819## Install `depot_tools`
andybonsad92aa32015-08-31 02:27:4420
sdy93387fa2016-12-01 01:03:4421Clone the `depot_tools` repository:
andybons3322f762015-08-24 21:37:0922
sdy93387fa2016-12-01 01:03:4423```shell
24$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
25```
andybonsad92aa32015-08-31 02:27:4426
sdy93387fa2016-12-01 01:03:4427Add `depot_tools` to the end of your PATH (you will probably want to put this
28in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to
29`/path/to/depot_tools`:
andybonsad92aa32015-08-31 02:27:4430
sdy93387fa2016-12-01 01:03:4431```shell
32$ export PATH="$PATH:/path/to/depot_tools"
33```
andybons3322f762015-08-24 21:37:0934
dpranke0ae7cad2016-11-30 07:47:5835## Get the code
andybonsad92aa32015-08-31 02:27:4436
sdy93387fa2016-12-01 01:03:4437Create a `chromium` directory for the checkout and change to it (you can call
38this whatever you like and put it wherever you like, as long as the full path
39has no spaces):
40
41```shell
42$ mkdir ~/chromium && cd ~/chromium
43```
andybons3322f762015-08-24 21:37:0944
dpranke0ae7cad2016-11-30 07:47:5845Run the `fetch` tool from depot_tools to check out the code and its
46dependencies.
andybonsad92aa32015-08-31 02:27:4447
sdy93387fa2016-12-01 01:03:4448```shell
49$ fetch --nohooks chromium
50```
andybonsad92aa32015-08-31 02:27:4451
dpranke0ae7cad2016-11-30 07:47:5852If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:4453adding the `--no-history` flag to `fetch`.
andybons3322f762015-08-24 21:37:0954
dpranke0ae7cad2016-11-30 07:47:5855Expect the command to take 30 minutes on even a fast connection, and many
56hours on slower ones.
andybonsad92aa32015-08-31 02:27:4457
dpranke0ae7cad2016-11-30 07:47:5858If you've already installed the build dependencies on the machine (from another
sdy93387fa2016-12-01 01:03:4459checkout, for example), you can omit the `--nohooks` flag and `fetch`
dpranke0ae7cad2016-11-30 07:47:5860will automatically execute `gclient runhooks` at the end.
andybons3322f762015-08-24 21:37:0961
sdy93387fa2016-12-01 01:03:4462When `fetch` completes, it will have created a hidden `.gclient` file and a
63directory called `src` in the working directory. The remaining instructions
64assume you have switched to the `src` directory:
andybons3322f762015-08-24 21:37:0965
sdy93387fa2016-12-01 01:03:4466```shell
67$ cd src
68```
andybons3322f762015-08-24 21:37:0969
dpranke0ae7cad2016-11-30 07:47:5870### Install additional build dependencies
andybons3322f762015-08-24 21:37:0971
dpranke0ae7cad2016-11-30 07:47:5872Once you have checked out the code, and assuming you're using Ubuntu, run
73[build/install-build-deps.sh](/build/install-build-deps.sh)
andybons3322f762015-08-24 21:37:0974
dpranke0ae7cad2016-11-30 07:47:5875Here are some instructions for what to do instead for
andybons3322f762015-08-24 21:37:0976
dpranke0ae7cad2016-11-30 07:47:5877* [Debian](linux_debian_build_instructions.md)
78* [Fedora](linux_fedora_build_instructions.md)
79* [Arch Linux](linux_arch_build_instructions.md)
80* [Open SUSE](linux_open_suse_build_instrctions.md)
81* [Mandriva](linux_mandriva_build_instrctions.md)
andybonsad92aa32015-08-31 02:27:4482
dpranke0ae7cad2016-11-30 07:47:5883For Gentoo, you can just run `emerge www-client/chromium`.
andybonsad92aa32015-08-31 02:27:4484
dpranke0ae7cad2016-11-30 07:47:5885### Run the hooks
andybons3322f762015-08-24 21:37:0986
dpranke0ae7cad2016-11-30 07:47:5887Once you've run `install-build-deps` at least once, you can now run the
sdy93387fa2016-12-01 01:03:4488Chromium-specific hooks, which will download additional binaries and other
dpranke0ae7cad2016-11-30 07:47:5889things you might need:
andybonsad92aa32015-08-31 02:27:4490
sdy93387fa2016-12-01 01:03:4491```shell
92$ gclient runhooks
93```
andybonsad92aa32015-08-31 02:27:4494
sdy93387fa2016-12-01 01:03:4495*Optional*: You can also [install API
96keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
97build to talk to some Google services, but this is not necessary for most
98development and testing purposes.
andybons3322f762015-08-24 21:37:0999
sdy93387fa2016-12-01 01:03:44100## Setting up the Build
andybonsad92aa32015-08-31 02:27:44101
sdy93387fa2016-12-01 01:03:44102Chromium uses [Ninja](https://ninja-build.org) as its main build tool along
103with a tool called [GN](../tools/gn/docs/quick_start.md) to generate `.ninja`
104files. You can create any number of *build directories* with different
105configurations. To create a build directory, run:
andybons8c02a1f2015-09-04 17:02:32106
sdy93387fa2016-12-01 01:03:44107```shell
108$ gn gen out/Default
109```
dpranke0ae7cad2016-11-30 07:47:58110
sdy93387fa2016-12-01 01:03:44111* You only have to run this once for each new build directory, Ninja will
112 update the build files as needed.
113* You can replace `Default` with another name, but
114 it should be a subdirectory of `out`.
115* For other build arguments, including release settings, see [GN build
116 configuration](https://www.chromium.org/developers/gn-build-configuration).
dpranke0ae7cad2016-11-30 07:47:58117 The default will be a debug component build matching the current host
118 operating system and CPU.
119* For more info on GN, run `gn help` on the command line or read the
120 [quick start guide](../tools/gn/docs/quick_start.md).
121
122### Faster builds
123
124See [faster builds on Linux](linux_faster_builds.md) for various tips and
125settings that may speed up your build.
126
127## Build Chromium
128
129Build Chromium (the "chrome" target) with Ninja using the command:
130
sdy93387fa2016-12-01 01:03:44131```shell
132$ ninja -C out/Default chrome
133```
dpranke0ae7cad2016-11-30 07:47:58134
sdy93387fa2016-12-01 01:03:44135You can get a list of all of the other build targets from GN by running `gn ls
136out/Default` from the command line. To compile one, pass the GN label to Ninja
137with no preceding "//" (so, for `//chrome/test:unit_tests` use `ninja -C
138out/Default chrome/test:unit_tests`).
dpranke0ae7cad2016-11-30 07:47:58139
140## Run Chromium
141
142Once it is built, you can simply run the browser:
143
sdy93387fa2016-12-01 01:03:44144```shell
145$ out/Default/chrome
146```
dpranke0ae7cad2016-11-30 07:47:58147
148## Running test targets
149
150You can run the tests in the same way. You can also limit which tests are
151run using the `--gtest_filter` arg, e.g.:
152
sdy93387fa2016-12-01 01:03:44153```shell
154$ ninja -C out/Default unit_tests --gtest_filter="PushClientTest.*"
155```
dpranke0ae7cad2016-11-30 07:47:58156
157You can find out more about GoogleTest at its
158[GitHub page](https://github.com/google/googletest).
159
160## Update your checkout
161
162To update an existing checkout, you can run
163
sdy93387fa2016-12-01 01:03:44164```shell
165$ git rebase-update
166$ gclient sync
167```
dpranke0ae7cad2016-11-30 07:47:58168
169The first command updates the primary Chromium source repository and rebases
sdy93387fa2016-12-01 01:03:44170any of your local branches on top of tip-of-tree (aka the Git branch
171`origin/master`). If you don't want to use this script, you can also just use
172`git pull` or other common Git commands to update the repo.
dpranke0ae7cad2016-11-30 07:47:58173
sdy93387fa2016-12-01 01:03:44174The second command syncs dependencies to the appropriate versions and re-runs
175hooks as needed.
dpranke0ae7cad2016-11-30 07:47:58176
177## Tips, tricks, and troubleshooting
andybons3322f762015-08-24 21:37:09178
179### Linker Crashes
andybonsad92aa32015-08-31 02:27:44180
andybons3322f762015-08-24 21:37:09181If, during the final link stage:
andybonsad92aa32015-08-31 02:27:44182
sdy93387fa2016-12-01 01:03:44183```
184LINK out/Debug/chrome
185```
andybonsad92aa32015-08-31 02:27:44186
andybons3322f762015-08-24 21:37:09187You get an error like:
andybons3322f762015-08-24 21:37:09188
sdy93387fa2016-12-01 01:03:44189```
190collect2: ld terminated with signal 6 Aborted terminate called after throwing an instance of 'std::bad_alloc'
191collect2: ld terminated with signal 11 [Segmentation fault], core dumped
192```
andybonsad92aa32015-08-31 02:27:44193
brettwc25693b32016-05-26 01:11:52194you are probably running out of memory when linking. You *must* use a 64-bit
195system to build. Try the following build settings (see [GN build
196configuration](https://www.chromium.org/developers/gn-build-configuration) for
sdy93387fa2016-12-01 01:03:44197other settings):
andybonsad92aa32015-08-31 02:27:44198
sdy93387fa2016-12-01 01:03:44199* Build in release mode (debugging symbols require more memory):
brettwc25693b32016-05-26 01:11:52200 `is_debug = false`
sdy93387fa2016-12-01 01:03:44201* Turn off symbols: `symbol_level = 0`
202* Build in component mode (this is for development only, it will be slower and
203 may have broken functionality): `is_component_build = true`
andybons3322f762015-08-24 21:37:09204
dpranke0ae7cad2016-11-30 07:47:58205### More links
andybons3322f762015-08-24 21:37:09206
brettwc25693b32016-05-26 01:11:52207* Information about [building with Clang](clang.md).
dpranke0ae7cad2016-11-30 07:47:58208* You may want to [use a chroot](using_a_linux_chroot.md) to
209 isolate yourself from versioning or packaging conflicts.
andybonsad92aa32015-08-31 02:27:44210* Cross-compiling for ARM? See [LinuxChromiumArm](linux_chromium_arm.md).
211* Want to use Eclipse as your IDE? See
212 [LinuxEclipseDev](linux_eclipse_dev.md).
dpranke0ae7cad2016-11-30 07:47:58213* Want to use your built version as your default browser? See
andybonsad92aa32015-08-31 02:27:44214 [LinuxDevBuildAsDefaultBrowser](linux_dev_build_as_default_browser.md).
andybons3322f762015-08-24 21:37:09215
dpranke0ae7cad2016-11-30 07:47:58216### Next Steps
andybonsad92aa32015-08-31 02:27:44217
218If you want to contribute to the effort toward a Chromium-based browser for
219Linux, please check out the [Linux Development page](linux_development.md) for
220more information.