Using `flang` in GitHub Actions

Has anyone gotten flang to work with GitHub Actions?

Currently, I use the binary release of flang in my GitHub Actions. The installation is not more than downloading the compiled binary files. But this version is relatively old, dating back to March 2019. It would be great to use the latest release of flang in GitHub Actions.

Thank you for any suggestions.

Building flang from source requires a quite powerful machine (peak memory requirement ~20GB with 8 threads for me).

There are few binary packages of flang available, which makes flang already usable for all major platforms on GitHub actions (if you count Docker on Ubuntu as Linux platform):

If you want to build it from source, you need to build MLIR first. This makes packaging more challenging because a binary package of MLIR has to be created as well. I managed to piece together Arch Linux PKGBUILDs for MLIR and flang for local installations, but building those on CI will be quite a challenge.

While I have no interest in packaging for Ubuntu (not a user and building deb packages is just a pain), it might be worth creating MLIR and flang packages for homebrew and try to update conda-forge’s flang package (they already have MLIR).

2 Likes

I asked at LLVM flang driver · Discussion #2753 · Homebrew/discussions · GitHub about flang in homebrew LLVM. You can get access to a flang version by tapping carlocab/personal on MacOS.

1 Like

Hi, yes, you should be able to just do

brew install carlocab/personal/flang

on macOS.

That will work on Linux too (at least, on GitHub’s ubuntu-latest runner), but it will build flang from source. I can set things up so that it installs a binary package instead (just like it would on macOS), but it will take a little bit of work.

File an issue at my tap if you’re interested in a binary package for Linux or if you’re having any other problems with the build.

Edit: This should work on Linux now too, but I should mention that this will install LLVM Flang and not classic Flang.

1 Like

Thank @awvwgk for the links and for bringing @carlocab into the loop. I agree that building Flang from source during a GitHub Action seems not ideal/possible. As @carlocab kindly suggested, I have filed an issue at your repo, and I hope that you could find time for it, but I do understand that it takes effort and we are busy.

Many thanks again!

While it might become tiresome to repeat every time we speak about flang, there is this unfortunate distinction between LLVM flang and classic flang. I just realized that you mentioned classic flang, while most packages linked currently contain LLVM flang.

Classic flang has code generation, while this is missing in LLVM flang. However, I wonder whether it is worth to invest time in building and packaging classic flang?

Hi @awvwgk ! Yes, there are several flangs (AMD AOCC and Huawei Bisheng also provide flang, which I remember is based on the classic flang). It has ever been confusing to me what is the relation/distinction between the classic flang and the LLVM flang. What I am currently using in my development is the classic flang (together with AOCC flang and Bisheng flang). It has been very instrumental in identifying bugs and questionable code. Therefore, in my personal opinion, it is worth investing time in building and packaging classic flang, while LLVM flang will be equally usuful. However, I do not have any experience in packaging. I imagine that it takes quite some effort.

Thank you.

It is easier than you might think it is. There is a learning curve, like with everything, and depending on the ecosystem you want to invest in it can be a bit steep. I have involved myself now with several packaging ecosystems (conda-forge, MSYS2, Arch Linux, spack, and homebrew) and I found it quite insightful. Making software easier to install and package and therefore also easier to use and build seems like a net win for everyone.

2 Likes

The classic flang CI uses github actions. We precompile a fork of llvm-project in github actions and then use that to build classic flang and run the tests.
github actions llvm
github actions flang

I did check with the members of the classic flang community during our last call and none of us have the time to provide a binary version. If you have and would need some assistance then please get in touch or do attend the classic flang call.

As mentioned by @zaikunzhang , the Arm, AMD and Huawei compilers are based on classic flang. The code is based on the pgifortran compiler’s source. It supports almost all of Fortran 2003 and a big portion of Fortran 2008. The compiler is currently mostly in maintenance mode. Some features of Fortran 2008 are likely to be added but major features like co-arrays are not in plan. All of these vendors plan to switch to llvm/flang when it is ready and are contributing to both the flang compilers.

2 Likes

Just started exploring existing classic flang builds and tried to setup my own, but was not very successful so far: Build failure on Arch Linux due to -Werror=format-security · Issue #1204 · flang-compiler/flang · GitHub

I’m aware of two classic flang packages, which might serve as reference for packaging

2 Likes

I’ve updated my repository. You should now be able to install LLVM Flang from a binary package easily on GitHub Actions runners, since brew is preinstalled (even on Linux) on GitHub Actions.

2 Likes

Thank you @carlocab for your great efforts! I have tried it and it works well. Many thanks!

Thank you @kiranchandramohan for the elaboration and for the efforts of maintaining and developing flang. I look forward to seeing LLVM flang becomes ready for production usage.

Thank you @awvwgk for the elaboration. I will try packaging once I find time for it. I agree that we can get insights into our code/software when trying to make it readily usable on others’ machines. It is one level higher than merely coding the software itself. In addition, it benefits the community by making software more accessible. Definitely worthwile. Many thanks!

1 Like