KC Sivaramakrishnan Research Associate @ OCaml Labs

Armed with Reason

This is a short tutorial on how to build Reason apps for an ARM target with the help of Docker. 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-compilers are often tricky to get right. Docker for Mac comes with multiarch support and hence removes the need for traditional cross-compilation.


I will be testing using a Cubietruck running Linaro Desktop. But these instructions should also work for Raspbian, a Debian optimized for the Raspberry pi hardware.


First get the dockerfile for Reason toolchain and build the image.

$ mkdir /tmp/reason_arm
$ cd /tmp/reason_arm
$ wget https://gist.githubusercontent.com/kayceesrk/dc37a6ffeeda2dea338550dd4e8ad7ec/raw/8e136b8b8170758bd5e9c0cacf70fed4f9ce3df1/Dockerfile
$ 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 /tmp/reason_arm_hello/_build directory.

$ 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 linaro@
$ ssh linaro@
Welcome to Linaro 13.04 (GNU/Linux 3.4.61+ armv7l)

* Documentation:  https://wiki.linaro.org/
Last login: Fri May 20 08:35:01 2016 from
linaro@cubietruck:~$ ./hello.native
Hello, Reason!