Flang support in LLVM (FLANG)
Introduction
Linaro and Linaro Members' are working on flang targeting AArch64 on Linux and Windows. Linux has had a head start in flang, so in general Linux support has been slightly ahead of Windows support. Therefore, part of our work is to bring Windows on Arm (WoA) support to the same level of parity as Linux. However, we also strive to improve flang in general, for any platform. Enabling Flang in LLVM is a big project with plenty of work for to go around.
General flang AArch64 enablement work
Fujitsu-specific bugs and feature improvement
Windows-specific work
https://linaro.atlassian.net/browse/WOA-47 (link may require special permissions to access)
Scope
Include flang in AArch64 releases for both Linux and Windows
Provide CI for flang for both Linux and Windows, running check-all and the llvm-test-suite
Test relevant open-source workloads with flang; add them to CI if license/resources permit
Fix bugs, add missing features as needed by the workloads that we choose to prioritize
Check flang’s integration with CMake and provide CI if necessary
Publish developer notes on how to generate a WoA binary
Help the flang community as much as possible (e.g. with upstreaming from fir-dev/classic-flang)
Project lead(s): @Carlos Seo
Project Contacts
Join the linaro-toolchain@ mailing list (archive)
Contact Carlos Seo for anything private or sensitive
Source Code
LLVM Buildbots CI
LLVM Releases
Upstream Wiki
Upstream Collaboration (Slack, Technical and Community calls etc)
Community Production-Ready Criteria and Linaro Goals
The LLVM community currently agrees that flang-new
will be renamed to flang
only when:
Make HLFIR the default Fortran IR (done)
Remove
-flang-experimental-exec
flag (done)Build and run SPEC CPU 2017 (done)
Full procedure pointers support (mostly done)
Most of the gfortran testsuite not crashing — special interest in fixing all the segmentation faults (done)
This happened in October 2024 and will be available in LLVM 20.
AArch64 enablement
We currently have full feature parity with x86_64 as of LLVM 19.
Support for trampoline intrinsics currently depend on compiler-rt and this dependency is planned to be removed when Flang has support for procedure pointers for internal procedures.
Linaro “production ready” criteria
In addition to the community criteria for renaming flang-new
to flang
, Linaro also considers that Flang will be production ready when:
Can build and run both SPEC CPU 2006 and 2017 (done)
Has debug information support (done)
Has Fortran 2008 support, except for coarrays
OpenMP support is stabilised (almost done)
Feature parity with x86 (done)
Performance is no slower than 25% compared to gfortran in SPEC CPU 2017 ‘rate’.
Linaro development completion criteria
Based on the current state of the compiler, Linaro should declare this project completed when the following conditions are met:
Next-generation SPEC CPU is supported
As the next generation of SPEC CPU is close to release, Flang should be able to build it and correctly run all of its benchmarks in both ‘rate’ and ‘speed’ modes.
OpenMP 2.5+ essential features are supported
OpenMP is becoming increasingly important with AI, so we need to support at least:
OpenMP 2.5
Workshare
Reprivatisation
Reduction (arrays)
Threadprivate (variables) (done)
Copyin (variables) (done)
Numthreads (done)
Copyprivate (done)
Directives can contain comments
_OPENMP
macroomp_lib
module contains interfaceOpenMP runtime routines
OpenMP 3.x — community goal for LLVM 20
Task (mostly done, missing support for delayed execution of tasks)
Taskwait
taskyield
OpenMP 4.x
Declare SIMD
Declare Reduction
Depend
Atomics
Target
Taskgroup
Teams
Taskloop
OpenMP 5.x — community goal for 2026
Order clause
Declare Target
Scan
Tile
Unroll
One caveat is that most of the fixes/supported features are on the host side only now. For GPU offloading, we currently have only a 15% pass rate in the tests. If Flang+OpenMP support in offloading is important, then we’ll have to revisit this list.
Active Tasks and Coordination
We are currently targeting: SPEC2017, SPEC2006, OpenBLAS, SciPy, NumPy
OpenBLAS
We have committed some fixes to flang to enable it to build OpenBLAS on WoA
SPEC2017 is tracked upstream in this board: https://github.com/orgs/llvm/projects/8
NumPy
Testsuite fixes https://linaro.atlassian.net/browse/LLVM-734
Missing support for procedure pointers: Peixin (Huawei) https://github.com/PeixinQiao from upstream is working on implementing this. A few patches were recently committed.
SPEC2006
All benchmarks are passing except 465.tonto, which fails at compile time because of 2 issues
Qualcomm is working on one of them, the upstream community is working on the other
SNAP is known to work with flang, Linaro has been reviewing a patch to add it to the test-suite https://reviews.llvm.org/D130734
Achievements and Status
SciPy
All issues fixed and committed upstream. SciPy now builds with Flang with all tests passing.
NumPy
Now Compiles with flang but has 4 testsuite failures.
SPEC2017
Flang now passes SPEC2017 correctness.
Flang included in LLVM releases:
Linux: since LLVM 14
Windows: since LLVM 15
Buildbots running check-flang:
Linux: 12 configurations
Windows: 2 buildbot (flang is the first subproject for which the tests have been enabled on the WoA buildbots)
Buildbots running the llvm-test-suite
We have several running on Linux:
The llvm-test-suite is currently not supported on Windows in general
CI testing flang + CMake:
Developer notes:
Upstreaming of the fir-dev branch is now considered complete (Linaro has contributed several patches & code reviews to this effort)
Contributions to flang’s runtime libraries, WoA support, bugfixes etc
Upstream code reviews
Current Plan
Backlog
Accomplished
Linaro Ltd.