https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112963
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I believe it should fix it indeed. On most targets, linking by g++ or gfortran drivers already adds -lm: find cp/g++spec.cc fortran/gfortranspec.cc config -type f | xargs grep -w MATH_LIBRARY cp/g++spec.cc:#ifndef MATH_LIBRARY cp/g++spec.cc:#define MATH_LIBRARY "m" fortran/gfortranspec.cc:#ifndef MATH_LIBRARY fortran/gfortranspec.cc:#define MATH_LIBRARY "m" config/vms/vms.h:#define MATH_LIBRARY "" config/s390/tpf.h:#define MATH_LIBRARY "CLBM" config/bpf/bpf.h:#define MATH_LIBRARY "" config/i386/cygming.h:#undef MATH_LIBRARY config/i386/cygming.h:#define MATH_LIBRARY "" config/vx-common.h:#define MATH_LIBRARY "" config/darwin.h:#define MATH_LIBRARY "" I bet we don't really support libquadmath say on s390 tpf and for many other targets we also don't build libquadmath, that is done only on targets with __float128 support. One question is for the "" targets (mainly Darwin, VxWorks, Cygwin, Mingw) whether "" MATH_LIBRARY is there just because it isn't needed to link against -lm, or whether it is because linking against it is not possible.