First official release of Flang!

Announcing the first official release of Flang! Congratulations to everyone who has contributed to this LLVM Fortran project, which began in late 2020. The blog post below provides a historical recap of the project.

Also, big thanks to Peter Klausler who wrote the first component to Flang, the parser! Peter continues to be one of the main contributors to the project (in fact, he is now the #24 all-time contributor to the LLVM project).

There is still work to be done, but it is great to reach this milestone today!

-Mark

26 Likes

How does one install flang on a Mac (macos-arm64) machine? My preferred solution is conda, but this flang package doesn’t have a Mac build. I see various llvm packages (e.g., llvm), but installing them they don’t seem to include the actual compiler?

1 Like

I think @JeffH has installed it on an apple silicon mac and should have some good insights on this. Otherwise, you can probably build it yourself if you have a spare couple of hours for it build from source :slight_smile:

Of the long list of tar files etc. given in the download link in the referenced blog, which one actually has a working version of the flang binary. Is it the entire llvm-20.1 tar file. Are any of the other files listed required as well. If the LLVM flang people want us to try their compiler they can stop assuming we are all mind readers and give us explicit instructions on how to install their compiler on our preferred OS. Also, is this still just a alpha release or is it a full working compiler. If the former, what works and what doesn’t work.

2 Likes

That’s the 19.1.7 version, anyway. Not the LLVM 20 mentioned by OP.

Edit: Also, MacOS comes with Apple’s ‘LLVM clang’ compiler, so one should be careful installing third-party LLVM suite.

HPCInfo/buildscripts/llvm-git.sh at master · jeffhammond/HPCInfo · GitHub is broken for MacOS, unfortunately. I haven’t cared enough to debug. I am sure the fix is not that hard. I’d love a pull request if somebody can fix it.

1 Like

I’ve gone this long without building any compilers from source so I’m not going to start now. :laughing:

5 Likes

Same here. Further proof that the old adage that “great minds think alike” is true. :grinning_face:

1 Like

I am only willing to build compilers that I write myself. :slight_smile:

Yes, as a user I install flang, gfortran and lfortran using conda-forge, but indeed on macOS/arm there is no flang package, so that should be fixed.

1 Like
  1. install Homebrew
  2. brew install flang

That won’t the the new llvm20 based, but it is quite usable.
Homebrew flang-new version 19.1.7
Target: arm64-apple-darwin24.4.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/flang/19.1.7_1/libexec
Configuration file: /opt/homebrew/Cellar/flang/19.1.7_1/libexec/flang.cfg
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin24.cfg

Note that “quad precision” (kind=16) isn’t supported, but won’t be diagnosed.

Congrats to everyone involved in this effort, and thanks for all your hard work so far!

Once this PR gets merged into the Spack package manager, you will also be able to build it from sources using spack install llvm@20 +flang

2 Likes

I recommend that you don’t try to build flang yourself. Yesterday morning, I began building the AUR package, and it was completed in the evening. My ThinkPad was almost unusable during that period. :joy:
It took way longer than building LFortran. I think because it had to build mlir (Multi-Level IR Compiler Framework for LLVM), too.

1 Like

yeah on a 40 core machine that I ssh into it took ~2 hours hahaha don’t build it on your laptop :stuck_out_tongue:

2 Likes

I used MacPorts to install Flang20 but I am confused as to what was installed. there are three flang compilers in the bin folder - flang-20-mp-20, flang-mp-20 and flang-new-mp-20. not sure what each one does. Anyone else use this MacPorts install?

Guess: flang-mp-20 is the classic flang v20, flang-new-mp-20 is the llvm-based flang (“v20”), but I don’t know what can be flang-20-mp-20!

they all give the same response with --version:
flang version 20.1.0
Target: arm64-apple-darwin24.3.0
Thread model: posix

I assume mp refers to openmp compatibility. Will be happier when the Homebrew recipe is updated.

Hi @Rekindle and welcome.

Notice that all three binaries end with -mp-20, so if the size is the same, they’re simply the same thing (flang, flang-new, flang-20).

And there’s a PR for homebrew in the works.

good to hear about the homebrew PR.

I did find I may have been looking in the wrong directory. the opt/local/lbexec/llvm-20/bin directory has flang, flang-20, and flang-new files. But flang and flang-20 are aliases to flang-new.

3 Likes