LLVM 11.0 Finally Available With Flang Fortran Compiler

Does anyone have experience installing this? I would be grateful to learn how well it works.

I believe this is also worth including in the next Fortran monthly newsletter.

git clone https://github.com/llvm/llvm-project.git
mkdir llvm-project/build
cd llvm-project/build
cmake -G Ninja -DLLVM_ENABLE_PROJECTS='flang'  ../llvm
cmake --build .
cmake --build . -- install

But the HEAD from October 9 still showed the following (and I doubt they changed that for the release);

$ f18 --version

f18 compiler (under development), version 12.0.0
$ f18 --help
f18: LLVM Fortran compiler

Usage: f18 [options] <input files>

  When invoked with input files, and no options to tell
  it otherwise, f18 will unparse its input and pass that on to an
  external compiler to continue the compilation.
  The external compiler is specified by the F18_FC environment
  variable. The default is 'gfortran'.
  If invoked with no input files, f18 reads source code from
  stdin and runs with -fdebug-measure-parse-tree -funparse.

So, it can parse Fortran, but not generate code yet (for that you need either GFortran or the driver from the Flang project).

1 Like

The flang package is available in Fedora Rawhide (development version):

$ flang --version

f18 compiler (under development), version 11.0.0

But yes, the code is generated by gfortran… Have you any information about when it will be able to compile the code by itself ?

It seems that when building from the LLVM master you can already enable the new driver by adding -DFLANG_BUILD_NEW_DRIVER=ON to the cmake incantation, see https://github.com/llvm/llvm-project/tree/master/flang#build-the-new-flang-driver
When building you may have to use --parallel N to reduce the number of parallel build steps because some targets require >=8GB of memory while linking.

And if I remember correctly Gary mentioning in his talk at FortranCon that the current state should be enough to start developing tools like flang-format, or some static analysis (the flang-doc build target is supposed to generate FIR documentation).