summaryrefslogtreecommitdiff
path: root/aclocal.m4
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2018-02-03 11:37:01 -0500
committerBen Gamari <ben@smart-cactus.org>2018-02-03 11:37:14 -0500
commit217e4170bdce3df28a667803ce5e619553bfecdd (patch)
tree1e548bae29aecc72ce257dc962025c1388a7a7b5 /aclocal.m4
parentfdf518c708dc5a34ae810c5d5f3a4db812d226f0 (diff)
downloadhaskell-217e4170bdce3df28a667803ce5e619553bfecdd.tar.gz
ghc-prim: Emulate C11 atomics when not available
GCC's __sync primitives apparently "usually" imply a full barrier, meaning they can be used to emulate the more precise C11 atomics albeit with a loss of efficiency. This restores compatibility with GCC 4.4. This partially reverts commit 59de290928e6903337f31c1f8107ac8a98ea145d. Test Plan: Validate on Centos Reviewers: hvr, simonmar, trommler Subscribers: rwbarton, thomie, erikd, carter GHC Trac Issues: #14244 Differential Revision: https://phabricator.haskell.org/D4364
Diffstat (limited to 'aclocal.m4')
-rw-r--r--aclocal.m425
1 files changed, 23 insertions, 2 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index 5989a13ce6..2ed2c08327 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1237,15 +1237,18 @@ if test -z "$CC"
then
AC_MSG_ERROR([gcc is required])
fi
+GccLT46=NO
AC_CACHE_CHECK([version of gcc], [fp_cv_gcc_version],
[
# Be sure only to look at the first occurrence of the "version " string;
# Some Apple compilers emit multiple messages containing this string.
fp_cv_gcc_version="`$CC -v 2>&1 | sed -n -e '1,/version /s/.*version [[^0-9]]*\([[0-9.]]*\).*/\1/p'`"
- FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [4.7],
- [AC_MSG_ERROR([Need at least gcc version 4.7])])
+ FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [4.4],
+ [AC_MSG_ERROR([Need at least gcc version 4.4 (4.7+ recommended)])])
+ FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [4.6], GccLT46=YES)
])
AC_SUBST([GccVersion], [$fp_cv_gcc_version])
+AC_SUBST(GccLT46)
])# FP_GCC_VERSION
dnl Check to see if the C compiler is clang or llvm-gcc
@@ -1278,6 +1281,24 @@ AC_SUBST(GccIsClang)
rm -f conftest.txt
])
+# FP_GCC_SUPPORTS__ATOMICS
+# ------------------------
+# Does gcc support the __atomic_* family of builtins?
+AC_DEFUN([FP_GCC_SUPPORTS__ATOMICS],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_MSG_CHECKING([whether GCC supports __atomic_ builtins])
+ echo 'int test(int *x) { int y; __atomic_load(&x, &y, __ATOMIC_SEQ_CST); return x; }' > conftest.c
+ if $CC -c conftest.c > /dev/null 2>&1; then
+ CONF_GCC_SUPPORTS__ATOMICS=YES
+ AC_MSG_RESULT([yes])
+ else
+ CONF_GCC_SUPPORTS__ATOMICS=NO
+ AC_MSG_RESULT([no])
+ fi
+ rm -f conftest.c conftest.o
+])
+
# FP_GCC_SUPPORTS_NO_PIE
# ----------------------
# Does gcc support the -no-pie option? If so we should pass it to gcc when