public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3186] libgfortran: Use the libtool macro to determine libm availability.
@ 2021-08-27 15:50 Iain D Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2021-08-27 15:50 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9b025925eceaf207e3d0104cddace753ac6dabd5

commit r12-3186-g9b025925eceaf207e3d0104cddace753ac6dabd5
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sun Mar 28 15:39:33 2021 +0100

    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.

Diff:
---
 libgfortran/Makefile.am         |   2 +-
 libgfortran/Makefile.in         |   3 +-
 libgfortran/configure           | 146 +++++++++++++++++++++++++++++++++++++++-
 libgfortran/configure.ac        |   1 +
 libgfortran/libgfortran.spec.in |   2 +-
 5 files changed, 149 insertions(+), 5 deletions(-)

diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
index 8d104321567..6fc4b465c6e 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 afe1ed17cb4..6fc9bafe07a 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 886216f69d4..4810b9b032e 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 523eb24bca1..a77509801e6 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 95aa3f842a3..367d485c230 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)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-27 15:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27 15:50 [gcc r12-3186] libgfortran: Use the libtool macro to determine libm availability Iain D Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).