Commit e888a103 authored by Etienne Renault's avatar Etienne Renault

atomic: check if -latomic is required for std::atomic

* configure.ac,
m4/l_atomic.m4,
python/Makefile.am,
tests/Makefile.am: Here.
parent 7d36e2c1
Pipeline #19081 passed with stage
in 92 minutes and 53 seconds
......@@ -79,6 +79,9 @@ AX_CHECK_COMPILE_FLAG([-std=c11], [CFLAGS="$CFLAGS -std=c11"])
gl_INIT
dnl Check if -latomic is required for <std::atomic>
CHECK_ATOMIC
# Use -Werror since using -fvisibility under MinGW is only a warning.
# (The option is ignored anyway since this does not make sense under windows).
AX_CHECK_COMPILE_FLAG([-Werror -fvisibility=hidden],
......
dnl Copyright (c) 2015 Tim Kosse <tim.kosse@filezilla-project.org>
dnl Copying and distribution of this file, with or without modification, are
dnl permitted in any medium without royalty provided the copyright notice
dnl and this notice are preserved. This file is offered as-is, without any
dnl warranty.
# Some versions of gcc/libstdc++ require linking with -latomic if
# using the C++ atomic library.
#
# Sourced from http://bugs.debian.org/797228
m4_define([_CHECK_ATOMIC_testbody], [[
#include <atomic>
#include <cstdint>
int main() {
std::atomic<int64_t> a{};
int64_t v = 5;
int64_t r = a.fetch_add(v);
return static_cast<int>(r);
}
]])
AC_DEFUN([CHECK_ATOMIC], [
AC_LANG_PUSH(C++)
AC_MSG_CHECKING([whether std::atomic can be used without link library])
AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_ATOMIC_testbody])],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
LIBS="$LIBS -latomic"
AC_MSG_CHECKING([whether std::atomic needs -latomic])
AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_ATOMIC_testbody])],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
AC_MSG_FAILURE([cannot figure out how to use std::atomic])
])
])
AC_LANG_POP
])
......@@ -23,7 +23,7 @@
AUTOMAKE_OPTIONS = subdir-objects
AM_CPPFLAGS = -I$(PYTHONINC) -I$(top_builddir) -I$(top_srcdir) \
$(BUDDY_CPPFLAGS) -lpthread -latomic -DSWIG_TYPE_TABLE=spot
$(BUDDY_CPPFLAGS) -lpthread -DSWIG_TYPE_TABLE=spot
SWIGFLAGS = -c++ -python -py3 -O -MD
......@@ -71,7 +71,7 @@ am__depfiles_remade = ./$(DEPDIR)/buddy_wrap.Plo \
spot__impl_la_SOURCES = spot/impl_wrap.cxx
spot__impl_la_LDFLAGS = -avoid-version -module $(SYMBOLIC_LDFLAGS)
spot__impl_la_LIBADD = $(top_builddir)/spot/libspot.la -lpthread -latomic
spot__impl_la_LIBADD = $(top_builddir)/spot/libspot.la -lpthread
am__depfiles_remade += ./spot/$(DEPDIR)/impl_wrap.Pcxx
@AMDEP_TRUE@@am__include@ @am__quote@./spot/$(DEPDIR)/impl_wrap.Pcxx@am__quote@ # am--include-marker
......@@ -92,7 +92,7 @@ spot__ltsmin_la_SOURCES = spot/ltsmin_wrap.cxx
spot__ltsmin_la_LDFLAGS = -avoid-version -module $(SYMBOLIC_LDFLAGS)
spot__ltsmin_la_LIBADD = $(top_builddir)/spot/libspot.la \
$(top_builddir)/spot/ltsmin/libspotltsmin.la \
-lpthread -latomic
-lpthread
am__depfiles_remade += ./spot/$(DEPDIR)/ltsmin_wrap.Pcxx
@AMDEP_TRUE@@am__include@ @am__quote@./spot/$(DEPDIR)/ltsmin_wrap.Pcxx@am__quote@ # am--include-marker
......@@ -111,7 +111,7 @@ spot__gen_la_SOURCES = spot/gen_wrap.cxx
spot__gen_la_LDFLAGS = -avoid-version -module $(SYMBOLIC_LDFLAGS)
spot__gen_la_LIBADD = $(top_builddir)/spot/libspot.la \
$(top_builddir)/spot/gen/libspotgen.la \
-lpthread -latomic
-lpthread
am__depfiles_remade += ./spot/$(DEPDIR)/gen_wrap.Pcxx
@AMDEP_TRUE@@am__include@ @am__quote@./spot/$(DEPDIR)/gen_wrap.Pcxx@am__quote@ # am--include-marker
......
......@@ -27,7 +27,7 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) $(BUDDY_CPPFLAGS) \
AM_CXXFLAGS = $(WARNING_CXXFLAGS)
LDADD = $(top_builddir)/spot/libspot.la \
$(top_builddir)/buddy/src/libbddx.la \
$(LIBLTDL) -lpthread -latomic
$(LIBLTDL) -lpthread
# Explicitely set it to avoid default value ".test"
TEST_EXTENSIONS =
......@@ -461,7 +461,7 @@ check_PROGRAMS += ltsmin/modelcheck
check_PROGRAMS += ltsmin/testconvert
ltsmin_modelcheck_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) \
$(BUDDY_CPPFLAGS) \-I$(top_builddir)/lib -I$(top_srcdir)/lib
ltsmin_modelcheck_CXXFLAGS = $(CXXFLAGS) -pthread -latomic
ltsmin_modelcheck_CXXFLAGS = $(CXXFLAGS) -pthread
ltsmin_modelcheck_SOURCES = ltsmin/modelcheck.cc
ltsmin_modelcheck_LDADD = \
$(top_builddir)/bin/libcommon.a \
......@@ -471,7 +471,7 @@ ltsmin_modelcheck_LDADD = \
ltsmin_testconvert_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) \
$(BUDDY_CPPFLAGS) \-I$(top_builddir)/lib -I$(top_srcdir)/lib
ltsmin_testconvert_CXXFLAGS = $(CXXFLAGS) -pthread -latomic
ltsmin_testconvert_CXXFLAGS = $(CXXFLAGS) -pthread
ltsmin_testconvert_SOURCES = ltsmin/testconvert.cc
ltsmin_testconvert_LDADD = \
$(top_builddir)/bin/libcommon.a \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment