From 1735eb98cd295c0aec2c2cd4cff436a786dbc70f Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 28 May 2019 10:49:21 -0700 Subject: [PATCH] Check if -latomic is needed instead of hardcoding This avoids having a huge list of platforms which can change over time. --- m4/pdns_check_os.m4 | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/m4/pdns_check_os.m4 b/m4/pdns_check_os.m4 index 40d266a91..da4bc8fd1 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]) -- 2.40.0