blob: 1731c7930fd17395028c1488cefd5db1b0d44f4a [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
dpranke0ae7cad2016-11-30 07:47:5816Most development is done on Ubuntu (currently 14.04, Trusty Tahr). There are
17some 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
dpranke0ae7cad2016-11-30 07:47:5821Clone the depot_tools repository:
andybons3322f762015-08-24 21:37:0922
dpranke0ae7cad2016-11-30 07:47:5823 $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
andybonsad92aa32015-08-31 02:27:4424
dpranke0ae7cad2016-11-30 07:47:5825Add depot_tools to the end of your PATH (you will probably want to put this
26in your ~/.bashrc or ~/.zshrc). Assuming you cloned depot_tools
27to /path/to/depot_tools:
andybonsad92aa32015-08-31 02:27:4428
dpranke0ae7cad2016-11-30 07:47:5829 $ export PATH=$PATH:/path/to/depot_tools
andybons3322f762015-08-24 21:37:0930
dpranke0ae7cad2016-11-30 07:47:5831## Get the code
andybonsad92aa32015-08-31 02:27:4432
dpranke0ae7cad2016-11-30 07:47:5833Create a chromium directory for the checkout and change to it (you can call
34this whatever you like and put it wherever you like, as
35long as the full path has no spaces):
36
37 $ mkdir chromium
38 $ cd chromium
andybons3322f762015-08-24 21:37:0939
dpranke0ae7cad2016-11-30 07:47:5840Run the `fetch` tool from depot_tools to check out the code and its
41dependencies.
andybonsad92aa32015-08-31 02:27:4442
dpranke0ae7cad2016-11-30 07:47:5843 $ fetch --nohooks chromium
andybonsad92aa32015-08-31 02:27:4444
dpranke0ae7cad2016-11-30 07:47:5845If you don't want the full repo history, you can save a lot of time by
46adding the `--no-history` flag to fetch.
andybons3322f762015-08-24 21:37:0947
dpranke0ae7cad2016-11-30 07:47:5848Expect the command to take 30 minutes on even a fast connection, and many
49hours on slower ones.
andybonsad92aa32015-08-31 02:27:4450
dpranke0ae7cad2016-11-30 07:47:5851If you've already installed the build dependencies on the machine (from another
52checkout, for example), you can omit the `--nohooks` flag and fetch
53will automatically execute `gclient runhooks` at the end.
andybons3322f762015-08-24 21:37:0954
dpranke0ae7cad2016-11-30 07:47:5855When fetch completes, it will have created a directory called `src`.
56The remaining instructions assume you are now in that directory:
andybons3322f762015-08-24 21:37:0957
dpranke0ae7cad2016-11-30 07:47:5858 $ cd src
andybons3322f762015-08-24 21:37:0959
dpranke0ae7cad2016-11-30 07:47:5860### Install additional build dependencies
andybons3322f762015-08-24 21:37:0961
dpranke0ae7cad2016-11-30 07:47:5862Once you have checked out the code, and assuming you're using Ubuntu, run
63[build/install-build-deps.sh](/build/install-build-deps.sh)
andybons3322f762015-08-24 21:37:0964
dpranke0ae7cad2016-11-30 07:47:5865Here are some instructions for what to do instead for
andybons3322f762015-08-24 21:37:0966
dpranke0ae7cad2016-11-30 07:47:5867* [Debian](linux_debian_build_instructions.md)
68* [Fedora](linux_fedora_build_instructions.md)
69* [Arch Linux](linux_arch_build_instructions.md)
70* [Open SUSE](linux_open_suse_build_instrctions.md)
71* [Mandriva](linux_mandriva_build_instrctions.md)
andybonsad92aa32015-08-31 02:27:4472
dpranke0ae7cad2016-11-30 07:47:5873For Gentoo, you can just run `emerge www-client/chromium`.
andybonsad92aa32015-08-31 02:27:4474
dpranke0ae7cad2016-11-30 07:47:5875### Run the hooks
andybons3322f762015-08-24 21:37:0976
dpranke0ae7cad2016-11-30 07:47:5877Once you've run `install-build-deps` at least once, you can now run the
78chromium-specific hooks, which will download additional binaries and other
79things you might need:
andybonsad92aa32015-08-31 02:27:4480
dpranke0ae7cad2016-11-30 07:47:5881 $ gclient runhooks
andybonsad92aa32015-08-31 02:27:4482
dpranke0ae7cad2016-11-30 07:47:5883*Optional*: You can also [install API keys](https://www.chromium.org/developers/how-tos/api-keys)
84if you want to talk to some of the Google services, but this is not necessary
85for most development and testing purposes.
andybons3322f762015-08-24 21:37:0986
dpranke0ae7cad2016-11-30 07:47:5887## Seting up the Build
andybonsad92aa32015-08-31 02:27:4488
dpranke0ae7cad2016-11-30 07:47:5889Chromium uses [Ninja](https://ninja-build.org) as its main build tool, and
90a tool called [GN](../tools/gn/docs/quick_start.md) to generate
91the .ninja files to do the build. To create a build directory, run:
andybons8c02a1f2015-09-04 17:02:3292
dpranke0ae7cad2016-11-30 07:47:5893 $ gn gen out/Default
94
95* You only have to do run this command once, it will self-update the build
96 files as needed after that.
97* You can replace `out/Default` with another directory name, but we recommend
98 it should still be a subdirectory of `out`.
99* To specify build parameters for GN builds, including release settings,
100 see [GN build configuration](https://www.chromium.org/developers/gn-build-configuration).
101 The default will be a debug component build matching the current host
102 operating system and CPU.
103* 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).
105
106### Faster builds
107
108See [faster builds on Linux](linux_faster_builds.md) for various tips and
109settings that may speed up your build.
110
111## Build Chromium
112
113Build Chromium (the "chrome" target) with Ninja using the command:
114
115 $ ninja -C out/Default chrome
116
117You can get a list of all of the other build targets from GN by running
118`gn ls out/Default` from the command line. To compile one, pass to Ninja
119the GN label with no preceding "//" (so for `//chrome/test:unit_tests`
120use ninja -C out/Default chrome/test:unit_tests`).
121
122## Run Chromium
123
124Once it is built, you can simply run the browser:
125
126 $ out/Default/chrome
127
128## Running test targets
129
130You can run the tests in the same way. You can also limit which tests are
131run using the `--gtest_filter` arg, e.g.:
132
133 $ ninja -C out/Default unit_tests --gtest_filter="PushClientTest.*"
134
135You can find out more about GoogleTest at its
136[GitHub page](https://github.com/google/googletest).
137
138## Update your checkout
139
140To update an existing checkout, you can run
141
142 $ git rebase-update
143 $ gclient sync
144
145The first command updates the primary Chromium source repository and rebases
146any of your local branches on top of tip-of-tree (aka the Git branch `origin/master`).
147If you don't want to use this script, you can also just use `git pull` or
148other common Git commands to update the repo.
149
150The second command syncs the subrepositories to the appropriate versions and
151re-runs the hooks as needed.
152
153## Tips, tricks, and troubleshooting
andybons3322f762015-08-24 21:37:09154
155### Linker Crashes
andybonsad92aa32015-08-31 02:27:44156
andybons3322f762015-08-24 21:37:09157If, during the final link stage:
andybonsad92aa32015-08-31 02:27:44158
brettwc25693b32016-05-26 01:11:52159 LINK out/Debug/chrome
andybonsad92aa32015-08-31 02:27:44160
andybons3322f762015-08-24 21:37:09161You get an error like:
andybons3322f762015-08-24 21:37:09162
brettwc25693b32016-05-26 01:11:52163 collect2: ld terminated with signal 6 Aborted terminate called after throwing an
164 instance of 'std::bad_alloc'
andybonsad92aa32015-08-31 02:27:44165
brettwc25693b32016-05-26 01:11:52166 collect2: ld terminated with signal 11 [Segmentation fault], core dumped
andybonsad92aa32015-08-31 02:27:44167
brettwc25693b32016-05-26 01:11:52168you are probably running out of memory when linking. You *must* use a 64-bit
169system to build. Try the following build settings (see [GN build
170configuration](https://www.chromium.org/developers/gn-build-configuration) for
171setting):
andybonsad92aa32015-08-31 02:27:44172
brettwc25693b32016-05-26 01:11:52173* Build in release mode (debugging symbols require more memory).
174 `is_debug = false`
175* Turn off symbols. `symbol_level = 0`
176* Build in component mode (this is for developers only, it will be slower and
177 may have broken functionality). `is_component_build = true`
andybons3322f762015-08-24 21:37:09178
dpranke0ae7cad2016-11-30 07:47:58179### More links
andybons3322f762015-08-24 21:37:09180
brettwc25693b32016-05-26 01:11:52181* Information about [building with Clang](clang.md).
dpranke0ae7cad2016-11-30 07:47:58182* You may want to [use a chroot](using_a_linux_chroot.md) to
183 isolate yourself from versioning or packaging conflicts.
andybonsad92aa32015-08-31 02:27:44184* Cross-compiling for ARM? See [LinuxChromiumArm](linux_chromium_arm.md).
185* Want to use Eclipse as your IDE? See
186 [LinuxEclipseDev](linux_eclipse_dev.md).
dpranke0ae7cad2016-11-30 07:47:58187* Want to use your built version as your default browser? See
andybonsad92aa32015-08-31 02:27:44188 [LinuxDevBuildAsDefaultBrowser](linux_dev_build_as_default_browser.md).
andybons3322f762015-08-24 21:37:09189
dpranke0ae7cad2016-11-30 07:47:58190### Next Steps
andybonsad92aa32015-08-31 02:27:44191
192If you want to contribute to the effort toward a Chromium-based browser for
193Linux, please check out the [Linux Development page](linux_development.md) for
194more information.