V8 is built with the help of 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. The instructions below assume that you already have acheckout of V8.
First, you need GYP itself. On systems that have make (Linux, Mac, most other Unixes), this is as easy as:
make dependencies
Otherwise (e.g. on Windows), you need to get GYP manually. From the root of your V8 checkout, run:
svn co http://gyp.googlecode.com/svn/trunk build/gyp
Requires GNU make 3.81 or later. Should work with any GCC 4.x version.
The top-level Makefile defines a number of targets for each target architecture (ia32, x64, arm) and mode (debug or release). So your basic command for building is:
make ia32.release
or analogously for the other architectures and modes. You can build both debug and release binaries with just one command:
make ia32
To automatically build in release mode for the host architecture:
make native
You can also can build all architectures in a given mode at once:
make release
Or everything:
make
LD_LIBRARY_PATH=out/ia32.release/lib.target out/ia32.release/d8
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:
export CC=/path/to/clang export CXX=/path/to/clang++ export GYP_DEFINES="clang=1"
After that, you can simply call make with any target as discussed in the GCC + make section.
Similar to building with Clang, you can also use a cross-compiler. Just export your toolchain (CXX/LINK environment variables should be enough) and compile. For example:
export CXX=/path/to/cross-compile-g++ export LINK=/path/to/cross-compile-g++ make arm.release
From the root of your V8 checkout, run either of:
build/gyp_v8 -Dtarget_arch=ia32 build/gyp_v8 -Dtarget_arch=x64
This will generate Xcode project files in build/ that you can then either open with Xcode or compile directly from the command line:
xcodebuild -project build/all.xcodeproj -configuration Release xcodebuild -project build/all.xcodeproj
Note: If you have configured your GYP_GENERATORS environment variable, either unset it, or set it to xcode for this to work.
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:
On Windows, you need to install some additional dependencies first:
svn co http://src.chromium.org/svn/trunk/tools/third_party/python_26@89111 third_party/python_26
Either way, it is recommended to put python.exe into your PATH.
svn co http://src.chromium.org/svn/trunk/deps/third_party/cygwin@66844 third_party/cygwin
python build\gyp_v8
Specify the path to python.exe if you don't have it in your PATH. 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. Example:third_party/python_26/python.exe build\gyp_v8 -Dtarget_arch=x64
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):"c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" /build Release build\All.slnReplace Release with Debug to build in Debug mode. The built binaries will be in build\Release\ or build\Debug\.
build/gyp_v8
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!)
/cygdrive/c/Program\ Files\ (x86)/Microsoft\ Visual\ Studio\ 9.0/Common7/IDE/devenv.com /build Release build/all.sln
See the "custom build settings" section for Xcode above.
You can abuse the test driver's --buildbot flag to make it find the executables where MSVC puts them:
python tools/run-tests.py --buildbot --outdir build --arch ia32 --mode Release
Building on MinGW is not officially supported, but it is possible. You even have two options:
Requirements:
Building:
Running tests:
Requirements:
Building and testing:
If you have problems or questions, please file bugs at code.google.com/p/v8/issues or send mail to [email protected]. Comments on this page are likely to go unnoticed and unanswered.