atomic-primops is a package which has foreign imports of functions from the GHC runtime system, e.g.,
-- | Memory barrier implemented by the GHC rts (see SMP.h).
foreign import ccall  unsafe "store_load_barrier" storeLoadBarrier
  :: IO ()For some reason, this causes GHC's runtime linker to choke.
- git clone https://github.com/rrnewton/haskell-lockfree(I'm using commit 0ea12fc141c6bd4762773a1adc2f005de068369c)
- cd atomic-primops/
- Apply the following change:
diff --git a/atomic-primops/Data/Atomics.hs b/atomic-primops/Data/Atomics.hs
index da0b790..8081b15 100644
--- a/atomic-primops/Data/Atomics.hs
+++ b/atomic-primops/Data/Atomics.hs
@@ -448,7 +448,7 @@ casMutVar2 mv tick new = IO$ \st ->
 -- GHC 7.8 consistently exposes these symbols while linking:
-#if MIN_VERSION_base(4,7,0) && !defined(mingw32_HOST_OS)
+#if MIN_VERSION_base(4,7,0)
 #warning "Assuming that store_load_barrier and friends are defined in the GHC RTS."
 -- | Memory barrier implemented by the GHC rts (see SMP.h).By doing this, we expose the foreign import of storeLoadBarrier on Windows.
If you're on GHC HEAD, you'll also need this change:
diff --git a/atomic-primops/Setup.hs b/atomic-primops/Setup.hs
index ddf5a02..1a768a1 100644
--- a/atomic-primops/Setup.hs
+++ b/atomic-primops/Setup.hs
@@ -5,7 +5,7 @@ import Distribution.Simple                (defaultMainWithHooks, simpleUserHooks
 import Distribution.Simple.Utils          (cabalVersion)
 import Distribution.Simple.LocalBuildInfo
 import Distribution.Simple.Setup          (ConfigFlags)
-import Distribution.Version               (Version(..))
+import qualified Distribution.Version as Cabal
 import Distribution.PackageDescription    (PackageDescription)
 import Debug.Trace
@@ -13,10 +13,10 @@ import Debug.Trace
 -- here to do it instead:
 checkGoodVersion :: IO ()
 checkGoodVersion =
-  if   cabalVersion >= Version [1,17,0] []
+  if   cabalVersion >= Cabal.mkVersion [1,17,0]
   then putStrLn (" [Setup.hs] This version of Cabal is ok for profiling: "++show cabalVersion)
   else error (" [Setup.hs] This package should not be used in profiling mode with cabal version "++
-                        show (versionBranch cabalVersion)++" < 1.17.0\n"++
+                        show (Cabal.versionNumbers cabalVersion)++" < 1.17.0\n"++
                         " It will break, see cabal issue #1284")
 main :: IO ()Then run cabal install .
If you have this program (SLB.hs):
module Main (main) where
import Data.Atomics
main :: IO ()
main = do
  putStrLn "1"
  storeLoadBarrier
  putStrLn "2"And then runghc SLB.hs:
ghc.exe: C:\Users\RyanGlScott\AppData\Roaming\cabal\x86_64-windows-ghc-8.0.1\atomic-primops-0.8.0.4-CRx9AqVw5b495jOfQbTd3E\HSatomic-primops-0.8.0.4-CRx9AqVw5b495jOfQbTd3E.o: unknown symbol `store_load_barrier'
SLB.hs: SLB.hs: unable to load package `atomic-primops-0.8.0.4'
Compiling it with ghc SLB.hs and then running the executable works without issue.