Skip to main content
This guide walks you through the complete process of building the Dart SDK from source code.
Before you begin, make sure you’ve installed all required dependencies.

Getting the Source

You must use fetch dart to get the source. Just cloning the GitHub repository or downloading a ZIP file will not work because the build requires additional dependencies managed by gclient.

For Googlers Only

Googlers: Add this to your ~/.gitconfig file before running fetch dart:
# Googlers need this in ~/.gitconfig or the checkout won't work correctly.
[url "sso://dart/"]
    insteadOf = https://dart.googlesource.com/
    insteadOf = https://dart-review.googlesource.com/
    insteadOf = http://dart.googlesource.com/
    insteadOf = http://dart-review.googlesource.com/

Fetch the Source

1

Create a directory for the SDK

You can use any directory name. This example uses dart-sdk:
mkdir dart-sdk
cd dart-sdk
2

Fetch the Dart source tree

fetch dart
This downloads the SDK repository and all its dependencies. It may take several minutes.
3

Navigate to the SDK directory

cd sdk
All build commands should be run from within the sdk directory.

Syncing Dependencies

The Dart SDK uses gclient to manage dependencies described in the DEPS file.
When you switch branches or update your SDK checkout, run gclient sync to bring dependencies in sync with the SDK version:
gclient sync

Building the SDK

1

Navigate to the SDK directory

Make sure you’re in the sdk directory:
cd sdk
2

Run the build script

Build the SDK in release mode:
./tools/build.py --mode release create_sdk
The build process may take 10-30 minutes depending on your system.
3

Locate the built SDK

After the build completes, find the SDK at:
  • Linux: out/ReleaseX64/dart-sdk
  • Windows: out/ReleaseX64/dart-sdk
  • macOS: xcodebuild/ReleaseARM64/dart-sdk

Build Options

Build Modes

The --mode (or -m) flag controls the optimization level:
./tools/build.py --mode debug create_sdk
  • debug: Includes debug symbols, no optimization (faster builds, slower runtime)
  • release: Optimized build (slower builds, faster runtime)
  • all: Builds both debug and release

Target Architecture

The --arch (or -a) flag specifies the target architecture:
./tools/build.py --arch x64 create_sdk
Supported architectures: x64, arm, arm64, riscv64

Build Targets

./tools/build.py --mode release create_sdk
Builds the complete Dart SDK with all tools and libraries.

Runtime Only

./tools/build.py --mode release runtime
Builds only the Dart VM runtime without SDK tools. This is faster but provides a limited development environment.

Most Targets

./tools/build.py --mode release most run_ffi_unit_tests
Builds most targets needed for comprehensive testing.

Testing Your Build

1

Build test targets

First, build the targets needed for testing:
./tools/build.py --mode release most run_ffi_unit_tests
2

Run the test suite

Run tests with the built SDK:
./tools/test.py -mrelease --runtime=vm corelib

Test Options

The test script supports various options:
./tools/test.py \
  --runtime vm \
  --progress color \
  --arch x64 \
  --mode release \
  --time \
  --tasks 6 \
  language
  • --runtime: Where to run tests (vm, d8, chrome, firefox, etc.)
  • --compiler: Compiler to use (dartk, dart2js, dart2analyzer)
  • --progress: Progress display style
  • --arch: Target architecture
  • --mode: Build mode to test
  • --time: Show timing information
  • --tasks: Number of parallel test tasks
Make sure to run tests using the same mode and architecture as your build.

Build Performance Tips

Use a Local File System

For faster builds, use a local file system for the output directory, especially if your source code is on NFS:
cd sdk/
mkdir -p /usr/local/dart-out/
ln -s -f /usr/local/dart-out/ out

Build Notifications

Get notified when long builds complete (macOS and Linux only):
export DART_BUILD_NOTIFICATION_DELAY=60  # Notify if build takes >60 seconds
Set this in your shell’s rc file to make it permanent.

Parallel Builds

The build system automatically uses available CPU cores. For testing, control parallelism with --tasks:
./tools/test.py --tasks 8 -mrelease --runtime=vm language

Troubleshooting

Build Fails Immediately

Ensure Python 3 is installed and in your PATH:
python3 --version
On Windows, make sure depot_tools/python.bat is first in your PATH.
Verify depot_tools is in your PATH:
which gclient  # Linux/macOS
where gclient  # Windows
If not found, add depot_tools to your PATH.
Run gclient sync to update all dependencies:
gclient sync

Visual Studio Issues (Windows)

For non-Googlers, set the environment variable:
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
Manually specify the Visual Studio version:
set gyp_msvs_version=2015
gclient runhooks
Specify the executable name:
python tools/build.py --executable=VSExpress.exe create_sdk

Browser Test Issues

Install required fonts for DumpRenderTree:See LayoutTestsLinux for font installation instructions.
Use xvfb to provide a virtual display:
xvfb-run ./tools/test.py --compiler=dart2js --runtime=drt
Or use SSH X tunneling, NX, or VNC.

Next Steps

ARM/RISC-V Builds

Build for ARM and RISC-V architectures

Android Builds

Build the Dart VM for Android devices

Fuchsia Builds

Build the Dart VM for Fuchsia OS

Contributing

Learn how to contribute to the Dart SDK

Build docs developers (and LLMs) love