[vlc-devel] [PATCH] configure: check the C compiler needs -latomic to support atomics
Steve Lhomme
robux4 at ycbcr.xyz
Mon Jan 13 13:50:49 CET 2020
At least gcc 8 for the Raspberry Pi needs it.
---
configure.ac | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/configure.ac b/configure.ac
index c2a2a231cee..a7cf39d2174 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,6 +70,23 @@ AC_C_INLINE
AC_C_RESTRICT
AX_CXX_COMPILE_STDCXX_14([noext], [mandatory])
+dnl Check the compiler supports atomics in C
+AC_MSG_CHECKING([C atomics])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdatomic.h>],[
+atomic_uintmax_t test;
+atomic_init(&test, 0);
+atomic_fetch_add_explicit(&test, 2u, memory_order_relaxed);
+])], [AC_MSG_RESULT([built-in])], [
+ LDFLAGS="$LDFLAGS -latomic"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdatomic.h>],[
+atomic_uintmax_t test;
+atomic_init(&test, 0);
+atomic_fetch_add_explicit(&test, 2u, memory_order_relaxed);
+])],[AC_MSG_RESULT([using -latomic])],[
+ AC_MSG_ERROR([VLC requires atomics support])
+ ])
+])
+
dnl Extend the --help string at the current spot.
AC_DEFUN([EXTEND_HELP_STRING], [m4_divert_once([HELP_ENABLE], [$1])])
--
2.17.1
More information about the vlc-devel
mailing list