Skip to content

Problem on macOS with gfortran #32

Open
@gha3mi

Description

@gha3mi
Contributor

Thanks for the project.

There is a problem with the mac operating system. It appears that it only works with gfortran version 10.

When running a simple fpm test on mac using gfortran, I encountered this error:

 dyld[2196]: Library not loaded: '/usr/local/opt/gcc@10/lib/gcc/10/libgfortran.5.dylib'
  Referenced from: '/Users/runner/work/_temp/fpm'
  Reason: tried: '/usr/local/opt/gcc@10/lib/gcc/10/libgfortran.5.dylib' (no such file), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file)
/Users/runner/work/_temp/378df7c3-1bf9-413a-8a60-858cb91f887e.sh: line 1:  2196 Abort trap: 6           fpm test
Error: Process completed with exit code 134.

To temporarily solve the problem, I used the following steps:

    - name: Setup Fortran on Windows
      if: contains( matrix.os, 'windows')
      uses: awvwgk/setup-fortran@v1
      with:
        compiler: ${{ matrix.toolchain.compiler }}
        version: ${{ matrix.toolchain.version }}

    - name: Setup Fortran on MacOS
      if: contains( matrix.os, 'macos')
      run: |
        brew reinstall gcc@12
        ln -s /usr/local/lib/gcc/current/libgfortran.5.dylib /usr/local/lib/
        ln -s /usr/local/lib/gcc/current/libquadmath.0.dylib /usr/local/lib/
        ln -s /usr/local/Cellar/gcc/13.1.0/bin/gfortran /usr/local/bin/gfortran
        # ln -s /usr/local/lib/gcc/current/bin/gfortran /usr/local/bin/gfortran

Activity

wpbonelli

wpbonelli commented on Aug 1, 2023

@wpbonelli
Contributor

cf #7, #31 reproducing in ci tests is likely the first step toward solution

gha3mi

gha3mi commented on Aug 1, 2023

@gha3mi
ContributorAuthor

To find locations on a Mac, I used the find command:

find /usr/local -name "libgfortran"
find /usr/local -name "libquadmath"
find /usr/local -name "gfortran"

Maybe the above solution can be generalized (I didn't test it):

  brew reinstall (or install) gcc@${{ matrix.toolchain.version }}
  ln -s /usr/local/lib/gcc/current/libgfortran.5.dylib /usr/local/lib/
  ln -s /usr/local/lib/gcc/current/libquadmath.0.dylib /usr/local/lib/
  ln -s /usr/local/Cellar/gcc/13.1.0/bin/gfortran /usr/local/bin/gfortran
  # or
  # ln -s /usr/local/Cellar/gcc/${{ matrix.toolchain.version }}/bin/gfortran /usr/local/bin/gfortran
  # or
  # ln -s /usr/local/lib/gcc/current/bin/gfortran /usr/local/bin/gfortran
  # or
jalvesz

jalvesz commented on Jan 15, 2024

@jalvesz

Same problem here, the tool chain installs gcc13 but it tries to look for gcc10 so it fails

dyld[[9](https://github.com/jalvesz/fast_math/actions/runs/7522194607/job/20473898887#step:5:10)87]: Library not loaded: '/usr/local/opt/gcc@[10](https://github.com/jalvesz/fast_math/actions/runs/7522194607/job/20473898887#step:5:11)/lib/gcc/10/libgfortran.5.dylib'
  Referenced from: '/Users/runner/work/_temp/fpm'
  Reason: tried: '/usr/local/opt/gcc@10/lib/gcc/10/libgfortran.5.dylib' (no such file), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file)
/Users/runner/work/_temp/5303a5b3-22dd-4062-9184-c4aeef2db72e.sh: line 1:   987 Abort trap: 6           fpm test --flag "-cpp -O3 -march=native"
minhqdao

minhqdao commented on Jul 28, 2024

@minhqdao
Contributor

Still having the problem:

dyld[4361]: Library not loaded: /usr/local/opt/gcc/lib/gcc/current/libgfortran.5.dylib
  Referenced from: <9C2D5DA8-E509-36A4-AB7E-D8D39205CC1F> /Users/runner/work/_temp/fpm
  Reason: tried: '/usr/local/opt/gcc/lib/gcc/current/libgfortran.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/gcc/lib/gcc/current/libgfortran.5.dylib' (no such file), '/usr/local/opt/gcc/lib/gcc/current/libgfortran.5.dylib' (no such file), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file, not in dyld cache)
/Users/runner/work/_temp/03e4926e-d593-4b01-848f-c502aedb9a9c.sh: line 1:  4361 Abort trap: 6           fpm test
Error: Process completed with exit code 134.

Tried running both gcc-13 or intel-classic and it happened in both instances.

wpbonelli

wpbonelli commented on Jul 29, 2024

@wpbonelli
Contributor

libgfortran shouldn't be used at all for an intel fortran build, right? seems like confirmation this is an fpm issue?

xref gha3mi/test-setup-fortran#1 where @gha3mi made some progress tracking it down

wpbonelli

wpbonelli commented on Jul 4, 2025

@wpbonelli
Contributor

hey @gha3mi @minhqdao was this ever confirmed to be a problem with fpm? not urgent, just pruning the backlog.

gha3mi

gha3mi commented on Jul 4, 2025

@gha3mi
ContributorAuthor

Hey @wpbonelli, I haven’t heard anything about it being confirmed. That was my speculation, but the test worked here: https://github.com/gha3mi/test-setup-fortran#compatibility

I can rerun the test to see if anything has changed since then.

gha3mi

gha3mi commented on Jul 4, 2025

@gha3mi
ContributorAuthor

Check the test of setup-fortran with Meson on macOS (CMake seems to work too):

Run meson setup build
The Meson build system
Version: 1.8.2
Source dir: /Users/runner/work/test-setup-fortran/test-setup-fortran
Build dir: /Users/runner/work/test-setup-fortran/test-setup-fortran/build
Build type: native build
Project name: hw
Project version: undefined
Fortran compiler for the host machine: gfortran (gcc 13.4.0 "GNU Fortran (Homebrew GCC 13.4.0) 13.4.0")
Fortran linker for the host machine: gfortran ld64 1053.12
Host machine cpu family: aarch64
Host machine cpu: aarch64
Build targets in project: 2

Found ninja-1.11.1.git.kitware.jobserver-1 at /Users/runner/hostedtoolcache/Python/3.10.11/arm64/bin/ninja
[1/8] Scanning target mod_hw for modules
[2/8] Scanning target main for modules
[3/8] Generating dynamic dependency information for target mod_hw
[4/8] Generating dynamic dependency information for target main
[5/8] Compiling Fortran object libmod_hw.a.p/src_mod_hw.f90.o
[6/8] Compiling Fortran object main.p/app_main.f90.o
[7/8] Linking static target libmod_hw.a
[8/8] Linking target main
 Hello World!

This works correctly, which confirms that setup-fortran works with Meson (and CMake) on macOS. However, fpm currently fails with the following error:

dyld[2339]: Library not loaded: /usr/local/opt/gcc@12/lib/gcc/12/libgfortran.5.dylib
  Referenced from: <26556B0B-10CE-34E1-8E58-0A1EA2DC6004> /Users/runner/work/_temp/fpm
  Reason: tried: '/usr/local/opt/gcc@12/lib/gcc/12/libgfortran.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/gcc@12/lib/gcc/12/libgfortran.5.dylib' (no such file), '/usr/local/opt/gcc@12/lib/gcc/12/libgfortran.5.dylib' (no such file), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file, not in dyld cache)
/Users/runner/work/_temp/4fccb4fd-52a9-4abb-8a27-43f5c5009770.sh: line 1:  2339 Abort trap: 6           fpm run --compiler gfortran
Error: Process completed with exit code 134.

It appears that fpm is still trying to link against libgfortran.5.dylib from gcc@12. Last year, installing gcc@10 resolved this issue, but now installing gcc@12 does not fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @wpbonelli@gha3mi@minhqdao@jalvesz

        Issue actions

          Problem on macOS with gfortran · Issue #32 · fortran-lang/setup-fortran