diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2021-03-28 15:39:33 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2021-08-27 16:50:19 +0100 |
commit | 9b025925eceaf207e3d0104cddace753ac6dabd5 (patch) | |
tree | 229425bf8564f2898e489f8112f91d8e473ea29d | |
parent | e42ea63bcc12e819c3e1066974a691988e86b724 (diff) | |
download | gcc-9b025925eceaf207e3d0104cddace753ac6dabd5.zip gcc-9b025925eceaf207e3d0104cddace753ac6dabd5.tar.gz gcc-9b025925eceaf207e3d0104cddace753ac6dabd5.tar.bz2 |
libgfortran: Use the libtool macro to determine libm availability.
We recently had a report of build failure against a Darwin branch on
the latest OS release. This was because (temporarily) the symlink
from libm.dylib => libSystem.dylib had been removed/omitted.
libm is not needed on Darwin, and should not be added unconditionally
even if that is (mostly) harmless since it is a symlink to libc.
There could be cases where the addition was not completely harmless
because the presentation of the symlink would cause the symbols exposed
in libSystem to be considered ahead of ones presented in convenience
libraries.
libgfortran/ChangeLog:
* Makefile.am: Use configured libm availability.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Use libtool macro to find libm availability.
* libgfortran.spec.in: Use configured libm availability.
-rw-r--r-- | libgfortran/Makefile.am | 2 | ||||
-rw-r--r-- | libgfortran/Makefile.in | 3 | ||||
-rwxr-xr-x | libgfortran/configure | 146 | ||||
-rw-r--r-- | libgfortran/configure.ac | 1 | ||||
-rw-r--r-- | libgfortran/libgfortran.spec.in | 2 |
5 files changed, 149 insertions, 5 deletions
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am index 8d10432..6fc4b46 100644 --- a/libgfortran/Makefile.am +++ b/libgfortran/Makefile.am @@ -42,7 +42,7 @@ libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS) libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ $(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \ $(HWCAP_LDFLAGS) \ - -lm $(extra_ldflags_libgfortran) \ + $(LIBM) $(extra_ldflags_libgfortran) \ $(version_arg) -Wc,-shared-libgcc libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP) diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in index afe1ed1..6fc9baf 100644 --- a/libgfortran/Makefile.in +++ b/libgfortran/Makefile.in @@ -610,6 +610,7 @@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBGOMP_CHECKED_INT_KINDS = @LIBGOMP_CHECKED_INT_KINDS@ LIBGOMP_CHECKED_REAL_KINDS = @LIBGOMP_CHECKED_REAL_KINDS@ +LIBM = @LIBM@ LIBOBJS = @LIBOBJS@ LIBQUADINCLUDE = @LIBQUADINCLUDE@ LIBQUADLIB = @LIBQUADLIB@ @@ -734,7 +735,7 @@ libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS) libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ $(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \ $(HWCAP_LDFLAGS) \ - -lm $(extra_ldflags_libgfortran) \ + $(LIBM) $(extra_ldflags_libgfortran) \ $(version_arg) -Wc,-shared-libgcc libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP) diff --git a/libgfortran/configure b/libgfortran/configure index 886216f..4810b9b 100755 --- a/libgfortran/configure +++ b/libgfortran/configure @@ -658,6 +658,7 @@ FC enable_static enable_shared lt_host_flags +LIBM OTOOL64 OTOOL LIPO @@ -12727,7 +12728,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12730 "configure" +#line 12731 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12833,7 +12834,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12836 "configure" +#line 12837 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13070,6 +13071,147 @@ CC="$lt_save_CC" # Only expand once: +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _mwvalidcheckl in -lmw" >&5 +$as_echo_n "checking for _mwvalidcheckl in -lmw... " >&6; } +if ${ac_cv_lib_mw__mwvalidcheckl+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lmw $LIBS" +if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char _mwvalidcheckl (); +int +main () +{ +return _mwvalidcheckl (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_mw__mwvalidcheckl=yes +else + ac_cv_lib_mw__mwvalidcheckl=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mw__mwvalidcheckl" >&5 +$as_echo "$ac_cv_lib_mw__mwvalidcheckl" >&6; } +if test "x$ac_cv_lib_mw__mwvalidcheckl" = xyes; then : + LIBM="-lmw" +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 +$as_echo_n "checking for cos in -lm... " >&6; } +if ${ac_cv_lib_m_cos+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char cos (); +int +main () +{ +return cos (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_cos=yes +else + ac_cv_lib_m_cos=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 +$as_echo "$ac_cv_lib_m_cos" >&6; } +if test "x$ac_cv_lib_m_cos" = xyes; then : + LIBM="$LIBM -lm" +fi + + ;; +*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 +$as_echo_n "checking for cos in -lm... " >&6; } +if ${ac_cv_lib_m_cos+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char cos (); +int +main () +{ +return cos (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_cos=yes +else + ac_cv_lib_m_cos=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 +$as_echo "$ac_cv_lib_m_cos" >&6; } +if test "x$ac_cv_lib_m_cos" = xyes; then : + LIBM="-lm" +fi + + ;; +esac + + diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac index 523eb24..a775098 100644 --- a/libgfortran/configure.ac +++ b/libgfortran/configure.ac @@ -260,6 +260,7 @@ AC_PROG_INSTALL #AC_MSG_NOTICE([====== Starting libtool configuration]) AC_LIBTOOL_DLOPEN AM_PROG_LIBTOOL +LT_LIB_M ACX_LT_HOST_FLAGS AC_SUBST(enable_shared) AC_SUBST(enable_static) diff --git a/libgfortran/libgfortran.spec.in b/libgfortran/libgfortran.spec.in index 95aa3f8..367d485 100644 --- a/libgfortran/libgfortran.spec.in +++ b/libgfortran/libgfortran.spec.in @@ -5,4 +5,4 @@ # %rename lib liborig -*lib: @LIBQUADSPEC@ -lm %(libgcc) %(liborig) +*lib: @LIBQUADSPEC@ @LIBM@ %(libgcc) %(liborig) |