Skip to content

install.sh logic to build fpm using available gfortran #329

@bonachea

Description

@bonachea

We currently require fpm to drive the build of Caffeine. That might change someday, but until/unless it does, this effectively also means requiring a working installation of gfortran, because fpm is currently only supported when built via gfortran.

Our install.sh script has an option to automatically install an fpm binary package from Homebrew (on either macOS or Linux), but even when installed as a binary this still pulls in a dependency on a recent GCC (currently GCC 15.2.0), because the fpm executable needs the gfortran shared library to execute.

Here's a recent CI job that follows this build strategy on Linux, where the relevant build log excerpt:

$ brew install fpm
...
==> Installing dependencies for fpm: gmp, isl, mpfr, libmpc, binutils and gcc
==> Installing fpm dependency: gmp
==> Pouring gmp--6.3.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/gmp/6.3.0: 24 files, 4.1MB
==> Installing fpm dependency: isl
==> Pouring isl--0.27.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/isl/0.27: 75 files, 10.3MB
==> Installing fpm dependency: mpfr
==> Pouring mpfr--4.2.2.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/mpfr/4.2.2: 32 files, 4.2MB
==> Installing fpm dependency: libmpc
==> Pouring libmpc--1.4.1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libmpc/1.4.1: 15 files, 707.2KB
==> Installing fpm dependency: binutils
==> Pouring binutils--2.46.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/binutils/2.46.0: 6,289 files, 443.7MB
==> Installing fpm dependency: gcc
==> Pouring gcc--15.2.0_1.x86_64_linux.bottle.tar.gz
==> Creating the GCC specs file: /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/bin/../lib/gcc/current/gcc/x86_64-pc-linux-gnu/15/specs
🍺  /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1: 2,175 files, 445.8MB
==> Installing fpm
==> Pouring fpm--0.13.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/fpm/0.13.0: 4 files, 11.2MB

Shows the brew install fpm command has pulled in GCC 15.2 and all its dependencies, for a grand total of up to 1GB of binary packages, all of which are potentially unused once the Caffeine build completes (assuming the user actually wants to use Caffeine with flang).

Assuming the user is starting with a working Fortran compiler, we could potentially do much better than this. Ideally we'd just build fpm from source using whatever Fortran compiler the user provided for Caffeine, and then use that fpm to build Caffeine. Unfortunately LLVM flang cannot currently build a working fpm (fortran-lang/fpm#1288), so that approach doesn't directly help the majority of near-term potential users.

As a less ideal option, the script could instead look for a sufficiently recent gfortran that might already be available on the system and use that to build fpm. This should result in a far smaller disk footprint than installing fpm from Homebrew (except when the current Homebrew GCC happens to already be installed).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions