OLD | NEW |
1 # Build instructions for Linux | 1 # Linux-specific build instructions |
2 | 2 |
3 [TOC] | 3 [TOC] |
4 | 4 |
| 5 ## Get the code |
| 6 |
| 7 [Get the Code](http://dev.chromium.org/developers/how-tos/get-the-code). The |
| 8 general instructions on the "Get the code" page cover basic Linux build setup |
| 9 and configuration. |
| 10 |
| 11 This page documents some additional Linux-specific build issues. |
| 12 |
5 ## Overview | 13 ## Overview |
6 | 14 |
7 Due its complexity, Chromium uses a set of custom tools to check out and build. | 15 Due its complexity, Chromium uses a set of custom tools to check out and build. |
8 Here's an overview of the steps you'll run: | 16 Here's an overview of the steps you'll run: |
9 | 17 |
10 1. **gclient**. A checkout involves pulling nearly 100 different SVN | 18 1. **gclient**. A checkout involves pulling nearly 100 different SVN |
11 repositories of code. This process is managed with a tool called `gclient`. | 19 repositories of code. This process is managed with a tool called `gclient`. |
12 1. **gyp**. The cross-platform build configuration system is called `gyp`, and | 20 1. **GN** / **gyp**. Cross-platform build configuration systems (GYP is the |
13 on Linux it generates ninja build files. Running `gyp` is analogous to the | 21 older one, GN is the one being transitioned to). It generates ninja build |
14 `./configure` step seen in most other software. | 22 files. Running `gn`/`gyp` is analogous to the `./configure` step seen in |
| 23 most other software. |
15 1. **ninja**. The actual build itself uses `ninja`. A prebuilt binary is in | 24 1. **ninja**. The actual build itself uses `ninja`. A prebuilt binary is in |
16 `depot_tools` and should already be in your path if you followed the steps | 25 `depot_tools` and should already be in your path if you followed the steps |
17 to check out Chromium. | 26 to check out Chromium. |
18 1. We don't provide any sort of "install" step. | 27 1. We don't provide any sort of "install" step. |
19 1. You may want to [use a chroot](using_a_linux_chroot.md) to isolate yourself | 28 1. You may want to |
20 from versioning or packaging conflicts (or to run the layout tests). | 29 [use a chroot](http://code.google.com/p/chromium/wiki/UsingALinuxChroot) to |
| 30 isolate yourself from versioning or packaging conflicts (or to run the |
| 31 layout tests). |
21 | 32 |
22 ## Getting a checkout | 33 ## Getting a checkout |
23 | 34 |
24 * [Prerequisites](linux_build_instructions_prerequisites.md): what you need | 35 [Prerequisites](linux_build_instructions_prerequisites.md): what you need before |
25 before you build. | 36 you build. |
26 * [Get the Code](http://dev.chromium.org/developers/how-tos/get-the-code): | |
27 check out the source code. | |
28 | 37 |
29 *** note | 38 **Note**. If you are working on Chromium OS and already have sources in |
30 Note: if you are working on Chromium OS and already have sources in | |
31 `chromiumos/chromium`, you **must** run `chrome_set_ver --runhooks` to set the | 39 `chromiumos/chromium`, you **must** run `chrome_set_ver --runhooks` to set the |
32 correct dependencies. This step is otherwise performed by `gclient` as part of | 40 correct dependencies. This step is otherwise performed by `gclient` as part of |
33 your checkout. | 41 your checkout. |
34 *** | |
35 | |
36 ## First Time Build Bootstrap | |
37 | |
38 * Make sure your dependencies are up to date by running the | |
39 `install-build-deps.sh` script: | |
40 | |
41 .../chromium/src$ build/install-build-deps.sh | |
42 | |
43 * Before you build, you should also | |
44 [install API keys](https://sites.google.com/a/chromium.org/dev/developers/ho
w-tos/api-keys). | |
45 | |
46 ## `gyp` (configuring) | |
47 | |
48 After `gclient sync` finishes, it will run `gyp` automatically to generate the | |
49 ninja build files. For standard chromium builds, this automatic step is | |
50 sufficient and you can start [compiling](linux_build_instructions.md). | |
51 | |
52 To manually configure `gyp`, run `gclient runhooks` or run `gyp` directly via | |
53 `build/gyp_chromium`. See [Configuring the Build](https://code.google.com/p/chro
mium/wiki/CommonBuildTasks#Configuring_the_Build) for detailed `gyp` options. | |
54 | |
55 [GypUserDocumentation](https://code.google.com/p/gyp/wiki/GypUserDocumentation)
gives background on `gyp`, but is not necessary if you are just building Chromiu
m. | |
56 | |
57 ### Configuring `gyp` | |
58 | |
59 See [Configuring the Build](common_build_tasks.md) for details; most often | |
60 you'll be changing the `GYP_DEFINES` options, which is discussed here. | |
61 | |
62 `gyp` supports a minimal amount of build configuration via the `-D` flag. | |
63 | |
64 build/gyp_chromium -Dflag1=value1 -Dflag2=value2 | |
65 | |
66 You can store these in the `GYP_DEFINES` environment variable, separating flags | |
67 with spaces, as in: | |
68 | |
69 export GYP_DEFINES="flag1=value1 flag2=value2" | |
70 | |
71 After changing your `GYP_DEFINES` you need to rerun `gyp`, either implicitly via | |
72 `gclient sync` (which also syncs) or `gclient runhooks` or explicitly via | |
73 `build/gyp_chromium`. | |
74 | |
75 Note that quotes are not necessary for a single flag, but are useful for | |
76 clarity; `GYP_DEFINES=flag1=value1` is syntactically valid but can be confusing | |
77 compared to `GYP_DEFINES="flag1=value1"`. | |
78 | |
79 If you have various flags for various purposes, you may find it more legible to | |
80 break them up across several lines, taking care to include spaces, such as like | |
81 this: | |
82 | |
83 export GYP_DEFINES="flag1=value1 flag2=value2" | |
84 | |
85 or like this (allowing comments): | |
86 | |
87 export GYP_DEFINES="flag1=value1" # comment | |
88 GYP_DEFINES+=" flag2=value2" # another comment | |
89 | |
90 | |
91 ### Sample configurations | |
92 | |
93 * **gcc warnings**. By default we fail to build if there are any compiler | |
94 warnings. If you're getting warnings, can't build because of that, but just | |
95 want to get things done, you can specify `-Dwerror=` to turn that off: | |
96 | |
97 ```script | |
98 # one-off | |
99 build/gyp_chromium -Dwerror= | |
100 # via variable | |
101 export GYP_DEFINES="werror=" | |
102 build/gyp_chromium | |
103 ``` | |
104 | |
105 * **ChromeOS**. `-Dchromeos=1` builds the ChromeOS version of Chrome. This is | |
106 **not** all of ChromeOS (see | |
107 [the ChromiumOS](http://www.chromium.org/chromium-os) page for full build | |
108 instructions), this is just the slightly tweaked version of the browser that | |
109 runs on that system. Its not designed to be run outside of ChromeOS and some | |
110 features won't work, but compiling on your Linux desktop can be useful for | |
111 certain types of development and testing. | |
112 | |
113 ```shell | |
114 # one-off | |
115 build/gyp_chromium -Dchromeos=1 | |
116 # via variable | |
117 export GYP_DEFINES="chromeos=1" | |
118 build/gyp_chromium | |
119 ``` | |
120 | 42 |
121 ## Compilation | 43 ## Compilation |
122 | 44 |
123 The weird "`src/`" directory is an artifact of `gclient`. Start with: | 45 The weird "`src/`" directory is an artifact of `gclient`. Start with: |
124 | 46 |
125 $ cd src | 47 $ cd src |
126 | 48 |
127 ### Build just chrome | |
128 | |
129 $ ninja -C out/Debug chrome | |
130 | |
131 | |
132 ### Faster builds | 49 ### Faster builds |
133 | 50 |
134 See [Linux Faster Builds](linux_faster_builds.md) | 51 See [Linux Faster Builds](linux_faster_builds.md) |
135 | 52 |
136 ### Build every test | 53 ### Build every test |
137 | 54 |
138 $ ninja -C out/Debug | 55 $ ninja -C out/Debug |
139 | 56 |
140 The above builds all libraries and tests in all components. **It will take | 57 The above builds all libraries and tests in all components. **It will take |
141 hours.** | 58 hours.** |
(...skipping 11 matching lines...) Expand all Loading... |
153 | 70 |
154 Executables are written in `src/out/Debug/` for Debug builds, and | 71 Executables are written in `src/out/Debug/` for Debug builds, and |
155 `src/out/Release/` for Release builds. | 72 `src/out/Release/` for Release builds. |
156 | 73 |
157 ### Release mode | 74 ### Release mode |
158 | 75 |
159 Pass `-C out/Release` to the ninja invocation: | 76 Pass `-C out/Release` to the ninja invocation: |
160 | 77 |
161 $ ninja -C out/Release chrome | 78 $ ninja -C out/Release chrome |
162 | 79 |
163 | |
164 ### Seeing the commands | 80 ### Seeing the commands |
165 | 81 |
166 If you want to see the actual commands that ninja is invoking, add `-v` to the | 82 If you want to see the actual commands that ninja is invoking, add `-v` to the |
167 ninja invocation. | 83 ninja invocation. |
168 | 84 |
169 $ ninja -v -C out/Debug chrome | 85 $ ninja -v -C out/Debug chrome |
170 | 86 |
171 This is useful if, for example, you are debugging gyp changes, or otherwise need | 87 This is useful if, for example, you are debugging gyp changes, or otherwise need |
172 to see what ninja is actually doing. | 88 to see what ninja is actually doing. |
173 | 89 |
174 ### Clean builds | 90 ### Clean builds |
175 | 91 |
176 All built files are put into the `out/` directory, so to start over with a clean | 92 If you're using GN, you can clean the build directory (`out/Default` in this |
177 build, just | 93 example): |
| 94 |
| 95 gn clean out/Default |
| 96 |
| 97 This will delete all files except a bootstrap ninja file necessary for |
| 98 recreating the build. |
| 99 |
| 100 If you're using GYP, do: |
178 | 101 |
179 rm -rf out | 102 rm -rf out |
| 103 gclient runhooks |
180 | 104 |
181 and run `gclient runhooks` or `build\gyp_chromium` again to recreate the ninja | 105 Ninja can also be used to clean a build with `ninja -C out/Debug -t clean` but |
182 build files (which are also stored in `out/`). Or you can run `ninja -C | 106 this will not be as complete as the above methods. |
183 out/Debug -t clean`. | |
184 | 107 |
185 ### Linker Crashes | 108 ### Linker Crashes |
186 | 109 |
187 If, during the final link stage: | 110 If, during the final link stage: |
188 | 111 |
189 LINK(target) out/Debug/chrome | 112 LINK(target) out/Debug/chrome |
190 | 113 |
191 | |
192 You get an error like: | 114 You get an error like: |
193 | 115 |
194 ``` | 116 ``` |
195 collect2: ld terminated with signal 6 Aborted terminate called after throwing an | 117 collect2: ld terminated with signal 6 Aborted terminate called after throwing an |
196 instance of 'std::bad_alloc' | 118 instance of 'std::bad_alloc' |
197 | 119 |
198 collect2: ld terminated with signal 11 [Segmentation fault], core dumped | 120 collect2: ld terminated with signal 11 [Segmentation fault], core dumped |
199 ``` | 121 ``` |
200 | 122 you are probably running out of memory when linking. Try one of: |
201 you are probably running out of memory when linking. Try one of: | |
202 | 123 |
203 1. Use the `gold` linker | 124 1. Use the `gold` linker |
204 1. Build on a 64-bit computer | 125 1. Build on a 64-bit computer |
205 1. Build in Release mode (debugging symbols require a lot of memory) | 126 1. Build in Release mode (debugging symbols require a lot of memory) |
206 1. Build as shared libraries (note: this build is for developers only, and may | 127 1. Build as shared libraries (note: this build is for developers only, and may |
207 have broken functionality) | 128 have broken functionality) |
208 | 129 |
209 Most of these are described on the [LinuxFasterBuilds](linux_faster_builds.md) | 130 Most of these are described on the [Linux Faster Builds](linux_faster_builds.md) |
210 page. | 131 page. |
211 | 132 |
212 ## Advanced Features | 133 ## Advanced Features |
213 | 134 |
214 * Building frequently? See [LinuxFasterBuilds](linux_faster_builds.md). | 135 * Building frequently? See [LinuxFasterBuilds](linux_faster_builds.md). |
215 * Cross-compiling for ARM? See [LinuxChromiumArm](linux_chromium_arm.md). | 136 * Cross-compiling for ARM? See [LinuxChromiumArm](linux_chromium_arm.md). |
216 * Want to use Eclipse as your IDE? See | 137 * Want to use Eclipse as your IDE? See |
217 [LinuxEclipseDev](linux_eclipse_dev.md). | 138 [LinuxEclipseDev](linux_eclipse_dev.md). |
218 * Built version as Default Browser? See | 139 * Built version as Default Browser? See |
219 [LinuxDevBuildAsDefaultBrowser](linux_dev_build_as_default_browser.md). | 140 [LinuxDevBuildAsDefaultBrowser](linux_dev_build_as_default_browser.md). |
220 | 141 |
221 ## Next Steps | 142 ## Next Steps |
222 | 143 |
223 If you want to contribute to the effort toward a Chromium-based browser for | 144 If you want to contribute to the effort toward a Chromium-based browser for |
224 Linux, please check out the [Linux Development page](linux_development.md) for | 145 Linux, please check out the [Linux Development page](linux_development.md) for |
225 more information. | 146 more information. |
OLD | NEW |