WebAssembly port of LLVM Flang - Fortran compiler for WebAssembly with SIMD optimization and comprehensive Fortran runtime library.
This repository contains tools to build a patched version of LLVM's flang 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
Makefilethat downloads, builds and installs theflangcompiler from a patched LLVM source. Use thePREFIXmake variable to control the installation directory (default,"."). Once installed, the$(PREFIX)/host/bin/directory will containflang. 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 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.
This WebAssembly port is part of a larger effort to bring professional desktop applications to browsers with native performance.
👨💻 About the Maintainer: Isaac Johnston (@superstructor) - Building foundational browser-native computing infrastructure through systematic C/C++ to WebAssembly porting.
📊 Impact: 70+ open source WASM libraries enabling professional applications like Blender, GIMP, and scientific computing tools to run natively in browsers.
🚀 Your Support Enables:
- Continued maintenance and updates
- Performance optimizations
- New library ports and integrations
- Documentation and tutorials
- Cross-browser compatibility testing
💖 Sponsor this work to help build the future of browser-native computing.