public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/gccgo] libphobos: Remove AC_CACHE_CHECK from network library tests.
@ 2020-07-12 17:34 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2020-07-12 17:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5e7f8c55c2ca634cec729d2d3fa0f2c13614168c

commit 5e7f8c55c2ca634cec729d2d3fa0f2c13614168c
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Apr 27 02:09:43 2020 +0200

    libphobos: Remove AC_CACHE_CHECK from network library tests.
    
    libphobos/ChangeLog:
    
            * configure: Regenerate.
            * m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_NET): Remove
            AC_CACHE_CHECK, simplify by setting LIBS directly.

Diff:
---
 libphobos/configure                | 103 +++++++++++++++++--------------------
 libphobos/m4/druntime/libraries.m4 |  51 +++++++++---------
 2 files changed, 72 insertions(+), 82 deletions(-)

diff --git a/libphobos/configure b/libphobos/configure
index c923417532f..98d8dc255c1 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -14932,25 +14932,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 fi
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket libraries" >&5
-$as_echo_n "checking for socket libraries... " >&6; }
-if ${druntime_cv_lib_sockets+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  druntime_cv_lib_sockets=
-     druntime_check_both=no
-     ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect"
+                            druntime_check_both=no
+  ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect"
 if test "x$ac_cv_func_connect" = xyes; then :
-  druntime_check_socket=no
-else
-  druntime_check_socket=yes
-fi
 
-     if test "$druntime_check_socket" = "yes"; then
-       unset ac_cv_func_connect
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsocket" >&5
-$as_echo_n "checking for main in -lsocket... " >&6; }
-if ${ac_cv_lib_socket_main+:} false; then :
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5
+$as_echo_n "checking for connect in -lsocket... " >&6; }
+if ${ac_cv_lib_socket_connect+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -14958,55 +14947,58 @@ LIBS="-lsocket  $LIBS"
 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 connect ();
 int
 main ()
 {
-return main ();
+return connect ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_socket_main=yes
+  ac_cv_lib_socket_connect=yes
 else
-  ac_cv_lib_socket_main=no
+  ac_cv_lib_socket_connect=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_socket_main" >&5
-$as_echo "$ac_cv_lib_socket_main" >&6; }
-if test "x$ac_cv_lib_socket_main" = xyes; then :
-  druntime_cv_lib_sockets="-lsocket"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5
+$as_echo "$ac_cv_lib_socket_connect" >&6; }
+if test "x$ac_cv_lib_socket_connect" = xyes; then :
+  LIBS="$LIBS -lsocket"
 else
   druntime_check_both=yes
 fi
 
-     fi
-     if test "$druntime_check_both" = "yes"; then
-       druntime_old_libs=$LIBS
-       LIBS="$LIBS -lsocket -lnsl"
-       unset ac_cv_func_accept
-       ac_fn_c_check_func "$LINENO" "accept" "ac_cv_func_accept"
+fi
+
+  if test "$druntime_check_both" = "yes"; then
+    druntime_old_libs=$LIBS
+    LIBS="$LIBS -lsocket -lnsl"
+    ac_fn_c_check_func "$LINENO" "accept" "ac_cv_func_accept"
 if test "x$ac_cv_func_accept" = xyes; then :
-  druntime_check_nsl=no
-		      druntime_cv_lib_sockets="-lsocket -lnsl"
+
+else
+  LIBS=$druntime_old_libs
 fi
 
-       unset ac_cv_func_accept
-       LIBS=$druntime_old_libs
-     fi
-     unset ac_cv_func_gethostbyname
-     druntime_old_libs="$LIBS"
-     ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname"
+  fi
+  ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname"
 if test "x$ac_cv_func_gethostbyname" = xyes; then :
 
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lnsl" >&5
-$as_echo_n "checking for main in -lnsl... " >&6; }
-if ${ac_cv_lib_nsl_main+:} false; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5
+$as_echo_n "checking for gethostbyname in -lnsl... " >&6; }
+if ${ac_cv_lib_nsl_gethostbyname+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -15014,38 +15006,39 @@ LIBS="-lnsl  $LIBS"
 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 gethostbyname ();
 int
 main ()
 {
-return main ();
+return gethostbyname ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_nsl_main=yes
+  ac_cv_lib_nsl_gethostbyname=yes
 else
-  ac_cv_lib_nsl_main=no
+  ac_cv_lib_nsl_gethostbyname=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_nsl_main" >&5
-$as_echo "$ac_cv_lib_nsl_main" >&6; }
-if test "x$ac_cv_lib_nsl_main" = xyes; then :
-  druntime_cv_lib_sockets="$druntime_cv_lib_sockets -lnsl"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5
+$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; }
+if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then :
+  LIBS="$LIBS -lnsl"
 fi
 
 fi
 
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $druntime_cv_lib_sockets" >&5
-$as_echo "$druntime_cv_lib_sockets" >&6; }
-  LIBS="$LIBS $druntime_cv_lib_sockets"
-
 
   # Keep this in sync with core/thread.d, set druntime_fiber_asm_external to
   # "yes" for targets that have 'version = AsmExternal'.
diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4
index 957bf98b442..743d3e3e17c 100644
--- a/libphobos/m4/druntime/libraries.m4
+++ b/libphobos/m4/druntime/libraries.m4
@@ -21,33 +21,30 @@ AC_DEFUN([DRUNTIME_LIBRARIES_DLOPEN],
 # Autodetect and add networking library to LIBS if necessary.
 AC_DEFUN([DRUNTIME_LIBRARIES_NET],
 [
-  dnl Test for -lsocket and -lnsl.  Copied from libjava/configure.ac.
-  AC_CACHE_CHECK([for socket libraries], druntime_cv_lib_sockets,
-    [druntime_cv_lib_sockets=
-     druntime_check_both=no
-     AC_CHECK_FUNC(connect, druntime_check_socket=no, druntime_check_socket=yes)
-     if test "$druntime_check_socket" = "yes"; then
-       unset ac_cv_func_connect
-       AC_CHECK_LIB(socket, main, druntime_cv_lib_sockets="-lsocket",
-		    druntime_check_both=yes)
-     fi
-     if test "$druntime_check_both" = "yes"; then
-       druntime_old_libs=$LIBS
-       LIBS="$LIBS -lsocket -lnsl"
-       unset ac_cv_func_accept
-       AC_CHECK_FUNC(accept,
-		     [druntime_check_nsl=no
-		      druntime_cv_lib_sockets="-lsocket -lnsl"])
-       unset ac_cv_func_accept
-       LIBS=$druntime_old_libs
-     fi
-     unset ac_cv_func_gethostbyname
-     druntime_old_libs="$LIBS"
-     AC_CHECK_FUNC(gethostbyname, ,
-		   [AC_CHECK_LIB(nsl, main,
-		    [druntime_cv_lib_sockets="$druntime_cv_lib_sockets -lnsl"])])
-  ])
-  LIBS="$LIBS $druntime_cv_lib_sockets"
+  dnl Check for the existence of the -lsocket and -lnsl libraries.
+  dnl The order here is important, so that they end up in the right
+  dnl order in the command line generated by make.  Here are some
+  dnl special considerations:
+  dnl 1. Use "connect" and "accept" to check for -lsocket, and
+  dnl    "gethostbyname" to check for -lnsl.
+  dnl 2. Use each function name only once:  can't redo a check because
+  dnl    autoconf caches the results of the last check and won't redo it.
+  dnl 3. Use -lnsl and -lsocket only if they supply procedures that
+  dnl    aren't already present in the normal libraries.
+  dnl 4. On some systems, can't use -lsocket without -lnsl too.
+  dnl    To get around this problem, check for both libraries together
+  dnl    if -lsocket doesn't work by itself.
+  druntime_check_both=no
+  AC_CHECK_FUNC(connect, ,
+	[AC_CHECK_LIB(socket, connect,
+	 LIBS="$LIBS -lsocket", druntime_check_both=yes)])
+  if test "$druntime_check_both" = "yes"; then
+    druntime_old_libs=$LIBS
+    LIBS="$LIBS -lsocket -lnsl"
+    AC_CHECK_FUNC(accept, , LIBS=$druntime_old_libs)
+  fi
+  AC_CHECK_FUNC(gethostbyname, ,
+	[AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")])
 ])
 
 # DRUNTIME_LIBRARIES_ZLIB


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

only message in thread, other threads:[~2020-07-12 17:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-12 17:34 [gcc/devel/gccgo] libphobos: Remove AC_CACHE_CHECK from network library tests Ian Lance Taylor

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).