diff options
author | Ilias Tsitsimpis <iliastsi@debian.org> | 2021-10-24 14:47:55 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-25 08:34:54 -0500 |
commit | 774fc4d63f920d4f8057450c3d50a483b025a536 (patch) | |
tree | 7ec6ac06cd5fbef2217320c262239d3eea0730b8 | |
parent | bd92c9b207143532827008ec2ea1be55f30843cb (diff) | |
download | haskell-774fc4d63f920d4f8057450c3d50a483b025a536.tar.gz |
Link against libatomic for 64-bit atomic operations
Some platforms (e.g., armel) require linking against libatomic for
64-bit atomic operations.
Fixes #20549
-rw-r--r-- | m4/fp_cc_supports__atomics.m4 | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/m4/fp_cc_supports__atomics.m4 b/m4/fp_cc_supports__atomics.m4 index 6a6b16b92b..f4a2eaff7c 100644 --- a/m4/fp_cc_supports__atomics.m4 +++ b/m4/fp_cc_supports__atomics.m4 @@ -8,27 +8,53 @@ AC_DEFUN([FP_CC_SUPPORTS__ATOMICS], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y;]], [[__atomic_load(&x, &y, __ATOMIC_SEQ_CST); return y]])], [ AC_MSG_RESULT(yes) + + need_latomic=0 AC_MSG_CHECKING(whether -latomic is needed for sub-word-sized atomic operations) AC_LINK_IFELSE([AC_LANG_PROGRAM([[unsigned char a;]], [[__atomic_fetch_or(&a, 1, __ATOMIC_RELAXED);]])], [ AC_MSG_RESULT(no) - AC_SUBST([CabalNeedLibatomic],[False]) - need_latomic=0 ], [ - _save_LIBS=$LIBS + _save_LIBS="$LIBS" LIBS="-latomic" AC_LINK_IFELSE([AC_LANG_PROGRAM([[unsigned char a;]], [[__atomic_fetch_or(&a, 1, __ATOMIC_RELAXED);]])], [ AC_MSG_RESULT(yes) - AC_SUBST([CabalNeedLibatomic],[True]) need_latomic=1 ], [ AC_MSG_RESULT(failed) AC_MSG_ERROR([sub-word-sized atomic operations are not available.]) ]) - LIBS=$_save_LIBS + LIBS="$_save_LIBS" + ]) + AC_MSG_CHECKING(whether -latomic is needed for 64-bit atomic operations) + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ + #include <inttypes.h> + uint64_t a; + ]], [[__atomic_fetch_or(&a, 1, __ATOMIC_RELAXED);]])], + [ + AC_MSG_RESULT(no) + ], + [ + _save_LIBS="$LIBS" + LIBS="-latomic" + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ + #include <inttypes.h> + uint64_t a; + ]], [[__atomic_fetch_or(&a, 1, __ATOMIC_RELAXED);]])], + [ + AC_MSG_RESULT(yes) + need_latomic=1 + ], + [ + AC_MSG_RESULT(failed) + AC_MSG_ERROR([64-bit atomic operations are not available.]) + ]) + LIBS="$_save_LIBS" ]) ], [ @@ -36,6 +62,11 @@ AC_DEFUN([FP_CC_SUPPORTS__ATOMICS], AC_MSG_ERROR([C compiler needs to support __atomic primitives.]) ]) AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?]) + if test "$need_latomic" = 1; then + AC_SUBST([CabalNeedLibatomic],[True]) + else + AC_SUBST([CabalNeedLibatomic],[False]) + fi AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic], - [Define to 1 if we need -latomic for sub-word atomic operations.]) + [Define to 1 if we need -latomic.]) ]) |