vincenthz / hs-memory

haskell memory
Other
48 stars 38 forks source link

Doesn't compile on GHC 9.0.1 due to unsafeCoerce# #84

Closed danwdart closed 2 years ago

danwdart commented 3 years ago
Data/ByteArray/ScrubbedBytes.hs:93:71: error:
    Variable not in scope:
      unsafeCoerce# :: MutableByteArray# RealWorld -> ByteArray#
   |
93 |                 let !scrubber = (getScrubber sz) (byteArrayContents# (unsafeCoerce# mbarr))
   |                                                                       ^^^^^^^^^^^^^

Data/ByteArray/ScrubbedBytes.hs:151:38: error:
    Variable not in scope:
      unsafeCoerce# :: MutableByteArray# RealWorld -> ByteArray#
    |
151 |     a <- f (Ptr (byteArrayContents# (unsafeCoerce# mba)))

Data/ByteArray/Bytes.hs:90:38: error:
    Variable not in scope:
      unsafeCoerce# :: MutableByteArray# RealWorld -> ByteArray#
   |
90 |     a <- f (Ptr (byteArrayContents# (unsafeCoerce# mba)))
danwdart commented 3 years ago

This workaround Nix derivation override helps:

{
  memory = (self.callHackage "memory" "0.15.0" {}).overrideDerivation(self: {
    prePatch = ''
      sed -zi 's/import\(\s\+\)GHC.Prim/import\1GHC.Prim hiding (unsafeCoerce#)\nimport\1GHC.Exts (unsafeCoerce#)/' Data/ByteArray/Bytes.hs
      sed -zi 's/import\(\s\+\)GHC.Prim/import\1GHC.Prim hiding (unsafeCoerce#)\nimport\1GHC.Exts (unsafeCoerce#)/' Data/ByteArray/ScrubbedBytes.hs
    '';
  });
}
sjakobi commented 3 years ago

As a Hackage trustee I have made a revision to v0.15.0 to prevent it from building with GHC 9.0: http://hackage.haskell.org/package/memory-0.15.0/revisions/

Also note that this PR is intended to fix the issue: https://github.com/vincenthz/hs-memory/pull/81

sjakobi commented 3 years ago

The v0.16.0 release builds with GHC 9.0.1: http://hackage.haskell.org/package/memory-0.16.0

Thanks @vincenthz! :)

ysangkok commented 2 years ago

@danwdart This can be closed.