Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <font color='darkred'><b>Build issues? File a bug at code.google.com/p/v8/issues or ask for help on v8-users@googlegroups.com.</b></font> | |
| 2 | |
| 3 # Building V8 | |
| 4 | |
| 5 V8 is built with the help of [GYP](http://code.google.com/p/gyp/). GYP is a meta build system of sorts, as it generates build files for a number of other build systems. How you build therefore depends on what "back-end" build system and com piler you're using. | |
| 6 The instructions below assume that you already have a [checkout of V8](using_git .md) but haven't yet installed the build dependencies. | |
| 7 | |
| 8 If you intend to develop on V8, i.e., send patches and work with changelists, yo u will need to install the dependencies as described [here](using_git.md). | |
| 9 | |
| 10 | |
| 11 ## Prerequisite: Installing GYP | |
| 12 | |
| 13 First, you need GYP itself. GYP is fetched together with the other dependencies by running: | |
| 14 | |
| 15 ``` | |
| 16 gclient sync | |
| 17 ``` | |
| 18 | |
| 19 ## Building | |
| 20 | |
| 21 ### GCC + make | |
| 22 | |
| 23 Requires GNU make 3.81 or later. Should work with any GCC >= 4.8 or any recent c lang (3.5 highly recommended). | |
| 24 | |
| 25 #### Build instructions | |
| 26 | |
| 27 | |
| 28 The top-level Makefile defines a number of targets for each target architecture (`ia32`, `x64`, `arm`, `arm64`) and mode (`debug`, `optdebug`, or `release`). So your basic command for building is: | |
| 29 ``` | |
| 30 make ia32.release | |
| 31 ``` | |
| 32 | |
| 33 or analogously for the other architectures and modes. You can build both debug a nd release binaries with just one command: | |
| 34 ``` | |
| 35 make ia32 | |
| 36 ``` | |
| 37 | |
| 38 To automatically build in release mode for the host architecture: | |
| 39 ``` | |
| 40 make native | |
| 41 ``` | |
| 42 | |
| 43 You can also can build all architectures in a given mode at once: | |
| 44 ``` | |
| 45 make release | |
| 46 ``` | |
| 47 | |
| 48 Or everything: | |
| 49 ``` | |
| 50 make | |
| 51 ``` | |
| 52 | |
| 53 #### Optional parameters | |
| 54 | |
| 55 * `-j` specifies the number of parallel build processes. Set it (roughly) to t he number of CPU cores your machine has. The GYP/make based V8 build also suppor ts distcc, so you can compile with `-j100` or so, provided you have enough machi nes around. | |
| 56 | |
| 57 * `OUTDIR=foo` specifies where the compiled binaries go. It defaults to `./out /`. In this directory, a subdirectory will be created for each architecture and mode. You will find the d8 shell's binary in `foo/ia32.release/d8`, for example. | |
| 58 | |
| 59 * `library=shared` or `component=shared_library` (the two are completely equiv alent) builds V8 as a shared library (`libv8.so`). | |
| 60 | |
| 61 * `soname_version=1.2.3` is only relevant for shared library builds and config ures the SONAME of the library. Both the SONAME and the filename of the library will be `libv8.so.1.2.3` if you specify this. Due to a peculiarity in GYP, if yo u specify a custom SONAME, the library's path will no longer be encoded in the b inaries, so you'll have to run d8 as follows: | |
| 62 ``` | |
| 63 LD_LIBRARY_PATH=out/ia32.release/lib.target out/ia32.release/d8 | |
| 64 ``` | |
| 65 | |
| 66 * `console=readline` enables readline support for the d8 shell. You need readl ine development headers for this (`libreadline-dev` on Ubuntu). | |
| 67 | |
| 68 * `disassembler=on` enables the disassembler for release mode binaries (it's a lways enabled for debug binaries). This is useful if you want to inspect generat ed machine code. | |
| 69 | |
| 70 * `snapshot=off` disables building with a heap snapshot. Compiling will be a l ittle faster, but V8’s start up will be slightly slower. | |
| 71 | |
| 72 * `gdbjit=on` enables GDB JIT support. | |
| 73 | |
| 74 * `liveobjectlist=on` enables the Live Object List feature. | |
| 75 | |
| 76 * `vfp3=off` is only relevant for ARM builds with snapshot and disables the us e of VFP3 instructions in the snapshot. | |
| 77 | |
| 78 * `debuggersupport=off` disables the javascript debugger. | |
| 79 | |
| 80 * `werror=no` omits the -Werror flag. This is especially useful for not offici ally supported C++ compilers (e.g. newer versions of the GCC) so that compile wa rnings are ignored. | |
| 81 | |
| 82 * `strictaliasing=off` passes the -fno-strict-aliasing flag to GCC. This may h elp to work around build failures on officially unsupported platforms and/or GCC versions. | |
| 83 | |
| 84 * `regexp=interpreted` chooses the interpreted mode of the irregexp regular ex pression engine instead of the native code mode. | |
| 85 | |
| 86 * `hardfp=on` creates "hardfp" binaries on ARM. | |
| 87 | |
| 88 ### Ninja | |
| 89 | |
| 90 To build d8: | |
| 91 ``` | |
| 92 export GYP_GENERATORS=ninja | |
| 93 build/gyp_v8 | |
| 94 ninja -C out/Debug d8 | |
| 95 ``` | |
| 96 | |
| 97 Specify `out/Release` for a release build. I recommend setting up an alias so th at you don't need to type out that build directory path. | |
| 98 | |
| 99 If you want to build all targets, use `ninja -C out/Debug all`. It's faster to b uild only the target you're working on, like `d8` or `unittests`. | |
| 100 | |
| 101 Note: You need to set `v8_target_arch` if you want a non-native build, i.e. eith er | |
| 102 ``` | |
| 103 export GYP_DEFINES="v8_target_arch=arm" | |
| 104 build/gyp_v8 ... | |
| 105 ``` | |
| 106 or | |
| 107 ``` | |
| 108 build/gyp_v8 -Dv8_target_arch=arm ... | |
| 109 ``` | |
| 110 | |
| 111 | |
| 112 #### Using goma (Googlers only) | |
| 113 | |
| 114 To use goma you need to set the `use_goma` gyp define, either by passing it to ` gyp_v8`, i.e. | |
| 115 ``` | |
| 116 build/gyp_v8 -Duse_goma=1 | |
| 117 ``` | |
| 118 or by setting the environment variable `$GYP_DEFINES` appropriately: | |
| 119 ``` | |
| 120 export GYP_DEFINES="use_goma=1" | |
| 121 ``` | |
| 122 Note: You may need to also set `gomadir` to point to the directory where you ins talled goma, if it's not in the default location. | |
| 123 | |
| 124 If you are using goma, you'll also want to bump the job limit, i.e. | |
| 125 ``` | |
| 126 ninja -j 100 -C out/Debug d8 | |
| 127 ``` | |
| 128 | |
| 129 | |
| 130 ### Cross-compiling | |
| 131 | |
| 132 Similar to building with Clang, you can also use a cross-compiler. Just export y our toolchain (`CXX`/`LINK` environment variables should be enough) and compile. For example: | |
| 133 ``` | |
| 134 export CXX=/path/to/cross-compile-g++ | |
| 135 export LINK=/path/to/cross-compile-g++ | |
| 136 make arm.release | |
| 137 ``` | |
| 138 | |
| 139 | |
| 140 ### Xcode | |
| 141 | |
| 142 From the root of your V8 checkout, run either of: | |
| 143 ``` | |
| 144 build/gyp_v8 -Dtarget_arch=ia32 | |
| 145 build/gyp_v8 -Dtarget_arch=x64 | |
| 146 ``` | |
| 147 | |
| 148 This will generate Xcode project files in `build/` that you can then either open with Xcode or compile directly from the command line: | |
| 149 ``` | |
| 150 xcodebuild -project build/all.xcodeproj -configuration Release | |
| 151 xcodebuild -project build/all.xcodeproj | |
| 152 ``` | |
| 153 | |
| 154 Note: If you have configured your `GYP_GENERATORS` environment variable, either unset it, or set it to `xcode` for this to work. | |
| 155 | |
| 156 | |
| 157 #### Custom build settings | |
| 158 | |
| 159 You can export the `GYP_DEFINES` environment variable in your shell to configure custom build options. The syntax is `GYP_DEFINES="-Dvariable1=value1 -Dvariable 2=value2"` and so on for as many variables as you wish. Possibly interesting opt ions include: | |
| 160 * `-Dcomponent=shared_library` (see `library=shared` in the [GCC + make](#Opti onal_parameters.md) section above) | |
| 161 * `-Dconsole=readline` (see `console=readline`) | |
| 162 * `-Dv8_enable_disassembler=1` (see `disassembler=on`) | |
| 163 * `-Dv8_use_snapshot='false'` (see `snapshot=off`) | |
| 164 * `-Dv8_enable_gdbjit=1` (see `gdbjit=on`) | |
| 165 * `-Dv8_use_liveobjectlist=true` (see `liveobjectlist=on`) | |
| 166 | |
| 167 | |
| 168 ### Visual Studio | |
| 169 | |
| 170 You need Visual Studio 2013, older versions might still work at the moment, but this will probably change soon because we intend to use C++11 features. | |
| 171 | |
| 172 #### Prerequisites | |
| 173 | |
| 174 After you created [checkout of V8](using_git.md), all dependencies will be alrea dy installed. | |
| 175 | |
| 176 If you are getting errors during build mentioning that 'python' could not be fou nd, add the 'python.exe' to PATH. | |
| 177 | |
| 178 If you have Visual Studio 2013 and 2015 installed side-by-side and set the envir onment variable GYP\_MSVS\_VERSION to '2013'. In that case the right project fil es are going to be created. | |
| 179 | |
| 180 #### Building | |
| 181 * If you use the command prompt: | |
| 182 1. Generate project files: | |
| 183 ``` | |
| 184 python build\gyp_v8 | |
| 185 ``` | |
| 186 > > > Specify the path to `python.exe` if you don't have it in your PATH. | |
| 187 > > > Append `-Dtarget_arch=x64` if you want to build 64bit binaries. If you swi tch between ia32 and x64 targets, you may have to manually delete the generated .vcproj/.sln files before regenerating them. | |
| 188 > > > Example: | |
| 189 ``` | |
| 190 third_party/python_26/python.exe build\gyp_v8 -Dtarget_arch=x64 | |
| 191 ``` | |
| 192 1. Build: | |
| 193 > > > Either open `build\All.sln` in Visual Studio, or compile on the command li ne as follows (adapt the path as necessary, or simply put `devenv.com` in your P ATH): | |
| 194 ``` | |
| 195 "c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" /bui ld Release build\All.sln | |
| 196 ``` | |
| 197 > > > Replace `Release` with `Debug` to build in Debug mode. | |
| 198 > > > The built binaries will be in build\Release\ or build\Debug\. | |
| 199 | |
| 200 * If you use cygwin, the workflow is the same, but the syntax is slightly diff erent: | |
| 201 1. Generate project files: | |
| 202 ``` | |
| 203 build/gyp_v8 | |
| 204 ``` | |
| 205 > > > This will spit out a bunch of warnings about missing input files, but it s eems to be OK to ignore them. (If you have time to figure this out, we'd happily accept a patch that makes the warnings go away!) | |
| 206 1. Build: | |
| 207 ``` | |
| 208 /cygdrive/c/Program\ Files\ (x86)/Microsoft\ Visual\ Studio\ 9.0/Common7/IDE/dev env.com /build Release build/all.sln | |
| 209 ``` | |
| 210 | |
| 211 | |
| 212 #### Custom build settings | |
| 213 | |
| 214 See the "custom build settings" section for [Xcode](#Xcode.md) above. | |
|
Michael Achenbach
2015/09/28 14:40:13
s/(#Xcode.md)/(#Xcode)
| |
| 215 | |
| 216 | |
| 217 #### Running tests | |
| 218 | |
| 219 You can abuse the test driver's --buildbot flag to make it find the executables where MSVC puts them: | |
| 220 ``` | |
| 221 python tools/run-tests.py --buildbot --outdir build --arch ia32 --mode Release | |
| 222 ``` | |
| 223 | |
| 224 | |
| 225 ### MinGW | |
| 226 | |
| 227 Building on MinGW is not officially supported, but it is possible. You even have two options: | |
| 228 | |
| 229 #### Option 1: With Cygwin Installed | |
| 230 | |
| 231 Requirements: | |
| 232 * MinGW | |
| 233 * Cygwin, including Python | |
| 234 * Python from www.python.org _(yes, you need two Python installations!)_ | |
| 235 | |
| 236 Building: | |
| 237 1. Open a MinGW shell | |
| 238 1. `export PATH=$PATH:/c/cygwin/bin` _(or wherever you installed Cygwin)_ | |
| 239 1. `make ia32.release -j8` | |
| 240 | |
| 241 Running tests: | |
| 242 1. Open a MinGW shell | |
| 243 1. `export PATH=/c/Python27:$PATH` _(or wherever you installed Python)_ | |
| 244 1. `make ia32.release.check -j8` | |
| 245 | |
| 246 #### Option 2: Without Cygwin, just MinGW | |
| 247 | |
| 248 Requirements: | |
| 249 * MinGW | |
| 250 * Python from www.python.org | |
| 251 | |
| 252 Building and testing: | |
| 253 1. Open a MinGW shell | |
| 254 1. `tools/mingw-generate-makefiles.sh` _(re-run this any time a `*`.gyp`*` fil e changed, such as after updating your checkout)_ | |
| 255 1. `make ia32.release` _(unfortunately -jX doesn't seem to work here)_ | |
| 256 1. `make ia32.release.check -j8` | |
| 257 | |
| 258 | |
| 259 # Final Note | |
| 260 <font color='darkred'><b>If you have problems or questions, please file bugs at code.google.com/p/v8/issues or send mail to v8-users@googlegroups.com. Comments on this page are likely to go unnoticed and unanswered.</b></font> | |
| OLD | NEW |