My favorites | Sign in
v8
Project Home Downloads Wiki Issues Source Code Search
Checkout   Browse   Changes  
Changes to /wiki/BuildingWithGYP.wiki
r11462 vs. r11867 Compare: vs.  Format:
Revision r11867
Go to: 
Project members, sign in to write a code review
/wiki/BuildingWithGYP.wiki   r11462 /wiki/BuildingWithGYP.wiki   r11867
1 #summary Instructions to build V8 using GYP 1 #summary Instructions to build V8 using GYP
2 2
3 <font color="darkred">*The instructions for the GYP build supersede the instructions for the SCons build, which will be deprecated soon. If the GYP build does not suit your needs, please file a bug at code.google.com/p/v8/issues or send mail to v8-users@googlegroups.com.*</font> 3 <font color="darkred">*The instructions for the GYP build supersede the instructions for the SCons build, which will be deprecated soon. If the GYP build does not suit your needs, please file a bug at code.google.com/p/v8/issues or send mail to v8-users@googlegroups.com.*</font>
4 4
5 =Building V8= 5 =Building V8=
6 6
7 V8 is built with the help of [http://code.google.com/p/gyp/ 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 compiler you're using. 7 V8 is built with the help of [http://code.google.com/p/gyp/ 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 compiler you're using.
8 The instructions below assume that you already have a [UsingGit checkout of V8]. 8 The instructions below assume that you already have a [UsingGit checkout of V8].
9 9
10 10
11 ==Prerequisite: Installing GYP== 11 ==Prerequisite: Installing GYP==
12 12
13 First, you need GYP itself. On systems that have make (Linux, Mac, cygwin, most other Unixes), this is as easy as: 13 First, you need GYP itself. On systems that have make (Linux, Mac, cygwin, most other Unixes), this is as easy as:
14 {{{ 14 {{{
15 make dependencies 15 make dependencies
16 }}} 16 }}}
17 Otherwise (e.g. on Windows), you need to get GYP manually. From the root of your V8 checkout, run: 17 Otherwise (e.g. on Windows), you need to get GYP manually. From the root of your V8 checkout, run:
18 {{{ 18 {{{
19 svn co http://gyp.googlecode.com/svn/trunk build/gyp 19 svn co http://gyp.googlecode.com/svn/trunk build/gyp
20 }}} 20 }}}
21 21
22 ==Building== 22 ==Building==
23 23
24 ===GCC + make=== 24 ===GCC + make===
25 25
26 ====Build instructions==== 26 ====Build instructions====
27 27
28 28
29 Building is configured in the top-level Makefile. It defines a number of targets for each target architecture ({{{ia32}}}, {{{x64}}}, {{{arm}}} which is the ARM simulator) and mode ({{{debug}}} or {{{release}}}). So your basic command for building is: 29 Building is configured in the top-level Makefile. It defines a number of targets for each target architecture ({{{ia32}}}, {{{x64}}}, {{{arm}}} which is the ARM simulator) and mode ({{{debug}}} or {{{release}}}). So your basic command for building is:
30 {{{ 30 {{{
31 make ia32.release 31 make ia32.release
32 }}} 32 }}}
33 33
34 or analogously for the other architectures and modes. You can build both debug and release binaries with just one command: 34 or analogously for the other architectures and modes. You can build both debug and release binaries with just one command:
35 {{{ 35 {{{
36 make ia32 36 make ia32
37 }}} 37 }}}
38 38
39 To automatically build in release mode for the host architecture: 39 To automatically build in release mode for the host architecture:
40 {{{ 40 {{{
41 make native 41 make native
42 }}} 42 }}}
43 43
44 You can also can build all architectures in a given mode at once: 44 You can also can build all architectures in a given mode at once:
45 {{{ 45 {{{
46 make release 46 make release
47 }}} 47 }}}
48 48
49 Or everything: 49 Or everything:
50 {{{ 50 {{{
51 make 51 make
52 }}} 52 }}}
53 53
54 ====Optional parameters==== 54 ====Optional parameters====
55 55
56 * {{{-j}}} specifies the number of parallel build processes. Set it (roughly) to the number of CPU cores your machine has. The GYP/make based V8 build also supports distcc, so you can compile with {{{-j100}}} or so, provided you have enough machines around. 56 * {{{-j}}} specifies the number of parallel build processes. Set it (roughly) to the number of CPU cores your machine has. The GYP/make based V8 build also supports distcc, so you can compile with {{{-j100}}} or so, provided you have enough machines around.
57 57
58 * {{{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 * {{{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.
59 59
60 * {{{library=shared}}} or {{{component=shared_library}}} (the two are completely equivalent) builds V8 as a shared library ({{{libv8.so}}}). 60 * {{{library=shared}}} or {{{component=shared_library}}} (the two are completely equivalent) builds V8 as a shared library ({{{libv8.so}}}).
61 61
62 * {{{soname_version=1.2.3}}} is only relevant for shared library builds and configures 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 you specify a custom SONAME, the library's path will no longer be encoded in the binaries, so you'll have to run d8 as follows: 62 * {{{soname_version=1.2.3}}} is only relevant for shared library builds and configures 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 you specify a custom SONAME, the library's path will no longer be encoded in the binaries, so you'll have to run d8 as follows:
63 {{{ 63 {{{
64 LD_LIBRARY_PATH=out/ia32.release/lib.target out/ia32.release/d8 64 LD_LIBRARY_PATH=out/ia32.release/lib.target out/ia32.release/d8
65 }}} 65 }}}
66 66
67 * {{{console=readline}}} enables readline support for the d8 shell. You need readline development headers for this ({{{libreadline-dev}}} on Ubuntu). 67 * {{{console=readline}}} enables readline support for the d8 shell. You need readline development headers for this ({{{libreadline-dev}}} on Ubuntu).
68 68
69 * {{{disassembler=on}}} enables the disassembler for release mode binaries (it's always enabled for debug binaries). This is useful if you want to inspect generated machine code. 69 * {{{disassembler=on}}} enables the disassembler for release mode binaries (it's always enabled for debug binaries). This is useful if you want to inspect generated machine code.
70 70
71 * {{{snapshot=off}}} disables building with a heap snapshot. Compiling will be a little faster, but V8’s start up will be slightly slower. 71 * {{{snapshot=off}}} disables building with a heap snapshot. Compiling will be a little faster, but V8’s start up will be slightly slower.
72 72
73 * {{{gdbjit=on}}} enables GDB JIT support. 73 * {{{gdbjit=on}}} enables GDB JIT support.
74 74
75 * {{{liveobjectlist=on}}} enables the Live Object List feature. 75 * {{{liveobjectlist=on}}} enables the Live Object List feature.
76 76
77 * {{{vfp3=off}}} is only relevant for ARM builds with snapshot and disables the use of VFP3 instructions in the snapshot. 77 * {{{vfp3=off}}} is only relevant for ARM builds with snapshot and disables the use of VFP3 instructions in the snapshot.
78 78
79 * {{{debuggersupport=off}}} disables the javascript debugger. 79 * {{{debuggersupport=off}}} disables the javascript debugger.
80 80
81 * {{{TESTJOBS=-j8}}} will run tests (see below) with 8 parallel jobs. Do not set this to a higher value than the number of CPU cores you have, or some tests will timeout (which counts as failure). 81 * {{{TESTJOBS=-j8}}} will run tests (see below) with 8 parallel jobs. Do not set this to a higher value than the number of CPU cores you have, or some tests will timeout (which counts as failure).
82 82
83 * {{{werror=no}}} omits the -Werror flag. This is especially useful for not officially supported C++ compilers (e.g. newer versions of the GCC) so that compile warnings are ignored. 83 * {{{werror=no}}} omits the -Werror flag. This is especially useful for not officially supported C++ compilers (e.g. newer versions of the GCC) so that compile warnings are ignored.
84 84
85 * {{{strictaliasing=off}}} passes the -fno-strict-aliasing flag to GCC. This may help to work around build failures on officially unsupported platforms and/or GCC versions. 85 * {{{strictaliasing=off}}} passes the -fno-strict-aliasing flag to GCC. This may help to work around build failures on officially unsupported platforms and/or GCC versions.
86 86
87 * {{{regexp=interpreted}}} use the interpreted regular expression engine instead of irregexp.
88
87 ====Testing:==== 89 ====Testing:====
88 90
89 You can append {{{.check}}} to any build target to have tests run for it, e.g. 91 You can append {{{.check}}} to any build target to have tests run for it, e.g.
90 {{{ 92 {{{
91 make ia32.release.check 93 make ia32.release.check
92 make ia32.check 94 make ia32.check
93 make release.check 95 make release.check
94 make check # builds and tests everything (no dot before "check"!) 96 make check # builds and tests everything (no dot before "check"!)
95 }}} 97 }}}
96 98
97 You can also run tests manually: 99 You can also run tests manually:
98 {{{ 100 {{{
99 tools/test-wrapper-gypbuild.py -j8 --arch-and-mode=ia32.release [--outdir=foo] 101 tools/test-wrapper-gypbuild.py -j8 --arch-and-mode=ia32.release [--outdir=foo]
100 }}} 102 }}}
101 103
102 Or you can run individual tests: 104 Or you can run individual tests:
103 {{{ 105 {{{
104 tools/test-wrapper-gypbuild.py --arch=ia32 cctest/test-heap/SymbolTable mjsunit/delete-in-eval 106 tools/test-wrapper-gypbuild.py --arch=ia32 cctest/test-heap/SymbolTable mjsunit/delete-in-eval
105 }}} 107 }}}
106 108
107 Run the script with {{{--help}}} to find out about its other options. --outdir defaults to {{{out}}}. 109 Run the script with {{{--help}}} to find out about its other options. --outdir defaults to {{{out}}}.
108 Expect this syntax to change slightly when we remove support for SCons and merge the wrapper with the original {{{tools/test.py}}} script. 110 Expect this syntax to change slightly when we remove support for SCons and merge the wrapper with the original {{{tools/test.py}}} script.
109 111
110 ===Clang + make=== 112 ===Clang + make===
111 113
112 Building with clang works on both Mac and Linux. You can use the same Makefile and instructions as when building with GCC, just a few extra steps are required first: 114 Building with clang works on both Mac and Linux. You can use the same Makefile and instructions as when building with GCC, just a few extra steps are required first:
113 {{{ 115 {{{
114 export CC=/path/to/clang 116 export CC=/path/to/clang
115 export CXX=/path/to/clang++ 117 export CXX=/path/to/clang++
116 export GYP_DEFINES="clang=1" 118 export GYP_DEFINES="clang=1"
117 }}} 119 }}}
118 After that, you can simply call {{{make}}} with any target as discussed in the [BuildingWithGYP#GCC_+_make GCC + make] section. 120 After that, you can simply call {{{make}}} with any target as discussed in the [BuildingWithGYP#GCC_+_make GCC + make] section.
119 121
120 122
121 ===Xcode=== 123 ===Xcode===
122 124
123 From the root of your V8 checkout, run either of: 125 From the root of your V8 checkout, run either of:
124 {{{ 126 {{{
125 build/gyp_v8 -Dtarget_arch=ia32 127 build/gyp_v8 -Dtarget_arch=ia32
126 build/gyp_v8 -Dtarget_arch=x64 128 build/gyp_v8 -Dtarget_arch=x64
127 }}} 129 }}}
128 130
129 This will generate Xcode project files in {{{build/}}} that you can then either open with Xcode or compile directly from the command line: 131 This will generate Xcode project files in {{{build/}}} that you can then either open with Xcode or compile directly from the command line:
130 {{{ 132 {{{
131 xcodebuild -project build/all.xcodeproj -configuration Release 133 xcodebuild -project build/all.xcodeproj -configuration Release
132 xcodebuild -project build/all.xcodeproj 134 xcodebuild -project build/all.xcodeproj
133 }}} 135 }}}
134 136
135 Note: If you have configured your {{{GYP_GENERATORS}}} environment variable, either unset it, or set it to {{{xcode}}} for this to work. 137 Note: If you have configured your {{{GYP_GENERATORS}}} environment variable, either unset it, or set it to {{{xcode}}} for this to work.
136 138
137 139
138 ====Custom build settings==== 140 ====Custom build settings====
139 141
140 You can export the {{{GYP_DEFINES}}} environment variable in your shell to configure custom build options. The syntax is {{{GYP_DEFINES="-Dvariable1=value1 -Dvariable2=value2"}}} and so on for as many variables as you wish. Possibly interesting options include: 142 You can export the {{{GYP_DEFINES}}} environment variable in your shell to configure custom build options. The syntax is {{{GYP_DEFINES="-Dvariable1=value1 -Dvariable2=value2"}}} and so on for as many variables as you wish. Possibly interesting options include:
141 * {{{-Dcomponent=shared_library}}} (see {{{library=shared}}} in the [#Optional_parameters GCC + make] section above) 143 * {{{-Dcomponent=shared_library}}} (see {{{library=shared}}} in the [#Optional_parameters GCC + make] section above)
142 * {{{-Dconsole=readline}}} (see {{{console=readline}}}) 144 * {{{-Dconsole=readline}}} (see {{{console=readline}}})
143 * {{{-Dv8_enable_disassembler=1}}} (see {{{disassembler=on}}}) 145 * {{{-Dv8_enable_disassembler=1}}} (see {{{disassembler=on}}})
144 * {{{-Dv8_use_snapshot='false'}}} (see {{{snapshot=off}}}) 146 * {{{-Dv8_use_snapshot='false'}}} (see {{{snapshot=off}}})
145 * {{{-Dv8_enable_gdbjit=1}}} (see {{{gdbjit=on}}}) 147 * {{{-Dv8_enable_gdbjit=1}}} (see {{{gdbjit=on}}})
146 * {{{-Dv8_use_liveobjectlist=true}}} (see {{{liveobjectlist=on}}}) 148 * {{{-Dv8_use_liveobjectlist=true}}} (see {{{liveobjectlist=on}}})
147 149
148 150
149 ===Visual Studio=== 151 ===Visual Studio===
150 152
151 ====Prerequisites==== 153 ====Prerequisites====
152 154
153 On Windows, you need to install some additional dependencies first: 155 On Windows, you need to install some additional dependencies first:
154 * Python. You have several options: 156 * Python. You have several options:
155 * Use the Windows installer from http://python.org/download 157 * Use the Windows installer from http://python.org/download
156 * Check out the version provided by Chromium: 158 * Check out the version provided by Chromium:
157 {{{ 159 {{{
158 svn co http://src.chromium.org/svn/trunk/tools/third_party/python_26@89111 third_party/python_26 160 svn co http://src.chromium.org/svn/trunk/tools/third_party/python_26@89111 third_party/python_26
159 }}} 161 }}}
160 * Use a cygwin shell instead of the normal Windows command prompt. 162 * Use a cygwin shell instead of the normal Windows command prompt.
161 Either way, it is recommended to put python.exe into your PATH. 163 Either way, it is recommended to put python.exe into your PATH.
162 * The Chromium-provided cygwin installation: 164 * The Chromium-provided cygwin installation:
163 {{{ 165 {{{
164 svn co http://src.chromium.org/svn/trunk/deps/third_party/cygwin@66844 third_party/cygwin 166 svn co http://src.chromium.org/svn/trunk/deps/third_party/cygwin@66844 third_party/cygwin
165 }}} 167 }}}
166 168
167 ====Building==== 169 ====Building====
168 * If you use the command prompt: 170 * If you use the command prompt:
169 # Generate project files: 171 # Generate project files:
170 {{{ 172 {{{
171 python build\gyp_v8 173 python build\gyp_v8
172 }}} 174 }}}
173 Specify the path to `python.exe` if you don't have it in your PATH. 175 Specify the path to `python.exe` if you don't have it in your PATH.
174 Append `-Dtarget_arch=x64` if you want to build 64bit binaries (you will need a 64bit version of Visual Studio to do this). If you switch between ia32 and x64 targets, you may have to manually delete the generated .vcproj/.sln files before regenerating them. 176 Append `-Dtarget_arch=x64` if you want to build 64bit binaries (you will need a 64bit version of Visual Studio to do this). If you switch between ia32 and x64 targets, you may have to manually delete the generated .vcproj/.sln files before regenerating them.
175 Example: 177 Example:
176 {{{ 178 {{{
177 third_party/python_26/python.exe build\gyp_v8 -Dtarget_arch=x64 179 third_party/python_26/python.exe build\gyp_v8 -Dtarget_arch=x64
178 }}} 180 }}}
179 # Build: 181 # Build:
180 Either open `build\All.sln` in Visual Studio, or compile on the command line as follows (adapt the path as necessary, or simply put `devenv.com` in your PATH): 182 Either open `build\All.sln` in Visual Studio, or compile on the command line as follows (adapt the path as necessary, or simply put `devenv.com` in your PATH):
181 {{{ 183 {{{
182 "c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" /build Release build\All.sln 184 "c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" /build Release build\All.sln
183 }}} 185 }}}
184 Replace `Release` with `Debug` to build in Debug mode. 186 Replace `Release` with `Debug` to build in Debug mode.
185 The built binaries will be in build\Release\ or build\Debug\. 187 The built binaries will be in build\Release\ or build\Debug\.
186 188
187 * If you use cygwin, the workflow is the same, but the syntax is slightly different: 189 * If you use cygwin, the workflow is the same, but the syntax is slightly different:
188 # Generate project files: 190 # Generate project files:
189 {{{ 191 {{{
190 build/gyp_v8 192 build/gyp_v8
191 }}} 193 }}}
192 This will spit out a bunch of warnings about missing input files, but it seems 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!) 194 This will spit out a bunch of warnings about missing input files, but it seems 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!)
193 # Build: 195 # Build:
194 {{{ 196 {{{
195 /cygdrive/c/Program\ Files\ (x86)/Microsoft\ Visual\ Studio\ 9.0/Common7/IDE/devenv.com /build Release build/all.sln 197 /cygdrive/c/Program\ Files\ (x86)/Microsoft\ Visual\ Studio\ 9.0/Common7/IDE/devenv.com /build Release build/all.sln
196 }}} 198 }}}
197 199
198 200
199 ====Custom build settings==== 201 ====Custom build settings====
200 202
201 See the "custom build settings" section for [#Xcode Xcode] above. 203 See the "custom build settings" section for [#Xcode Xcode] above.
202 204
203 205
204 =Final Note= 206 =Final Note=
205 <font color="darkred">*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.*</font> 207 <font color="darkred">*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.*</font>
Powered by Google Project Hosting