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>
AlexGhiti committed
Mar 30, 2022 at 14:41 UTC
dd437d66fbe6fd7dae1dbd801175306e9ece5259
10 files changed
+29
-29
configure.ac
+7
-29
@@ -1529,37 +1529,15 @@ if test "${enable_exporting_kinesis}" = "yes" -o \
1529
"${new_cloud_protocol}" = "yes" -o \
1530
"${build_ml}" = "yes"; then
1531
enable_cxx_linker="yes"
1532
-
1533
- # Try to unconditionally link with -latomic. If the compiler can satisfy
1534
- # all the atomic ops with builtins then, the library will be left unused.
1535
- # Otherwise, some ops will be covered by the compiler's intrinsics and some
1536
- # will be picked up by the linker from -latomic. In the later case, if
1537
- # -latomic is not available there will be a build failure, which would
1538
- # have happened either way before this change.
1539
- AC_LANG_PUSH([C++])
1540
-
1541
- AC_MSG_CHECKING(whether we can use -latomic)
1542
- OLD_LIBS="${LIBS}"
1543
- LIBS="-latomic"
1544
- AC_LINK_IFELSE([AC_LANG_SOURCE([[
1545
- #include <atomic>
1546
- #include <cstdint>
1547
- std::atomic<std::int64_t> v;
1548
- int main() {
1549
- return v;
1550
- }
1551
- ]])], CAN_USE_LIBATOMIC=yes, CAN_USE_LIBATOMIC=no)
1552
- LIBS="${OLD_LIBS}"
1553
- AC_MSG_RESULT($CAN_USE_LIBATOMIC)
1554
-
1555
- if test "x$CAN_USE_LIBATOMIC" = xyes; then
1556
- OPTIONAL_ATOMIC_LIBS="-latomic"
1557
- fi
1558
- AC_SUBST([OPTIONAL_ATOMIC_LIBS])
1559
-
1560
- AC_LANG_POP([C++])
1532
fi
1533
1534
+# Unconditionally link with the libatomic since:
1535
+# - if atomics are not needed, the library will be unused
1536
+# - if atomics are needed, either atomics are fulfilled by the compiler builtins
1537
+# and the library is unused or the library is needed anyway.
1538
+OPTIONAL_ATOMIC_LIBS="-latomic"
1539
+AC_SUBST([OPTIONAL_ATOMIC_LIBS])
1540
+
1541
AM_CONDITIONAL([ENABLE_CXX_LINKER], [test "${enable_cxx_linker}" = "yes"])
1542
1543
AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
packaging/installer/dependencies/alpine.sh
+1
@@ -16,6 +16,7 @@ package_tree="
16
autoconf
17
cmake
18
make
19
+ libatomic
20
libtool
21
pkgconfig
22
tar
packaging/installer/dependencies/centos.sh
+1
@@ -12,6 +12,7 @@ declare -a package_tree=(
12
autoconf-archive
13
autogen
14
automake
15
+ libatomic
16
libtool
17
pkgconfig
18
cmake
packaging/installer/dependencies/debian.sh
+1
@@ -17,6 +17,7 @@ package_tree="
17
autoconf
18
autoconf-archive
19
autogen
20
+ libatomic1
21
libtool
22
pkg-config
23
tar
packaging/installer/dependencies/fedora.sh
+1
@@ -32,6 +32,7 @@ declare -a package_tree=(
32
autoconf-archive
33
autogen
34
automake
35
+ libatomic
36
libtool
37
cmake
38
nmap-ncat
packaging/installer/dependencies/ol.sh
+1
@@ -15,6 +15,7 @@ declare -a package_tree=(
15
autoconf-archive
16
autogen
17
automake
18
+ libatomic
19
libtool
20
pkgconfig
21
cmake
packaging/installer/dependencies/opensuse.sh
+1
@@ -17,6 +17,7 @@ declare -a package_tree=(
17
autoconf-archive
18
autogen
19
automake
20
+ libatomic1
21
libtool
22
pkg-config
23
cmake
packaging/installer/dependencies/rockylinux.sh
+1
@@ -15,6 +15,7 @@ declare -a package_tree=(
15
autoconf-archive
16
autogen
17
automake
18
+ libatomic
19
libtool
20
pkgconfig
21
cmake
packaging/installer/dependencies/ubuntu.sh
+1
@@ -17,6 +17,7 @@ package_tree="
17
autoconf
18
autoconf-archive
19
autogen
20
+ libatomic1
21
libtool
22
pkg-config
23
tar
packaging/installer/install-required-packages.sh
+14
@@ -699,6 +699,19 @@ declare -A pkg_json_c_dev=(
699
['default']="json-c-devel"
700
)
701
702
+declare -A pkg_libatomic=(
703
+ ['arch']="NOTREQUIRED"
704
+ ['clearlinux']="NOTREQUIRED"
705
+ ['debian']="libatomic1"
706
+ ['freebsd']="NOTREQUIRED"
707
+ ['gentoo']="NOTREQUIRED"
708
+ ['macos']="NOTREQUIRED"
709
+ ['sabayon']="NOTREQUIRED"
710
+ ['suse']="libatomic1"
711
+ ['ubuntu']="libatomic1"
712
+ ['default']="libatomic"
713
+)
714
+
715
declare -A pkg_bridge_utils=(
716
['gentoo']="net-misc/bridge-utils"
717
['clearlinux']="network-basic"
@@ -1339,6 +1352,7 @@ packages() {
1352
# basic build environment
1353
1354
suitable_package distro-sdk
1355
+ suitable_package libatomic
1356
1357
require_cmd git || suitable_package git
1358
require_cmd find || suitable_package find