From: Rosen Penev Date: Tue, 28 May 2019 17:49:21 +0000 (-0700) Subject: Check if -latomic is needed instead of hardcoding X-Git-Tag: dnsdist-1.4.0-beta1~9^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1735eb98cd295c0aec2c2cd4cff436a786dbc70f;p=thirdparty%2Fpdns.git Check if -latomic is needed instead of hardcoding This avoids having a huge list of platforms which can change over time. --- diff --git a/m4/pdns_check_os.m4 b/m4/pdns_check_os.m4 index 40d266a91d..da4bc8fd11 100644 --- a/m4/pdns_check_os.m4 +++ b/m4/pdns_check_os.m4 @@ -35,16 +35,21 @@ AC_DEFUN([PDNS_CHECK_OS],[ AM_CONDITIONAL([HAVE_LINUX], [test "x$have_linux" = "xyes"]) AM_CONDITIONAL([HAVE_SOLARIS], [test "x$have_solaris" = "xyes"]) - case "$host" in - arc-* | mips* | powerpc-* ) - AC_MSG_CHECKING([whether the linker accepts -latomic]) - LDFLAGS="-latomic $LDFLAGS" - AC_LINK_IFELSE([m4_default([],[AC_LANG_PROGRAM()])], - [AC_MSG_RESULT([yes])], - [AC_MSG_ERROR([Unable to link against libatomic, cannot continue])] - ) - ;; - esac + AC_MSG_CHECKING([whether -latomic is needed for __atomic builtins]) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[uint64_t val = 0; __atomic_add_fetch(&val, 1, __ATOMIC_RELAXED);]] + )], + [AC_MSG_RESULT([no])], + [LIBS="$LIBS -latomic" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[uint64_t val = 0; __atomic_add_fetch(&val, 1, __ATOMIC_RELAXED);]] + )], + [AC_MSG_RESULT([yes])], + [AC_MSG_FAILURE([libatomic needed, but linking with -latomic failed, cannot continue])] + )] + ) AC_SUBST(THREADFLAGS) AC_SUBST([DYNLINKFLAGS], [-export-dynamic])