diff --git a/configure.ac b/configure.ac index 45b82af9b..72239cbe3 100644 --- a/configure.ac +++ b/configure.ac @@ -79,6 +79,9 @@ AX_CHECK_COMPILE_FLAG([-std=c11], [CFLAGS="$CFLAGS -std=c11"]) gl_INIT +dnl Check if -latomic is required for +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], diff --git a/m4/l_atomic.m4 b/m4/l_atomic.m4 new file mode 100644 index 000000000..e423270ea --- /dev/null +++ b/m4/l_atomic.m4 @@ -0,0 +1,40 @@ +dnl Copyright (c) 2015 Tim Kosse +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 + #include + int main() { + std::atomic a{}; + int64_t v = 5; + int64_t r = a.fetch_add(v); + return static_cast(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 +]) diff --git a/python/Makefile.am b/python/Makefile.am index e97660dfb..ae5660a2f 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -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 diff --git a/tests/Makefile.am b/tests/Makefile.am index 26bd46288..7a1a5d03d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \