Building with GN

Clemens Hammacher edited this page Aug 13, 2018 · 25 revisions

Build issues? File a bug at code.google.com/p/v8/issues or ask for help on v8-users@googlegroups.com.

Building V8

V8 is built with the help of GN. GN 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 a checkout of V8 but haven't yet installed the build dependencies.

If you intend to develop on V8, i.e., send patches and work with changelists, you’ll need to install the dependencies as described here.

More information on GN can be found in Chromium's documentation or GN's own.

Prerequisite: Build dependencies

All build dependencies are fetched by running:

gclient sync

(Only on linux, only needed once) Build dependencies are installed by running:

./build/install-build-deps.sh

GN itself is distributed with depot_tools.

Building

There are two workflows for building V8. A raw workflow using commands on a lower level and a convenience workflow using wrapper scripts. There is also convenience all-in-one script that generates build files, triggers the build and optionally also runs the tests.

Build instructions (all-in-one script)

To use the helper script for instance for x64.release configuration, run:

tools/dev/gm.py x64.release

To run the tests right after the build, run:

tools/dev/gm.py x64.release.check

This helper script outputs all commands it's executing, so one can easily track them and re-execute if necessary. Using the script it's also possible to build the required binaries and run specific tests with a single command:

tools/dev/gm.py x64.debug mjsunit/foo cctest/test-bar/*

Build instructions (convenience workflow)

Use a convenience script to generate your build files, e.g.:

tools/dev/v8gen.py x64.release

Call v8gen.py --help for more information. You can add an alias v8gen calling the script and also use it in other checkouts.

List available configurations (or bots from a master):

tools/dev/v8gen.py list

tools/dev/v8gen.py list -m client.v8

Build like a particular bot from waterfall client.v8 in folder foo:

tools/dev/v8gen.py -b "V8 Linux64 - debug builder" -m client.v8 foo

Build instructions (raw workflow)

First, generate the necessary build files:

gn args out.gn/foo

An editor will open for specifying the gn arguments. You can replace foo with an arbitrary directory name. Note that due to the conversion from gyp to gn, we use a separate out.gn folder, to not collide with old gyp folders. If you don't use gyp or keep your subfolders separate, you can also use out.

You can also pass the arguments on the command line:

gn gen out.gn/foo --args='is_debug=false target_cpu="x64" v8_target_cpu="arm64" use_goma=true'

This will generate build files for compiling V8 with the arm64 simulator in release mode using goma for compilation. For an overview of all available gn arguments run:

gn args out.gn/foo --list

Compilation

For building all of V8 run (assuming gn generated to the x64.release folder):

ninja -C out.gn/x64.release

To build specific targets like d8, add them to the command line:

ninja -C out.gn/x64.release d8

Testing

You can pass the output directory to the test driver. Other relevant flags will be inferred from the build:

tools/run-tests.py --outdir out.gn/foo

You can also test your most recently compiled build (in out.gn):

tools/run-tests.py --gn

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.