[vlc-commits] configure: check the C compiler needs -latomic to support atomics
Steve Lhomme
git at videolan.org
Tue Mar 24 16:04:31 CET 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Jan 13 13:24:41 2020 +0100| [274b32c1a6f6416660d65e5f29d733e7d962e178] | committer: Steve Lhomme
configure: check the C compiler needs -latomic to support atomics
At least gcc 8 for the Raspberry Pi needs it.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=274b32c1a6f6416660d65e5f29d733e7d962e178
---
configure.ac | 24 ++++++++++++++++++++++++
src/Makefile.am | 2 +-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 7ae5cdaf31..1e70a6ad33 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,6 +70,30 @@ 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])
+VLC_SAVE_FLAGS
+ATOMIC_LIB=""
+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])
+ ATOMIC_LIB="-latomic"
+ ],[
+ AC_MSG_ERROR([VLC requires atomics support])
+ ])
+])
+VLC_RESTORE_FLAGS
+AC_SUBST([ATOMIC_LIB])
+
dnl Extend the --help string at the current spot.
AC_DEFUN([EXTEND_HELP_STRING], [m4_divert_once([HELP_ENABLE], [$1])])
diff --git a/src/Makefile.am b/src/Makefile.am
index 2b4dfcb7dd..0760faeef9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -393,7 +393,7 @@ libvlccore_la_SOURCES = \
libvlccore_la_LIBADD = $(LIBS_libvlccore) \
../compat/libcompat.la \
$(LTLIBINTL) $(LTLIBICONV) \
- $(IDN_LIBS) $(SOCKET_LIBS) $(LIBRT) $(LIBDL) $(LIBM)
+ $(IDN_LIBS) $(SOCKET_LIBS) $(ATOMIC_LIB) $(LIBRT) $(LIBDL) $(LIBM)
if HAVE_WIN32
libvlccore_la_SOURCES += \
More information about the vlc-commits
mailing list