Building the LLVM Flang Fortran compiler

less than 1 minute read

Nvidia is supporting Flang, a Fortran compiler via 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.

conda install flang

Anaconda’s compiler support includes Flang, currently for Linux and Windows:

conda install -c conda-forge flang

Building Flang

For casual use, it’s far easier to use the conda install method 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 -j7. 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