Skip to main content
The Dart VM runs on a variety of ARM and RISC-V processors on Linux and Android. This guide explains how to build the Dart VM and SDK to target these platforms.
You must follow the steps in Building from Source to set up the environment and properly fetch the source code. Cloning the repository or obtaining the source code through other means will not result in a successful build.

Cross-Compilation Overview

The build scripts download a Clang toolchain that can target X64, ARM, ARM64, or RISC-V64 and run on an X64 or ARM64 host.
For most cases, you do not need to install a cross-compiler yourself. The build system handles this automatically.
You only need to manually install a toolchain for:
  • Building on a RISC-V64 host
  • Targeting RISC-V32
  • Using a custom toolchain

Installing Cross-Compilers

Linux (Debian/Ubuntu)

If you prefer to use the system toolchain or need a specific configuration, install the cross-compilers:
# To target x64
sudo apt-get install g++-x86-64-linux-gnu

# To target arm
sudo apt-get install g++-arm-linux-gnueabihf

# To target arm64
sudo apt-get install g++-aarch64-linux-gnu

# To target riscv64
sudo apt-get install g++-riscv64-linux-gnu

Android

For Android targets, follow the setup in Building for Android.

Building for ARM and RISC-V

Using Default Toolchain (Clang)

The simplest approach uses the automatically downloaded Clang toolchain:
./tools/build.py --mode release --arch arm create_sdk

Using System Toolchain (GCC)

If you’ve installed system cross-compilers, use the --no-clang flag:
./tools/build.py --no-clang --mode release --arch arm create_sdk

Using Custom Toolchain

To use a different toolchain, specify the prefix with the -t flag:
./tools/build.py --no-clang -m release -a arm \
  -t arm=/path/to/toolchain/prefix \
  create_sdk
If the path to your gcc is /path/to/toolchain/prefix-gcc, use /path/to/toolchain/prefix as the toolchain prefix.

Building Runtime Only

For faster builds when you only need the VM runtime:
./tools/build.py --mode release --arch arm64 runtime
This builds only the Dart VM runtime without the full SDK. The process also builds a VM that targets x64, which is used to generate some SDK components.

Building for Android

The standalone Dart VM can also target Android:
./tools/build.py --mode=release --arch=arm --os=android create_sdk
See Building for Android for complete Android setup instructions.

Building Debian Packages

You can create Debian packages for multiple architectures in a single build:
./tools/build.py --mode=release --arch=arm,arm64,riscv64 debian_package
This creates .deb packages for all specified architectures.

Testing Cross-Compiled Builds

You can test cross-compiled builds even without the target hardware using QEMU.

Testing RISC-V Builds

1

Build the SDK and tests

Cross-compile the RISC-V64 SDK and test targets:
./tools/build.py --mode release --arch riscv64 create_sdk
./tools/build.py --mode release --arch riscv64 most run_ffi_unit_tests
2

Install QEMU

Install QEMU user-mode emulation:
sudo apt install qemu-user qemu-user-static qemu-system
3

Run tests with QEMU

Set the QEMU library path and run tests:
export QEMU_LD_PREFIX=/usr/riscv64-linux-gnu

./tools/test.py \
  --runtime vm \
  --progress color \
  --arch riscv64 \
  --mode release \
  --time \
  --tasks 8 \
  lib

Simplified QEMU Testing

If QEMU is properly configured, you can use the --use-qemu flag:
./tools/test.py -r vm -m release -a riscv64 --use-qemu lib
This automatically handles QEMU setup for cross-architecture testing.

Build Output Locations

Cross-compiled builds are placed in architecture-specific directories:
out/ReleaseARM/dart-sdk

Multi-Architecture Builds

You can build for multiple architectures in sequence:
# Build for multiple architectures
./tools/build.py --mode=release --arch=arm create_sdk
./tools/build.py --mode=release --arch=arm64 create_sdk
./tools/build.py --mode=release --arch=riscv64 create_sdk
Each build goes to its own output directory, so they don’t conflict.

Common Issues

If you’re using --no-clang and get toolchain errors:
  1. Verify the cross-compiler is installed:
    dpkg -l | grep g++-arm
    
  2. Check the compiler is in your PATH:
    which arm-linux-gnueabihf-g++
    
  3. Install missing cross-compilers as shown above.
If QEMU tests fail:
  1. Ensure QEMU is installed:
    qemu-riscv64 --version
    
  2. Set the correct library prefix:
    export QEMU_LD_PREFIX=/usr/riscv64-linux-gnu
    
  3. Verify the prefix directory exists and contains libraries:
    ls -la $QEMU_LD_PREFIX/lib
    
Make sure you’ve set up Android dependencies:
  1. Update your .gclient file:
    "custom_vars": {
      "download_android_deps": True,
    },
    
  2. Sync dependencies:
    gclient sync
    
  3. See Building for Android for details.

Development Workflow

For RISC-V and ARM development without target hardware:
1

Make code changes

Edit source code on your development machine.
2

Cross-compile

Build for your target architecture:
./tools/build.py --mode release --arch riscv64 most run_ffi_unit_tests
3

Test with QEMU

Verify correctness using QEMU:
./tools/test.py -r vm -m release -a riscv64 --use-qemu lib
4

Test on hardware (optional)

For final verification, test on actual ARM/RISC-V hardware.

Next Steps

Android Builds

Build for Android devices and emulators

Testing

Learn about testing the Dart SDK

Build docs developers (and LLMs) love