Move __ATOMICS into ghc-prim
authorMoritz Angermann <moritz.angermann@gmail.com>
Thu, 8 Feb 2018 08:07:07 +0000 (16:07 +0800)
committerMoritz Angermann <moritz.angermann@gmail.com>
Thu, 8 Feb 2018 08:07:07 +0000 (16:07 +0800)
aclocal.m4
configure.ac
libraries/ghc-prim/Setup.hs
libraries/ghc-prim/aclocal.m4 [new file with mode: 0644]
libraries/ghc-prim/configure.ac [new file with mode: 0644]
libraries/ghc-prim/ghc-prim.buildinfo.in [new file with mode: 0644]
libraries/ghc-prim/ghc-prim.cabal

index 99ff1bf..fc9d618 100644 (file)
@@ -1281,24 +1281,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
index ec96d2c..a2c0a3c 100644 (file)
@@ -712,11 +712,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.
index 5bb17e2..cccc416 100644 (file)
@@ -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 (file)
index 0000000..e569538
--- /dev/null
@@ -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 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
+])
diff --git a/libraries/ghc-prim/configure.ac b/libraries/ghc-prim/configure.ac
new file mode 100644 (file)
index 0000000..bacc89c
--- /dev/null
@@ -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 "x$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 (file)
index 0000000..a093282
--- /dev/null
@@ -0,0 +1,2 @@
+cc-options: @PRIM_CFLAGS@
+extra-libraries: @PRIM_EXTRA_LIBRARIES@
\ No newline at end of file
index 2b860e6..f395c9f 100644 (file)
@@ -66,9 +66,6 @@ Library
         --         on Windows. Required because of mingw32.
         extra-libraries: user32, mingw32, mingwex
 
-    if os(linux)
-        extra-libraries: atomic
-    
     c-sources:
         cbits/atomic.c
         cbits/bswap.c