From 1064141967a2d22c2ae9e22ae77e8c9616559947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Wed, 30 Oct 2024 13:19:44 +0100 Subject: [PATCH] gh-91962: Fix `hstrerror` detection issues on Solaris (GH-91963) --- configure | 85 +++++++++++++++++++++++++++++++++++++++++++++++++-- configure.ac | 9 ++++-- pyconfig.h.in | 3 -- 3 files changed, 88 insertions(+), 9 deletions(-) diff --git a/configure b/configure index 70eea29620f..5be57e39309 100755 --- a/configure +++ b/configure @@ -20478,12 +20478,91 @@ fi printf "%s\n" "$ac_cv_lib_resolv_inet_aton" >&6; } if test "x$ac_cv_lib_resolv_inet_aton" = xyes then : - printf "%s\n" "#define HAVE_LIBRESOLV 1" >>confdefs.h + SOCKET_LIBS="-lresolv" +fi - LIBS="-lresolv $LIBS" fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for hstrerror in -lc" >&5 +printf %s "checking for hstrerror in -lc... " >&6; } +if test ${ac_cv_lib_c_hstrerror+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-lc $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. */ +char hstrerror (); +int +main (void) +{ +return hstrerror (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_c_hstrerror=yes +else $as_nop + ac_cv_lib_c_hstrerror=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_hstrerror" >&5 +printf "%s\n" "$ac_cv_lib_c_hstrerror" >&6; } +if test "x$ac_cv_lib_c_hstrerror" = xyes +then : + $ac_cv_prog_TRUE +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for hstrerror in -lresolv" >&5 +printf %s "checking for hstrerror in -lresolv... " >&6; } +if test ${ac_cv_lib_resolv_hstrerror+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-lresolv $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. */ +char hstrerror (); +int +main (void) +{ +return hstrerror (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_resolv_hstrerror=yes +else $as_nop + ac_cv_lib_resolv_hstrerror=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_hstrerror" >&5 +printf "%s\n" "$ac_cv_lib_resolv_hstrerror" >&6; } +if test "x$ac_cv_lib_resolv_hstrerror" = xyes +then : + SOCKET_LIBS="-lresolv" +fi + fi @@ -29988,7 +30067,7 @@ fi then : - + as_fn_append MODULE_BLOCK "MODULE__SOCKET_LDFLAGS=$SOCKET_LIBS$as_nl" fi if test "$py_cv_module__socket" = yes; then diff --git a/configure.ac b/configure.ac index 86e7075f07e..caf0244cc7b 100644 --- a/configure.ac +++ b/configure.ac @@ -5311,10 +5311,13 @@ AS_VAR_IF([ac_cv_broken_unsetenv], [yes], [ dnl check for true AC_CHECK_PROGS([TRUE], [true], [/bin/true]) -dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv +dnl On some systems (e.g. Solaris), hstrerror and inet_aton are in -lresolv dnl On others, they are in the C library, so we to take no action AC_CHECK_LIB([c], [inet_aton], [$ac_cv_prog_TRUE], - AC_CHECK_LIB([resolv], [inet_aton]) + AC_CHECK_LIB([resolv], [inet_aton], [SOCKET_LIBS="-lresolv"]) +) +AC_CHECK_LIB([c], [hstrerror], [$ac_cv_prog_TRUE], + AC_CHECK_LIB([resolv], [hstrerror], [SOCKET_LIBS="-lresolv"]) ) # On Tru64, chflags seems to be present, but calling it will @@ -7789,7 +7792,7 @@ PY_STDLIB_MOD([mmap], PY_STDLIB_MOD([_socket], [], m4_flatten([test "$ac_cv_header_sys_socket_h" = "yes" -a "$ac_cv_header_sys_types_h" = "yes" - -a "$ac_cv_header_netinet_in_h" = "yes"])) + -a "$ac_cv_header_netinet_in_h" = "yes"]), [], [$SOCKET_LIBS]) dnl platform specific extensions PY_STDLIB_MOD([grp], [], diff --git a/pyconfig.h.in b/pyconfig.h.in index fb9ab1e78dc..fcb8a965b1e 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -691,9 +691,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H -/* Define to 1 if you have the `resolv' library (-lresolv). */ -#undef HAVE_LIBRESOLV - /* Define to 1 if you have the `sendfile' library (-lsendfile). */ #undef HAVE_LIBSENDFILE