[Haskell-cafe] zlib build failure on recent GHC

Johan Tibell johan.tibell at gmail.com
Mon Nov 7 17:17:18 CET 2011


On Mon, Nov 7, 2011 at 7:53 AM, Ben Gamari <bgamari.foss at gmail.com> wrote:

> With GHC 1ece7b27a11c6947f0ae3a11703e22b7065a6b6c zlib fails to build,
> apparently due to Safe Haskell (bug 5610 [1]). The error is specifically,
>
> $ cabal install zlib
> Resolving dependencies...
> Configuring zlib-0.5.3.1...
> Preprocessing library zlib-0.5.3.1...
> Building zlib-0.5.3.1...
> [1 of 5] Compiling Codec.Compression.Zlib.Stream (
> dist/build/Codec/Compression/Zlib/Stream.hs,
> dist/build/Codec/Compression/Zlib/Stream.o )
>
> Codec/Compression/Zlib/Stream.hsc:857:1:
>    Unacceptable argument type in foreign declaration: CInt
>    When checking declaration:
>      foreign import ccall unsafe "static zlib.h inflateInit2_"
> c_inflateInit2_
>        :: StreamState -> CInt -> Ptr CChar -> CInt -> IO CInt
>
> Codec/Compression/Zlib/Stream.hsc:857:1:
>    Unacceptable argument type in foreign declaration: CInt
>    When checking declaration:
>      foreign import ccall unsafe "static zlib.h inflateInit2_"
> c_inflateInit2_
>        :: StreamState -> CInt -> Ptr CChar -> CInt -> IO CInt
>
> Codec/Compression/Zlib/Stream.hsc:857:1:
>    Unacceptable result type in foreign declaration: IO CInt
>    Safe Haskell is on, all FFI imports must be in the IO monad
>    When checking declaration:
>      foreign import ccall unsafe "static zlib.h inflateInit2_"
> c_inflateInit2_
>        :: StreamState -> CInt -> Ptr CChar -> CInt -> IO CInt
> ...
>
> This is a little strange since,
>
>  a) It's not clear why Safe Haskell is enabled
>  b) The declarations in question seem to be valid
>
> Does this seem like a compiler issue to you?
>

This is due to a change in how FFI imports and newtypes work. GHC was
recently changed to not allow you to use newtypes in FFI imports unless the
constructor of the newtype is in scope. This broke quite a few libraries. I
have patched a few of them and I've sent a patch to the zlib maintainer.

-- Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111107/1296ce53/attachment.htm>


More information about the Haskell-Cafe mailing list