summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimotej S <6674623+underhood@users.noreply.github.com>2021-08-09 12:57:18 +0200
committerGitHub <noreply@github.com>2021-08-09 12:57:18 +0200
commit8293d5ff56873c2ae33c7b7903ebbcfd9756d3f2 (patch)
tree10d6c7de6963aa3a6e214474eb89192cc306bb95
parent115de859288d150d7db7f7a466ddc2e635962e8d (diff)
Fix bundled protobuf linkage on systems needing -latomic (#11406)
* fix bundled protobuf on systems that need -latomic
-rw-r--r--Makefile.am14
-rw-r--r--configure.ac23
2 files changed, 31 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am
index 690b03b35d..480a104417 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -863,15 +863,17 @@ netdata_LDADD = \
$(NULL)
if ACLK_NG
- netdata_LDADD += $(OPTIONAL_PROTOBUF_LIBS)
+ netdata_LDADD += $(OPTIONAL_PROTOBUF_LIBS) \
+ $(OPTIONAL_ATOMIC_LIBS) \
+ $(NULL)
endif
if ACLK_LEGACY
-netdata_LDADD += \
- $(abs_top_srcdir)/externaldeps/mosquitto/libmosquitto.a \
- $(OPTIONAL_LWS_LIBS) \
- $(OPTIONAL_LIBCAP_LIBS) \
- $(NULL)
+ netdata_LDADD += \
+ $(abs_top_srcdir)/externaldeps/mosquitto/libmosquitto.a \
+ $(OPTIONAL_LWS_LIBS) \
+ $(OPTIONAL_LIBCAP_LIBS) \
+ $(NULL)
endif #ACLK_LEGACY
if ENABLE_CXX_LINKER
diff --git a/configure.ac b/configure.ac
index 0c3a960525..d3b13231a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -757,6 +757,29 @@ if test "$enable_cloud" != "no" -a "$aclk_ng" != "no"; then
else
AC_MSG_RESULT([yes])
fi
+
+ if test "${with_bundled_protobuf}" = "yes"; then
+ AC_LANG_PUSH([C++])
+ CXXFLAGS="${CXXFLAGS} -std=c++11"
+
+ # On some platforms, std::atomic needs a helper library
+ AC_MSG_CHECKING(whether -latomic is needed for static protobuf)
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+ #include <atomic>
+ #include <cstdint>
+ std::atomic<std::int64_t> v;
+ int main() {
+ return v;
+ }
+ ]])], STD_ATOMIC_NEED_LIBATOMIC=no, STD_ATOMIC_NEED_LIBATOMIC=yes)
+ AC_MSG_RESULT($STD_ATOMIC_NEED_LIBATOMIC)
+ if test "x$STD_ATOMIC_NEED_LIBATOMIC" = xyes; then
+ OPTIONAL_ATOMIC_LIBS="-latomic"
+ fi
+ AC_SUBST([OPTIONAL_ATOMIC_LIBS])
+ AC_LANG_POP([C++])
+ fi
+
AC_MSG_CHECKING([ACLK Next Generation can be built])
AC_MSG_RESULT([${can_enable_ng}])
if test "$can_enable_ng" = "no" -a "$aclk_ng" = "yes"; then