[petsc-dev] Gfortran Fix for "library not found for -lSystem" macOS Big Sur

Sean Farley sean at farley.io
Thu Dec 24 16:35:00 CST 2020

Jacob Faibussowitsch <jacob.fai at gmail.com> writes:

> If anyone is on macOS and using brew to get gfortran, you may find it suddenly doesn’t work anymore.
> Fix is to add /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib to $LIBRARY_PATH in startup shell file, as per this SO post.

TLDR; reinstall gcc and libgccjit (if you use that) from source if
you're on MacOS 11 (Big Sur)

$ brew reinstall gcc --build-from-source --force
$ brew reinstall libgccjit --build-from-source --force

Setting LIBRARY_PATH on MacOS is almost always a smell. I had this same
problem with libgccjit as gfortran did. Unfortunately, setting the
environment variable doesn't fix gcc's jit.

The binaries that Homebrew hosts are somehow misconfigured (I suspect
they weren't compiled on Big Sur and didn't pick up the new search path
for -lSystem).

After waiting (perhaps hours) for gcc to compile, things should work
without any environment variables being set. Also, the gfortran formula
is just a link to gcc so recompiling one will fix the fortran compiler.

Anyways, hope that helps.

More information about the petsc-dev mailing list