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.
- 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: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:Using System Toolchain (GCC)
If you’ve installed system cross-compilers, use the--no-clang flag:
Using Custom Toolchain
To use a different toolchain, specify the prefix with the-t flag:
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:Building for Android
The standalone Dart VM can also target Android:See Building for Android for complete Android setup instructions.
Building Debian Packages
You can create Debian packages for multiple architectures in a single build:.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
Simplified QEMU Testing
If QEMU is properly configured, you can use the--use-qemu flag:
Build Output Locations
Cross-compiled builds are placed in architecture-specific directories:Multi-Architecture Builds
You can build for multiple architectures in sequence:Common Issues
Toolchain not found
Toolchain not found
If you’re using
--no-clang and get toolchain errors:-
Verify the cross-compiler is installed:
-
Check the compiler is in your PATH:
- Install missing cross-compilers as shown above.
QEMU tests fail
QEMU tests fail
If QEMU tests fail:
-
Ensure QEMU is installed:
-
Set the correct library prefix:
-
Verify the prefix directory exists and contains libraries:
Android build fails
Android build fails
Make sure you’ve set up Android dependencies:
-
Update your
.gclientfile: -
Sync dependencies:
- See Building for Android for details.
Development Workflow
For RISC-V and ARM development without target hardware:Next Steps
Android Builds
Build for Android devices and emulators
Testing
Learn about testing the Dart SDK