diff options
author | AlexGhiti <AlexGhiti@users.noreply.github.com> | 2022-03-30 14:41:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-30 08:41:43 -0400 |
commit | dd437d66fbe6fd7dae1dbd801175306e9ece5259 (patch) | |
tree | d2517e55d724a79cca64488986beea21cb966562 /configure.ac | |
parent | c41d8e0a012e6eef546c0ae3ceb1c763e7350a72 (diff) |
configure.ac: Unconditionally link against libatomic (#12366)
* configure.ac: Unconditionally link against libatomic
Indeed:
- if atomics are not needed, the library will be unused
- if atomics are needed, either atomics are fulfilled by the compiler builtins
and the library is unused or the library is needed anyway.
Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
* Add libatomic to required dependencies.
Co-authored-by: Austin S. Hemmelgarn <austin@netdata.cloud>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/configure.ac b/configure.ac index 812cdbb3a2..025e8d5380 100644 --- a/configure.ac +++ b/configure.ac @@ -1529,37 +1529,15 @@ if test "${enable_exporting_kinesis}" = "yes" -o \ "${new_cloud_protocol}" = "yes" -o \ "${build_ml}" = "yes"; then enable_cxx_linker="yes" - - # Try to unconditionally link with -latomic. If the compiler can satisfy - # all the atomic ops with builtins then, the library will be left unused. - # Otherwise, some ops will be covered by the compiler's intrinsics and some - # will be picked up by the linker from -latomic. In the later case, if - # -latomic is not available there will be a build failure, which would - # have happened either way before this change. - AC_LANG_PUSH([C++]) - - AC_MSG_CHECKING(whether we can use -latomic) - OLD_LIBS="${LIBS}" - LIBS="-latomic" - AC_LINK_IFELSE([AC_LANG_SOURCE([[ - #include <atomic> - #include <cstdint> - std::atomic<std::int64_t> v; - int main() { - return v; - } - ]])], CAN_USE_LIBATOMIC=yes, CAN_USE_LIBATOMIC=no) - LIBS="${OLD_LIBS}" - AC_MSG_RESULT($CAN_USE_LIBATOMIC) - - if test "x$CAN_USE_LIBATOMIC" = xyes; then - OPTIONAL_ATOMIC_LIBS="-latomic" - fi - AC_SUBST([OPTIONAL_ATOMIC_LIBS]) - - AC_LANG_POP([C++]) fi +# Unconditionally link with the libatomic since: +# - if atomics are not needed, the library will be unused +# - if atomics are needed, either atomics are fulfilled by the compiler builtins +# and the library is unused or the library is needed anyway. +OPTIONAL_ATOMIC_LIBS="-latomic" +AC_SUBST([OPTIONAL_ATOMIC_LIBS]) + AM_CONDITIONAL([ENABLE_CXX_LINKER], [test "${enable_cxx_linker}" = "yes"]) AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged]) |