Skip to content

Commit e9119e9

Browse files
jpalusben717-linux
authored andcommitted
Check and link libatomic if needed
Some architectures without native support for 64-bit atomics need linking with libatomic.
1 parent f9481e1 commit e9119e9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

configure.ac

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,19 @@ CXX="$PTHREAD_CXX"
9292
])
9393

9494
# Atomics
95-
AC_CHECK_HEADERS([stdatomic.h])
95+
AC_CHECK_HEADERS([stdatomic.h],
96+
[AC_MSG_CHECKING([whether libatomic is required])
97+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdatomic.h>]], [[atomic_uint_fast64_t i; i++;]])],
98+
[AC_MSG_RESULT([no])],
99+
[save_LIBS="$LIBS"
100+
LIBS="$LIBS -latomic"
101+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdatomic.h>]], [[atomic_uint_fast64_t i; i++;]])],
102+
[AC_MSG_RESULT([yes])],
103+
[AC_MSG_ERROR([failed to find working configuration with atomics])]
104+
)]
105+
)],
106+
[]
107+
)
96108

97109
# Check for poll.h (it's in POSIX so everyone should have it?)
98110
AC_CHECK_HEADERS([poll.h])

0 commit comments

Comments
 (0)