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 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 3 | **See also [the old version of this page](old_linux_build_instructions.md).** |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 4 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 5 | Google employee? See [go/building-chrome](https://goto.google.com/building-chrome) instead. |
andybons | 8c02a1f | 2015-09-04 17:02:32 | [diff] [blame] | 6 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 7 | [TOC] |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 8 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 9 | ## System requirements |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 10 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 11 | * 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. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 15 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 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. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 18 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 19 | ## Install `depot_tools` |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 20 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 21 | Clone the depot_tools repository: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 22 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 23 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 24 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 25 | 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 |
| 27 | to /path/to/depot_tools: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 28 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 29 | $ export PATH=$PATH:/path/to/depot_tools |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 30 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 31 | ## Get the code |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 32 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 33 | 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 |
| 35 | long as the full path has no spaces): |
| 36 | |
| 37 | $ mkdir chromium |
| 38 | $ cd chromium |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 39 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 40 | Run the `fetch` tool from depot_tools to check out the code and its |
| 41 | dependencies. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 42 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 43 | $ fetch --nohooks chromium |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 44 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 45 | 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. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 47 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 48 | Expect the command to take 30 minutes on even a fast connection, and many |
| 49 | hours on slower ones. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 50 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 51 | 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 |
| 53 | will automatically execute `gclient runhooks` at the end. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 54 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 55 | When fetch completes, it will have created a directory called `src`. |
| 56 | The remaining instructions assume you are now in that directory: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 57 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 58 | $ cd src |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 59 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 60 | ### Install additional build dependencies |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 61 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 62 | 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) |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 64 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 65 | Here are some instructions for what to do instead for |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 66 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 67 | * [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) |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 72 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 73 | For Gentoo, you can just run `emerge www-client/chromium`. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 74 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 75 | ### Run the hooks |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 76 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 77 | 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 |
| 79 | things you might need: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 80 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 81 | $ gclient runhooks |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 82 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 83 | *Optional*: You can also [install API keys](https://www.chromium.org/developers/how-tos/api-keys) |
| 84 | if you want to talk to some of the Google services, but this is not necessary |
| 85 | for most development and testing purposes. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 86 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 87 | ## Seting up the Build |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 88 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 89 | Chromium uses [Ninja](https://ninja-build.org) as its main build tool, and |
| 90 | a tool called [GN](../tools/gn/docs/quick_start.md) to generate |
| 91 | the .ninja files to do the build. To create a build directory, run: |
andybons | 8c02a1f | 2015-09-04 17:02:32 | [diff] [blame] | 92 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 93 | $ 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 | |
| 108 | See [faster builds on Linux](linux_faster_builds.md) for various tips and |
| 109 | settings that may speed up your build. |
| 110 | |
| 111 | ## Build Chromium |
| 112 | |
| 113 | Build Chromium (the "chrome" target) with Ninja using the command: |
| 114 | |
| 115 | $ ninja -C out/Default chrome |
| 116 | |
| 117 | You 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 |
| 119 | the GN label with no preceding "//" (so for `//chrome/test:unit_tests` |
| 120 | use ninja -C out/Default chrome/test:unit_tests`). |
| 121 | |
| 122 | ## Run Chromium |
| 123 | |
| 124 | Once it is built, you can simply run the browser: |
| 125 | |
| 126 | $ out/Default/chrome |
| 127 | |
| 128 | ## Running test targets |
| 129 | |
| 130 | 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.: |
| 132 | |
| 133 | $ ninja -C out/Default unit_tests --gtest_filter="PushClientTest.*" |
| 134 | |
| 135 | You can find out more about GoogleTest at its |
| 136 | [GitHub page](https://github.com/google/googletest). |
| 137 | |
| 138 | ## Update your checkout |
| 139 | |
| 140 | To update an existing checkout, you can run |
| 141 | |
| 142 | $ git rebase-update |
| 143 | $ gclient sync |
| 144 | |
| 145 | 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/master`). |
| 147 | If you don't want to use this script, you can also just use `git pull` or |
| 148 | other common Git commands to update the repo. |
| 149 | |
| 150 | The second command syncs the subrepositories to the appropriate versions and |
| 151 | re-runs the hooks as needed. |
| 152 | |
| 153 | ## Tips, tricks, and troubleshooting |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 154 | |
| 155 | ### Linker Crashes |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 156 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 157 | If, during the final link stage: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 158 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 159 | LINK out/Debug/chrome |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 160 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 161 | You get an error like: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 162 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 163 | collect2: ld terminated with signal 6 Aborted terminate called after throwing an |
| 164 | instance of 'std::bad_alloc' |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 165 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 166 | collect2: ld terminated with signal 11 [Segmentation fault], core dumped |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 167 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 168 | 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 |
| 170 | configuration](https://www.chromium.org/developers/gn-build-configuration) for |
| 171 | setting): |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 172 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 173 | * 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` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 178 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 179 | ### More links |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 180 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 181 | * Information about [building with Clang](clang.md). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 182 | * You may want to [use a chroot](using_a_linux_chroot.md) to |
| 183 | isolate yourself from versioning or packaging conflicts. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 184 | * 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). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 187 | * Want to use your built version as your default browser? See |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 188 | [LinuxDevBuildAsDefaultBrowser](linux_dev_build_as_default_browser.md). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 189 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame^] | 190 | ### Next Steps |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 191 | |
| 192 | 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 |
| 194 | more information. |