Speech & Audio

LLVM’s Fortran compiler finally drops the training wheels • The Register

LLVM’s Fortran compiler finally drops the training wheels • The Register


The latest version of the LLVM compiler suite has promoted its Fortran front end. “Flang” is now official.

LLVM 20.1 appeared last week. This is a major release following LLVM 19.1, which came out in September 2024 (the project’s version numbering scheme is a little idiosyncratic). One of the headline features in this release is that the Fortran front end received a promotion. LLVM has included Fortran since LLVM 11 in October 2020, but until now, the compiler was called flang-new. Now its name has changed, and it’s just the Flang Compiler, or Flang for short.

There are other modern open source versions of Fortran out there, such as GNU Fortran, which is part of the GCC suite. The blog post announcing Flang’s renaming is long, detailed, and highly informative. It goes into the project history, and why it’s important to have at least two independent FOSS implementations, Flang and GFortran.

As for compilers called Flang, though, things do start to get confusing. The new Flang compiler is not the first or only Fortran compiler with that name. (The name comes from “F” for Fortran, plus “lang” from language, by analogy with LLVM’s C compiler, which is called Clang. Scrabble fans may wish to know that “flang” is a miner’s double-headed pickaxe.)

There was already another Fortran compiler based on LLVM that is also called Flang, now known as Classic Flang. The Portland Group started work in 2009 and it went open source a decade ago, when PGI was already being digested by Nvidia. Classic Flang still exists and it’s still getting occasional code contributions. In its former commercial incarnation, it was called pgfortran. Just for added entertainment value, that Flang wasn’t the first either.

Far back in the mists of ancient times when this vulture learned Fortran at university, the dominant standard was FORTRAN-77, but even in the 1980s, reference books still talked about FORTRAN IV from 1961. Things have moved on, and Fortran 2018 was agreed a while ago. The newly appointed Flang compiler is mostly compatible with Fortran 18, and indeed was called F18 while it was in development – the documentation still uses that name in places. Since then, that standard has been superseded by Fortran-2023. For some light reading, it is a mere 688 pages [PDF], although there’s a more digestible 25-page summary of the new features [PDF]. If that’s still too much, there’s a summary of the summary here.

If you fancy updating your skills, there’s an interactive compiler called LFortran – although it is still in alpha. Not only can LFortran generate WebAssembly, if that’s your thing, it also means you can experiment with a REPL in Fortran. The 18-year-old version of this Reg scribe would have given good money for that, if he’d had any.

The Fortran language never went away. Indeed, it’s looking healthier than it has for decades, in part thanks to the efforts of Ondřej Čertík. Since Fortran 90, the rather ugly, old-fashioned, punched card-based layout has gone. Modern versions are much more flexible. It even has its own package manager now. Some of SciPy is written in Fortran, and thanks to free, highly optimized libraries like LAPACK and BLAS, even modern languages that don’t include a line of Fortran call Fortran code to do numerical computation. ®

LLVM's Fortran compiler finally drops the training wheels • The Register

Source link