Flang (LLVM Fortran compiler) binaries with wasm32 cross-compilation support.
| Target | Host |
|---|---|
| x86_64-unknown-linux-gnu | Linux x86_64 |
| aarch64-unknown-linux-gnu | Linux ARM64 |
| x86_64-apple-darwin | macOS x86_64 |
| arm64-apple-darwin | macOS ARM64 |
| x86_64-pc-windows-msvc | Windows x86_64 |
Linux builds are compiled on Alpine (musl libc), producing portable binaries that work on any Linux distribution regardless of glibc version.
Each release includes libflang_rt.runtime.wasm32.a for cross-compiling Fortran to WebAssembly.
Release artifact naming is stable:
flang+llvm-{version}-{target_triple}.tar.gz(Linux, macOS)flang+llvm-{version}-{target_triple}.zip(Windows)
Every release also includes:
SHA256SUMS.txtrelease-metadata.json
Compiler entrypoints are normalized in every archive:
- Unix:
bin/flangandbin/flang-new - Windows:
bin/flang.exeandbin/flang-new.exe
Download from Releases and extract.
# Native compilation
flang-new -o hello hello.f90
# Cross-compile to wasm32 (requires Emscripten)
flang-new -c --target=wasm32-unknown-emscripten -o hello.o hello.f90
emcc hello.o -L$FLANG/lib/clang/21/lib/wasm32-unknown-emscripten -lflang_rt.runtime.wasm32 -o hello.jsset(CMAKE_Fortran_COMPILER /path/to/flang-new)Or via command line:
cmake -DCMAKE_Fortran_COMPILER=/path/to/flang-new ..FC = /path/to/flang-new
FFLAGS = -O2
%.o: %.f90
$(FC) $(FFLAGS) -c $< -o $@Use with rules_fortran:
load("@rules_fortran//fortran:repositories.bzl", "flang_register_toolchains")
flang_register_toolchains()Fortran remains widely used in numerical computing, scientific simulation, and optimization libraries. This project enables running such code in browsers and other WebAssembly runtimes—useful for interactive demos, client-side computation, or porting legacy numerical code to the web.
- Fortran in the Browser (2020)
- Compile FORTRAN to WebAssembly and Solve Electromagnetic Fields in Web Browsers (2023)
- Fortran on WebAssembly (2024)
- LLVM Fortran Levels Up: Goodbye flang-new, Hello flang! (2025)
- math/openblas: switch to flang (2025)
ci-pr.yml: lightweight PR validation (Linux x86_64, presetlinux-x86_64, wasm32 e2e)ci-full.yml: full 5-platform builds (scheduled Tue/Fri 01:00 UTC + manual)release.yml: release-only workflow, consumes artifacts fromci-fullrun or rebuilds
release.yml workflow_dispatch inputs:
rebuild(bool): rebuild all platforms in release runsource_run_id(string): consume artifacts from a specificci-fullruntag(string): override release tagversion(string): single source of version truth for artifact/tag/build (recommended to fill this only)llvm_fork_repo(string, advanced): LLVM fork repo overridellvm_fork_ref(string, advanced): LLVM fork ref overridedraft(bool): draft/public release toggle
When rebuild=false, release.yml downloads artifacts from an existing successful ci-full.yml run (same commit SHA by default, or explicit source_run_id).
When rebuild=true, release.yml builds from llvm_fork_repo/llvm_fork_ref (input override or versions.env/auto defaults).
All build jobs use .github/workflows/_build-platform.yml.
LLVM source is pulled from fork, not from upstream llvm/llvm-project directly.
LLVM_FORK_REPOandLLVM_FORK_REFare defined inversions.env- CI fails immediately if
LLVM_FORK_REFis empty - Fork ref is expected to include wasm32 patch set already applied
EMSDK is selected automatically from emsdk-llvm-map.json based on build LLVM major.
- Selector:
scripts/resolve_emsdk_for_llvm.py - Validation:
scripts/check_tool_llvm_major.py --tool llvm-nm - CI fails if downloaded emsdk's
llvm-nm --versionmajor does not match mapped expectation.
versions.env still keeps EMSDK_VERSION/EMSDK_HASH as fallback metadata, but CI selection is map-driven.
llvm-version-watch.yml runs daily and:
- Finds latest LLVM patch version in
TRACKED_LLVM_MINOR - Opens a PR when
versions.envneeds an update - Updates
LLVM_VERSIONandLLVM_FORK_REFusingflang-wasm32-llvmorg-{version}convention