LLVM-enabled Mono (F#) Docker image
This image is sourced from the Mono docker image.
See the documentation for that image for important information on using the LLVM from Mono.
By default, the
mono executable does not use the LLVM backend. You can enforce the use of LLVM
by using the
--llvm argument when invoking
mono or by setting the
variable as in the below example.
If you would like to AOT-compile the Global Assembly Cache, execute
This script will use the LLVM backend and attempt to perform a full Ahead-Of-Time compilation of
mscorlib.dll and all assemblies in the GAC. This can take some time, and will likely compile
several assemblies that you may not need, though you can follow its pattern to execute a targeted
compilation of assemblies. The core F# libraries and executables have already been AOT-compiled
for your convenience.
By default, the image will open the F# Interpreter and await input.
$ docker run --rm -i -t -e MONO_USE_LLVM=1 neoeinstein/fsharp-llvm
You can also invoke the interpreter to execute a file:
$ echo 'let img = "LLVM"' > qq.fsx $ echo 'printfn "Hello World from fsharpi with %s" img' >> qq.fsx $ docker run --rm -e MONO_USE_LLVM=1 -v "$(pwd)":/mnt neoeinstein/fsharp-llvm fsharpi --exec /mnt/qq.fsx
That same file can be compiled into an executable and run:
$ echo 'let img = "LLVM" in printfn "Hello World from fsharpc with %s" img' > qq.fs $ docker run --rm -e MONO_USE_LLVM=1 -v "$(pwd)":/mnt neoeinstein/fsharp-llvm sh -c "fsharpc -o:/mnt/qq.exe /mnt/qq.fs && mono /mnt/qq.exe"