From: Victor Stinner Date: Thu, 12 Sep 2024 14:21:31 +0000 (+0200) Subject: [3.12] gh-123917: Fix crypt check in configure (#123952) X-Git-Tag: v3.12.7~97 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=53af5b2dd2069680be4ce76626c857e9b2959f77;p=thirdparty%2FPython%2Fcpython.git [3.12] gh-123917: Fix crypt check in configure (#123952) Use a global volatile variable and check if the function is not NULL to use the variable. Otherwise, a compiler optimization can remove the variable making the check useless. Co-authored-by: Paul Smith --- diff --git a/Misc/NEWS.d/next/Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst b/Misc/NEWS.d/next/Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst new file mode 100644 index 000000000000..4cf4a177f151 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst @@ -0,0 +1,2 @@ +Fix the check for the ``crypt()`` function in the configure script. Patch by +Paul Smith and Victor Stinner. diff --git a/configure b/configure index 173674073ca5..1c75810d9e8c 100755 --- a/configure +++ b/configure @@ -22041,16 +22041,18 @@ else $as_nop #include #endif #include + volatile void *func; int main (void) { #ifdef HAVE_CRYPT_R - void *x = crypt_r; + func = crypt_r; #else - void *x = crypt; + func = crypt; #endif + return (func != NULL); ; return 0; diff --git a/configure.ac b/configure.ac index f22e71f46fea..d0d54050286c 100644 --- a/configure.ac +++ b/configure.ac @@ -5237,12 +5237,14 @@ WITH_SAVE_ENV([ #include #endif #include + volatile void *func; ], [ #ifdef HAVE_CRYPT_R - void *x = crypt_r; + func = crypt_r; #else - void *x = crypt; + func = crypt; #endif + return (func != NULL); ]) ], [ac_cv_crypt_crypt=yes], [ac_cv_crypt_crypt=no]) ])