Building with GN

Maya Lekova edited this page Jun 6, 2018 · 23 revisions
Clone this wiki locally

Build issues? File a bug at or ask for help on

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:


GN itself is distributed with depot_tools.


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/ x64.release

To run the tests right after the build, run:

tools/dev/ 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/ x64.debug mjsunit/foo cctest/test-bar/*

Build instructions (convenience workflow)

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

tools/dev/ x64.release

Call --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/ list

tools/dev/ list -m client.v8

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

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

Build instructions (raw workflow)

First, generate the necessary build files:

gn args

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 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 --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 --list


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

ninja -C

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

ninja -C d8


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

tools/ --outdir

You can also test your most recently compiled build (in

tools/ --gn