From ad69044e0dce233e3485c744c6299589a451f1dc Mon Sep 17 00:00:00 2001 From: Debian Haskell Group Date: Thu, 28 Feb 2019 14:18:49 +0000 Subject: [PATCH] add_-latomic_to_ghc-prim commit ec9aacf3eb2975fd302609163aaef429962ecd87 Author: Moritz Angermann Date: Thu Feb 8 16:07:07 2018 +0800 adds -latomic to. ghc-prim Reviewers: bgamari, hvr Reviewed By: bgamari Subscribers: erikd, hvr, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4378 iliastsi: The original patch fails to correctly detect and use C11 atomics, so I modified it based on https://phabricator.haskell.org/D5154. Gbp-Pq: Name add_-latomic_to_ghc-prim --- aclocal.m4 | 18 ------------------ configure.ac | 5 ----- libraries/ghc-prim/Setup.hs | 2 +- libraries/ghc-prim/aclocal.m4 | 17 +++++++++++++++++ libraries/ghc-prim/configure.ac | 18 ++++++++++++++++++ libraries/ghc-prim/ghc-prim.buildinfo.in | 2 ++ 6 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 libraries/ghc-prim/aclocal.m4 create mode 100644 libraries/ghc-prim/configure.ac create mode 100644 libraries/ghc-prim/ghc-prim.buildinfo.in diff --git a/aclocal.m4 b/aclocal.m4 index b2685af3..1ff96ae8 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1284,24 +1284,6 @@ 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 diff --git a/configure.ac b/configure.ac index 222b8617..cf28796f 100644 --- a/configure.ac +++ b/configure.ac @@ -714,11 +714,6 @@ FP_GCC_VERSION dnl ** See whether gcc supports -no-pie FP_GCC_SUPPORTS_NO_PIE -dnl ** Used to determine how to compile ghc-prim's atomics.c, used by -dnl unregisterised, Sparc, and PPC backends. -FP_GCC_SUPPORTS__ATOMICS -AC_DEFINE([HAVE_C11_ATOMICS], [$CONF_GCC_SUPPORTS__ATOMICS], [Does GCC support __atomic primitives?]) - FP_GCC_EXTRA_FLAGS dnl ** look to see if we have a C compiler using an llvm back end. diff --git a/libraries/ghc-prim/Setup.hs b/libraries/ghc-prim/Setup.hs index 5bb17e23..cccc416d 100644 --- a/libraries/ghc-prim/Setup.hs +++ b/libraries/ghc-prim/Setup.hs @@ -18,7 +18,7 @@ import System.Exit import System.Directory main :: IO () -main = do let hooks = simpleUserHooks { +main = do let hooks = autoconfUserHooks { regHook = addPrimModule $ regHook simpleUserHooks, buildHook = build_primitive_sources diff --git a/libraries/ghc-prim/aclocal.m4 b/libraries/ghc-prim/aclocal.m4 new file mode 100644 index 00000000..81fc44c5 --- /dev/null +++ b/libraries/ghc-prim/aclocal.m4 @@ -0,0 +1,17 @@ +# 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 y; }' > 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 +]) diff --git a/libraries/ghc-prim/configure.ac b/libraries/ghc-prim/configure.ac new file mode 100644 index 00000000..8249be31 --- /dev/null +++ b/libraries/ghc-prim/configure.ac @@ -0,0 +1,18 @@ +AC_INIT([ghc-prim package], [2.1], [glasgow-haskell-bugs@haskell.org], [ghc-prim]) + +AC_CONFIG_SRCDIR([ghc-prim.cabal]) + +# ------------------------------------------------------------------------- +dnl ** Used to determine how to compile ghc-prim's atomics.c, used by +dnl unregisterised, Sparc, and PPC backends. +FP_GCC_SUPPORTS__ATOMICS +AC_DEFINE([HAVE_C11_ATOMICS], [$CONF_GCC_SUPPORTS__ATOMICS], [Does GCC support __atomic primitives?]) + +if test "$CONF_GCC_SUPPORTS__ATOMICS" = "YES" +then PRIM_CFLAGS=-DHAVE_C11_ATOMICS + PRIM_EXTRA_LIBRARIES=atomic +fi +AC_SUBST([PRIM_CFLAGS]) +AC_SUBST([PRIM_EXTRA_LIBRARIES]) +AC_CONFIG_FILES([ghc-prim.buildinfo]) +AC_OUTPUT diff --git a/libraries/ghc-prim/ghc-prim.buildinfo.in b/libraries/ghc-prim/ghc-prim.buildinfo.in new file mode 100644 index 00000000..a0932824 --- /dev/null +++ b/libraries/ghc-prim/ghc-prim.buildinfo.in @@ -0,0 +1,2 @@ +cc-options: @PRIM_CFLAGS@ +extra-libraries: @PRIM_EXTRA_LIBRARIES@ \ No newline at end of file -- 2.30.2