I asked in the spack-slack channel and was told to include the explicitly link the gfortran associated with the gcc version I build petsc with. Following that advice, I'm using gcc@7.3.0, linking gcc@7.3.0/lib64 in FFLAGS and setting -g option to CFLAGS in my makefile.
Yet, somehow the executable still picks up the system gfortran (It picks both libgfortran.so.4 and libgfortran.so.3). Anything else I missed trying? PS: My makefile looks like this: [sajid@xrm free_space]$ cat makefile ALL: CFLAGS = -g FFLAGS = -L/raid/home/sajid/packages/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/gcc-7.3.0-qrjpi76aeo4bysagruwwfii6oneh56lj/lib64/ CPPFLAGS = FPPFLAGS = CLEANFILES = ex_matlab include ${PETSC_DIR}/lib/petsc/conf/variables include ${PETSC_DIR}/lib/petsc/conf/rules # your targets if any include ${PETSC_DIR}/lib/petsc/conf/test I've looked into the superludist and can confirm that it is indeed linked to the system gfortran due to it's build error and since it's a petsc dependency, it might be that this is where the system gfortran is coming in instead of the newer gfortran associated with gcc-7.3.0 but I'm not sure.