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
- 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
- Parsing the Email Standard with TypeBeat
- An OCaml Backend for Agda with Malfunctional Programming
- Databox Open-Source Software Community Launch
- Composable Builds for OCaml with Jbuilder
- MirageOS Hack Updates
- Algebraic Subtyping: PhD thesis