Based on Building Dart, Building Dart SDK for ARM processors and Building Dart SDK for Raspberry Pi.
Environment
- Ubuntu 16.04 LTS
- arm-linux-gnueabihf (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
- Dart SDK, master f6a2fb0050eeaf24706da66bdd73c2f3c9770f96
x86 toolchain
Pre-installed in Ubuntu (16.04 LTS).
ARM 32-bit toolchain
See Raspberry Pi: C++ cross-compiling .
ARM 64-bit toolchain
$ sudo apt-get install g++-aarch64-linux-gnu
Other build tools
$ sudo apt-get install g++ git make python
$ sudo apt-get install g++-multilib
Install Chromium depot_toops
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ export PATH="$PATH:$PWD/depot_tools"
Get the source
$ mkdir dart-sdk
$ cd dart-sdk
$ gclient config https://github.com/dart-lang/sdk.git
### Checkout HEAD
$ gclient sync
### Checkout a tag, e.g. 1.9.3
$ gclient sync --revision=1.9.3
Create (if missing) symbolic links
create_sdk build will fail if the following symbolic links are missing:
$ sudo ln -s /usr/include/x86_64-linux-gnu/asm/ /usr/include/asm
$ sudo ln -s /usr/include/x86_64-linux-gnu/bits/ /usr/include/bits
Build 64-bit x86
$ cd dart-sdk/sdk
$ ./tools/build.py --mode release --arch x64 create_sdk
Build 32-bit x86
$ cd dart-sdk/sdk
$ ./tools/build.py --mode release --arch ia32 create_sdk
Build for 32-bit ARM
$ cd dart-sdk/sdk
$ ./tools/build.py --mode release --arch arm create_sdk
The build fails (master #eb1839b):
g++ -MMD -MF x86/obj/runtime/bin/gen_snapshot_dart_io/eventhandler_linux.o.d -DDART_IO_SECURE_SOCKET_DISABLED -D_FORTIFY_SOURCE=2 -DNDEBUG -DTARGET_OS_LINUX -DTARGET_ARCH_ARM -DNDEBUG -DDART_USE_TCMALLOC -DDART_PRECOMPILER -I../../runtime -I../../third_party -I../.. -Ix86/gen -I../../third_party/tcmalloc/gperftools/src -I../../third_party/zlib -m32 -msse2 -mfpmath=sse -fno-exceptions -pthread -Wall -Wextra -Werror -Wendif-labels -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-local-typedefs -O3 -fno-ident -fdata-sections -ffunction-sections -g3 -ggdb3 -Werror -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wvla -Wno-conversion-null -Woverloaded-virtual -g3 -ggdb3 -fno-rtti -fno-exceptions -O3 -fvisibility-inlines-hidden -fno-omit-frame-pointer -fno-rtti -fno-exceptions -c ../../runtime/bin/eventhandler_linux.cc -o x86/obj/runtime/bin/gen_snapshot_dart_io/eventhandler_linux.o
In file included from ../../runtime/vm/simulator_arm.h:19:0,
from ../../runtime/vm/simulator.h:15,
from ../../runtime/vm/atomic.h:11,
from ../../runtime/bin/reference_counting.h:8,
from ../../runtime/bin/socket.h:14,
from ../../runtime/bin/eventhandler_linux.cc:27:
../../runtime/vm/constants_arm.h:263:17: error: ‘dart::STMP’ defined but not used [-Werror=unused-variable]
const SRegister STMP = EvenSRegisterOf(DTMP);
^
cc1plus: all warnings being treated as errors
ninja: build stopped: subcommand failed.
BUILD FAILED
This can be fixed by changing the dart-sdk/sdk/runtime/vm/constants_arm.h file, lines 262-263 from:
const DRegister DTMP = EvenDRegisterOf(QTMP);
const SRegister STMP = EvenSRegisterOf(DTMP);
to:
const DRegister DTMP __attribute__((unused)) = EvenDRegisterOf(QTMP);
const SRegister STMP __attribute__((unused)) = EvenSRegisterOf(DTMP);
Raspberry Pi note: This procedure will produce a useful Dart VM – the dart and pub utilities.
Pre-built 32-bit ARM Dart SDK image
$ wget http://share.geomodule.com/dart-sdk-f6a2fb0050eeaf24706da66bdd73c2f3c9770f96.tar.gz
Build for 64-bit ARM
$ cd dart-sdk/sdk
./tools/build.py --mode release --arch arm64 create_sd
Install Dart SDK on Raspberry Pi
Make sure you have correct version of the GLIBCXX library, see here:
http://sw-eng-notes.geomodule.com/2017/04/16/raspberry-pi-how-to-solve-version-glibcxx_6-0-21-not-found/
# On your build host host
$ cd dart-sdk
$ scp -r sdk/out/ReleaseXARM/dart-sdk pi@192.168.0.xxx:~/dart-sdk
# On Raspberry Pi
# Add the following line at the end of .bashrc
# export PATH=${PATH}:/home/pi/dart-sdk/bin
$ dart --version
Dart VM version: 1.24.0-edge.eb1839b8fd453b6c0c93376346743fa96db48440 (Sun Apr 16 18:04:59 2017) on "linux_arm"
$ pub --version
Pub 1.25.0-edge.511963d71509de50ac577ac22f3bac8d33c17e34