Skip to content

Commit 8cf646a

Browse files
[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 8d42e2d) Co-authored-by: Sam Gross <[email protected]>
1 parent 4bc59e5 commit 8cf646a

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix detection of whether ``-latomic`` is needed when cross-compiling CPython
2+
using the configure script.

configure

+3-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

+3-4
Original file line numberDiff line numberDiff line change
@@ -7397,7 +7397,7 @@ CPPFLAGS="${BASECPPFLAGS} -I. -I${srcdir}/Include ${CPPFLAGS}"
73977397

73987398
AC_CACHE_CHECK([whether libatomic is needed by <pyatomic.h>],
73997399
[ac_cv_libatomic_needed],
7400-
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
7400+
[AC_LINK_IFELSE([AC_LANG_SOURCE([[
74017401
// pyatomic.h needs uint64_t and Py_ssize_t types
74027402
#include <stdint.h> // int64_t, intptr_t
74037403
#ifdef HAVE_SYS_TYPES_H
@@ -7434,9 +7434,8 @@ int main()
74347434
return 0; // all good
74357435
}
74367436
]])],
7437-
[ac_cv_libatomic_needed=no], dnl build succeeded
7438-
[ac_cv_libatomic_needed=yes], dnl build failed
7439-
[ac_cv_libatomic_needed=no]) dnl cross compilation
7437+
[ac_cv_libatomic_needed=no], dnl build and link succeeded
7438+
[ac_cv_libatomic_needed=yes]) dnl build and link failed
74407439
])
74417440

74427441
AS_VAR_IF([ac_cv_libatomic_needed], [yes],

0 commit comments

Comments
 (0)