diff --git a/Misc/NEWS.d/next/Build/2021-11-15-16-42-10.bpo-45808.Aoe8Fn.rst b/Misc/NEWS.d/next/Build/2021-11-15-16-42-10.bpo-45808.Aoe8Fn.rst new file mode 100644 index 00000000000000..a7e55b7a1382d7 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-11-15-16-42-10.bpo-45808.Aoe8Fn.rst @@ -0,0 +1 @@ +Correct check for ``crypt_r`` on platforms without ``crypt.h``. diff --git a/configure b/configure index 53dc4a23f80631..b79ab18ff51b79 100755 --- a/configure +++ b/configure @@ -14052,9 +14052,9 @@ done # We search for both crypt and crypt_r as one or the other may be defined -# This gets us our -lcrypt in LIBS when required on the target platform. -# Save/restore LIBS to avoid linking libpython with libcrypt. +# Some platforms have crypt.h, others like FreeBSD have crypt*() in unistd.h LIBS_SAVE=$LIBS +LIBCRYPT= { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt_r" >&5 $as_echo_n "checking for library containing crypt_r... " >&6; } if ${ac_cv_search_crypt_r+:} false; then : @@ -14109,6 +14109,13 @@ ac_res=$ac_cv_search_crypt_r if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +$as_echo "#define HAVE_CRYPT_R 1" >>confdefs.h + + if test "$ac_cv_search_crypt_r" != "none required"; then + LIBCRYPT="$ac_cv_search_crypt_r" + fi + fi LIBS="$LIBS_SAVE" @@ -14166,35 +14173,17 @@ ac_res=$ac_cv_search_crypt if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" -fi - - -ac_fn_c_check_func "$LINENO" "crypt_r" "ac_cv_func_crypt_r" -if test "x$ac_cv_func_crypt_r" = xyes; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include - -int -main () -{ - -struct crypt_data d; -char *r = crypt_r("", "", &d); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -$as_echo "#define HAVE_CRYPT_R 1" >>confdefs.h + if test "$ac_cv_search_crypt" != "none required"; then + LIBCRYPT="$ac_cv_search_crypt" + fi fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt(_r) linker argument" >&5 +$as_echo_n "checking for crypt(_r) linker argument... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBCRYPT" >&5 +$as_echo "$LIBCRYPT" >&6; } LIBS=$LIBS_SAVE diff --git a/configure.ac b/configure.ac index f43030e481068e..545f7b8c6a15b9 100644 --- a/configure.ac +++ b/configure.ac @@ -4072,23 +4072,25 @@ AC_CHECK_FUNCS(setpgrp, ) # We search for both crypt and crypt_r as one or the other may be defined -# This gets us our -lcrypt in LIBS when required on the target platform. -# Save/restore LIBS to avoid linking libpython with libcrypt. +# Some platforms have crypt.h, others like FreeBSD have crypt*() in unistd.h LIBS_SAVE=$LIBS -AC_SEARCH_LIBS(crypt_r, crypt) +LIBCRYPT= +AC_SEARCH_LIBS([crypt_r], [crypt], [ + AC_DEFINE(HAVE_CRYPT_R, 1, [Define if you have the crypt_r() function.]) + if test "$ac_cv_search_crypt_r" != "none required"; then + LIBCRYPT="$ac_cv_search_crypt_r" + fi +]) LIBS="$LIBS_SAVE" -AC_SEARCH_LIBS(crypt, crypt) +AC_SEARCH_LIBS([crypt], [crypt], [ + if test "$ac_cv_search_crypt" != "none required"; then + LIBCRYPT="$ac_cv_search_crypt" + fi +]) + +AC_MSG_CHECKING([for crypt(_r) linker argument]) +AC_MSG_RESULT([$LIBCRYPT]) -AC_CHECK_FUNC(crypt_r, - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[ -struct crypt_data d; -char *r = crypt_r("", "", &d); -]])], - [AC_DEFINE(HAVE_CRYPT_R, 1, [Define if you have the crypt_r() function.])], - []) -) LIBS=$LIBS_SAVE AC_CHECK_FUNCS(clock_gettime, [], [