Skip to content

Commit 8d42e2d

Browse files
authored
gh-125269: Use AC_LINK_IF_ELSE to detect if -latomic is needed (#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.
1 parent 0b28ea4 commit 8d42e2d

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
@@ -7497,7 +7497,7 @@ CPPFLAGS="${BASECPPFLAGS} -I. -I${srcdir}/Include ${CPPFLAGS}"
74977497

74987498
AC_CACHE_CHECK([whether libatomic is needed by <pyatomic.h>],
74997499
[ac_cv_libatomic_needed],
7500-
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
7500+
[AC_LINK_IFELSE([AC_LANG_SOURCE([[
75017501
// pyatomic.h needs uint64_t and Py_ssize_t types
75027502
#include <stdint.h> // int64_t, intptr_t
75037503
#ifdef HAVE_SYS_TYPES_H
@@ -7534,9 +7534,8 @@ int main()
75347534
return 0; // all good
75357535
}
75367536
]])],
7537-
[ac_cv_libatomic_needed=no], dnl build succeeded
7538-
[ac_cv_libatomic_needed=yes], dnl build failed
7539-
[ac_cv_libatomic_needed=no]) dnl cross compilation
7537+
[ac_cv_libatomic_needed=no], dnl build and link succeeded
7538+
[ac_cv_libatomic_needed=yes]) dnl build and link failed
75407539
])
75417540

75427541
AS_VAR_IF([ac_cv_libatomic_needed], [yes],

0 commit comments

Comments
 (0)