https://github.com/python/cpython/commit/8cf646adeab0e5a368cc2875068a725a324fc7c1
commit: 8cf646adeab0e5a368cc2875068a725a324fc7c1
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2024-10-15T11:29:03+02:00
summary:

[3.13] gh-125269: Use `AC_LINK_IF_ELSE` to detect if `-latomic` is needed 
(GH-125416) (#125493)

gh-125269: Use `AC_LINK_IF_ELSE` to detect if `-latomic` is needed (GH-125416)

We previously used `AC_RUN_IF_ELSE` with a short test program to detect
if `-latomic` is needed, but that requires choosing a specific default
value when cross-compiling because the test program is not run.
Some cross compilation targets like `wasm32-emscripten` do not support
`-latomic`, while other cross compilation targets, like
`arm-linux-gnueabi` require it.
(cherry picked from commit 8d42e2d915c3096e7eac1c649751d1da567bb7c3)

Co-authored-by: Sam Gross <[email protected]>

files:
A Misc/NEWS.d/next/Build/2024-10-13-21-11-30.gh-issue-125269.BC-fdo.rst
M configure
M configure.ac

diff --git 
a/Misc/NEWS.d/next/Build/2024-10-13-21-11-30.gh-issue-125269.BC-fdo.rst 
b/Misc/NEWS.d/next/Build/2024-10-13-21-11-30.gh-issue-125269.BC-fdo.rst
new file mode 100644
index 00000000000000..24f5469e8a664b
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2024-10-13-21-11-30.gh-issue-125269.BC-fdo.rst
@@ -0,0 +1,2 @@
+Fix detection of whether ``-latomic`` is needed when cross-compiling CPython
+using the configure script.
diff --git a/configure b/configure
index e1bfd73f24be96..82089e6256f75b 100755
--- a/configure
+++ b/configure
@@ -28618,10 +28618,6 @@ printf %s "checking whether libatomic is needed by 
<pyatomic.h>... " >&6; }
 if test ${ac_cv_libatomic_needed+y}
 then :
   printf %s "(cached) " >&6
-else $as_nop
-  if test "$cross_compiling" = yes
-then :
-    ac_cv_libatomic_needed=no
 else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -28663,16 +28659,14 @@ int main()
 }
 
 _ACEOF
-if ac_fn_c_try_run "$LINENO"
+if ac_fn_c_try_link "$LINENO"
 then :
   ac_cv_libatomic_needed=no
 else $as_nop
     ac_cv_libatomic_needed=yes
 fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
 fi
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libatomic_needed" 
>&5
 printf "%s\n" "$ac_cv_libatomic_needed" >&6; }
diff --git a/configure.ac b/configure.ac
index cfe9de0f7f3819..13dc9fa36de887 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7397,7 +7397,7 @@ CPPFLAGS="${BASECPPFLAGS} -I. -I${srcdir}/Include 
${CPPFLAGS}"
 
 AC_CACHE_CHECK([whether libatomic is needed by <pyatomic.h>],
                [ac_cv_libatomic_needed],
-[AC_RUN_IFELSE([AC_LANG_SOURCE([[
+[AC_LINK_IFELSE([AC_LANG_SOURCE([[
 // pyatomic.h needs uint64_t and Py_ssize_t types
 #include <stdint.h>  // int64_t, intptr_t
 #ifdef HAVE_SYS_TYPES_H
@@ -7434,9 +7434,8 @@ int main()
     return 0; // all good
 }
 ]])],
-  [ac_cv_libatomic_needed=no],  dnl build succeeded
-  [ac_cv_libatomic_needed=yes], dnl build failed
-  [ac_cv_libatomic_needed=no])  dnl cross compilation
+  [ac_cv_libatomic_needed=no],  dnl build and link succeeded
+  [ac_cv_libatomic_needed=yes]) dnl build and link failed
 ])
 
 AS_VAR_IF([ac_cv_libatomic_needed], [yes],

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to