I’ve been enjoying working with Reason, and looking at ways to combine ARM, Reason and Docker. Check out this tutorial on how to build Reason apps for an ARM target using the Docker for Mac beta program. Reason is packaged as a Docker image, so local installation is unnecessary, and Docker’s multiarch support means no need for cross-compilation - what a breeze!
I am using Docker for Mac, which is still under beta program. Using Docker for development has two important advantages over traditional cross-compilation. First, the Reason toolchain comes packaged as a Docker image and hence no local installation is necessary. Secondly, cross-compiler are often tricky to get right. Docker for Mac comes with multiarch support and hence removes the need for traditional cross-compilation.
First get the dockerfile for Reason toolchain and build the image.
$ mkdir /tmp/reason_arm
$ cd /tmp/reason_arm
$ docker build -t reason-arm .
All set! Let’s build a “Hello, World!” program.
$ mkdir /tmp/reason_arm_hello
$ cd /tmp/reason_arm_hello
$ echo 'print_endline "Hello, Reason!"' > hello.re
$ docker run -it -v `pwd`:/src reason-arm
$ cd /src
$ rebuild hello.native
The build artifacts are found in the host machines
$ file _build/hello.native
_build/hello.native: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped
We can now transfer the file to the cubietruck and run it. My
cubietruck’s IP address is
$ scp _build/hello.native firstname.lastname@example.org:
$ ssh email@example.com
Welcome to Linaro 13.04 (GNU/Linux 3.4.61+ armv7l)
Last login: Fri May 20 08:35:01 2016 from 192.168.0.3
- Intel Hyper-Threading Bug Uncovered by OCaml Developers
- Unsigned Integers as Built-In Types or as a Library?
- A Week of Platform Releases: Odig, Odoc, Opam Bundle and More!
- Why Jbuilder? Demonstration and Discussion
- OCaml Compiler Hacking May 2017 - Activity Summaries
- Opam 2.0.0 beta 3
- Multicore OCaml ARM64 Backend
- Cambio, OCaml and Karaoke at the MirageOS Marrakech Hack Retreat 2017
- Using Menhir to Build Grammar Attributes
- OCaml 4.04.1 Released