summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorHaochen Tong <i@hexchain.org>2021-10-11 11:40:56 +0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-12 19:17:53 -0400
commit90f06a0e015e18c066fe1569fb2add318bec72ca (patch)
treec9ab2f2530ce13e136d7085b66f7920c50777863 /configure.ac
parent82938981a7916c2747ee3b97624c55f7c5467c84 (diff)
downloadhaskell-90f06a0e015e18c066fe1569fb2add318bec72ca.tar.gz
Check for libatomic dependency for atomic operations
Some platforms (e.g. RISC-V) require linking against libatomic for some (e.g. sub-word-sized) atomic operations. Fixes #19119.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac26
1 files changed, 26 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index a1a561d70e..cde0637d1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1189,6 +1189,32 @@ AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])],
FP_CHECK_PTHREADS
+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
+ 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_SUBST([CabalNeedLibatomic],[False])
+ AC_MSG_ERROR([sub-word-sized atomic operations not available.])
+ need_latomic=0
+ ])
+ LIBS=$_save_LIBS
+ ])
+AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
+ [Define to 1 if we need -latomic for sub-word atomic operations.])
+
dnl ** check for eventfd which is needed by the I/O manager
AC_CHECK_HEADERS([sys/eventfd.h])
AC_CHECK_FUNCS([eventfd])