Creating compiler toolchains
We currently detect our compiler toolchain by identifying it from the Fortran compiler, with the default being gfortran. This is somewhat suboptimal since it doesn't account for the C compiler and because changes in the PATH are not correctly considered in our toolchain.
Here is a proposal for creating an fpm compiler command inspired by spack compiler:
- allow to find installed compilers by searching the
PATHfor standard names (done automatically on first invocation) - inspection/modification of existing compiler toolchains possible (checksum?)
- available toolchains are user settings in
~/.config/fpm/toolchain/*.tomlor~/.config/fpm/toolchain.toml(individual files might be easier to share/reuse) - specify the default toolchain in
~/.config/fpm/config.toml - the commands for
--compiler,--c-compiler, ... are passed tofpm compilerinternally (create new toolchain on demand) - toolchain name is used to prefix build output directory (maybe include a digest/slug?)
- possibility to perform an integrity check of toolchain (in case of system upgrade, ...)
The Rust cc crate also has a cc::Tool class. The biggest difference is the compiler is configured via the build.rs build script. It makes sense that Fortran compiler integration must be closer (configuration is passed internally).
In general I like the proposal. Given the multitude of Fortran compilers, a good separation layer would be useful. In the spack compiler command, I see one can embed flags directly in the compiler configuration file. How would those interact with the compiler flag profiles (https://github.com/fortran-lang/fpm/pull/498) in the user project manifest?
A second question is what if fpm were to be used as a spack build system in the future. Would the spack configurations be translated to fpm configurations (or vice-versa)?