Building the LLVM Flang Fortran compiler

1 minute read

Nvidia is supporting Flang, a Fortran compiler frontend to LLVM. Flang is supported by Cmake ≥ 3.10. Flang is increasing support for Fortran 2008, but still has a ways to go. A big downside to Flang like PGI that it’s partly based on is that Flang doesn’t yet support the ubiquitous Fortran 2008 error stop statement.

Flang f18 is a new LLVM Fortran compiler front-end based in C++17 instead of the monolithic C code inherited from PGI that become the first-generation Flang.

How to install Flang

Pick ONE of the following:

  • Download the latest Flang Linux binary release
  • conda install -c conda-forge flang currently for Linux and Windows Flang
  • Compile from source (not recommended for casual Flang users)

Building Flang

For casual use, it’s far easier to use the methods above.

Building the LLVM Flang Fortran compiler from source is a resource-intensive process.

  • You need a moderately powerful PC to compile Flang with > 100 GB of free space on the drive you build Flang on. Flang install is small, but Flang build process requires a lot of drive space.
  • Don’t use too much RAM with the -j option of make for building Flang. It maxed out RAM on a PC with 32 GB of RAM with make -j. Maybe try make -j2 or just plain make.
  • follow the Flang build instructions sequentially. Don’t try to build later parts while earlier parts are still building, this will not work properly.

Leave a Comment