Placing everything in LIBDIR
happens because of RPATH
issues. If I place something in /usr/lib/mydir/
then the executable or library that uses it needs either RPATH
hard-coded in the binary or $LD_LIBRARY_PATH
set at runtime to contain possibly hundreds of entries. As it currently stands distro packages (deb or rpms) can be installed in somewhere other than /usr
(eg /usr/local
) and just work with $PATH
and $LD_LIBRARY_PATH
set, which hard-coding RPATH
.
My concern is how to get all the software to work together in a distribution. We will see increasing library stacks as software matures - at last checking i’ve some cases of shared libraries 7 deep. People work against the top-level library and leave the rest to “the distribution” - containerised workflows typically do this. The dirty secret of containerisation is that it leaves the heavy lifting to the distro without that being obvious.
A good example of how to work is hdf5
in Debian. There are three implementations of hdf5
: serial
, openmpi
, mpich
which can be co-installed. So on my system:
ls /usr/lib/aarch64-linux-gnu/hdf5/openmpi/
include libhdf5_cpp.a libhdf5_fortran.so libhdf5_hl_cpp.so libhdf5_hl.so
lib libhdf5_cpp.so libhdf5_hl.a libhdf5hl_fortran.a libhdf5.settings
libhdf5.a libhdf5_fortran.a libhdf5_hl_cpp.a libhdf5hl_fortran.so libhdf5.so
These are symlinks, so:
/usr/lib/aarch64-linux-gnu/hdf5/openmpi/libhdf5_cpp.so -> ../../libhdf5_openmpi_cpp.so
and I can build against hdf5 openmpi with --with-hdf5=$LIBDIR/hdf5/openmpi
in most applications.
The aim is to implement a similar structure for Fortran libraries.
Its important to remember there may be multiple versions of a compiler coinstalled, eg flang-new-16 , flang-new-18 and they may have different mod- formats etc too.
This was easier with just gfortran and flang for classic flang
; Currently the issues are what to name directories and how to handle lfortran.
flang-new-* seems to have a stable mod structure with v1
in the first line header. I can use that to put modules in the right directories (eg. $LIBDIR/fortran/flang-mod-1
.
flang-to-external-fc-* produces gfortran-mod files (compressed; version number can be extracted from the header.
Issues:
(1) Are module files produced directly from gfortran and flang-to-external-fc really interoperable? If I have stuff with both gfortran and flang-to-external-fc on my system, should I put the latter in a different directory, eg $LIBDIR/fortran/flangext
?
(2) Ditto libraries?
(3) Are module files guaranteed to be binary-compatible across all archs?
(4) What to do about lfortran? At the moment the format seems tied to the exact compiler version, which is very brittle and requires everything to be rebuilt for every compiler version.