This repository contains tools to build a patched version of LLVM's flang-new
compiler that can be used to compile Fortran sources for WebAssembly. A pre-built Fortran runtime library is also built for WebAssembly using Emscripten.
-
A
Makefile
that downloads, builds and installs theflang-new
compiler from a patched LLVM source. Use thePREFIX
make variable to control the installation directory (default,"."
). Once installed, the$(PREFIX)/host/bin/
directory will containflang-new
. The$(PREFIX)/wasm/
directory will contain a pre-built Fortran runtime library compiled for WebAssembly, for use with Emscripten. -
A
Dockerfile
, which can be used to build a Docker container with LLVM Flang and the WebAssembly Fortran runtime library installed under the directory/opt/flang
. -
A Nix flake file,
flake.nix
, which can be used to build LLVM Flang and the WebAssembly Fortran runtime library as a Nix package.
The flang-new
compiler is used as part of the build process for webR to compile Fortran sources for WebAssembly. Compiling LLVM takes a long time and is fairly resource intensive. By building LLVM independently with a Docker container and/or Nix package, the result is cached and improves the performance of webR's CI scripts.
Downloading this project as a Docker container or Nix package can shorten the time needed to build webR, but it is not required. WebR will compile LLVM from source in the build tree if it is not provided with Fortran compiler tools.
No, this project does not contain a version of R configured for use with WebAssembly, which is required to build R packages. To build R packages, either build webR from source, or use a Docker image containing a fully pre-built version of webR.