Notes on flang build for Debian =============================== Alastair McKinstry , 2019-01-25 This is the first build of flang for Debian; it is built with gcc/gfortran. Some patches are required. It needs review by the LLVM packaging team. ieee_arithmetic and ieee_exceptions currently do not compile with gfortran, as it is pickier about the quality of the Fortran (!) and C bindings. A two-stage compile is done: the initial compile with gfortran, followed by a recompile using the flang from the first stage. This build is done against Debian's build of LLVM-7, rather than the adapted LLVM used with flang. The flang fork of llvm handles several extensions to llvm debug metadata. The flang llvm converts these to DWARF that is specific to Fortran. These llvm changes are waiting to be upstreamed; they are in review at llvm.org right now. By default, flang does not generate this extended metadata. There’s a flag that must be set at compile time. Currently this is not set, and the code produced appears to work fine in Debian. As a pre-release, the compiler does not have a version number; I have named the binary package 'flang-7' as it uses LLVM-7, with a version 20181226, as this is the release dump of the tarball(s). Binaries produced are linked against the flang runtime libraries, shipped in libflang0d-7. Currently these do not have SONAMEs set upstream, They are patched to set SOVERSION to 0d as per Debian practice. (Hence the package name libflang0d-7). flang-driver, which produces the top-end driver, is shipped as a separate tarball but included here as a subdirectory. The driver, normally called 'clang-7', is renamed 'flang' Flang uses a different module file format to gfortran (Module files, suffixed '.mod', are precompiled header files). For interoperability, gfortran and flang will need to search for and keep their module files in different directories. In Redhat/Fedora, Fortran module files are placed in $LIBDIR/$FMODDIR, typically /usr/lib/fortran. I am proposing to put them in /usr/lib/$multarch/fortran/$compiler with compiler being gfortran-8, flang-7, etc. (mod file formats can become incompatible between compiler versions, eg. gfortran-7 and gfortran-8). I am working on dh-fortran-mod, a debhelper extension, for user packages, and patches for gfortran and flang to search $FMODDIR.