使用 GHC 构建 zlib 错误 [英] zlib build error with GHC

查看:36
本文介绍了使用 GHC 构建 zlib 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有以下配置的虚拟机:

I'm using a VM with the following configuration:

  • Arch Linux(3.0-ARCH 内核)
  • GHC 7.0.3
  • cabal 安装 0.10.2
  • Cabal 库 1.10.1.0

当我尝试使用 cabal 构建 zlib 时...

When I try to build zlib using cabal...

$ cabal install zlib

我得到以下输出:

Resolving dependencies...
Downloading zlib-0.5.3.2...
Configuring zlib-0.5.3.2...
Preprocessing library zlib-0.5.3.2...
Stream.hsc:86:21: error: missing binary operator before token "("
Stream.hsc: In function ‘main’:
Stream.hsc:86:21: error: missing binary operator before token "("
Stream.hsc:86:21: error: missing binary operator before token "("
compiling dist/build/Codec/Compression/Zlib/Stream_hsc_make.c failed (exit code 1)
command was: /usr/bin/gcc -c dist/build/Codec/Compression/Zlib/Stream_hsc_make.c -o dist/build/Codec/Compression/Zlib/Stream_hsc_make.o -fno-stack-protector -fno-stack-protector -D__GLASGOW_HASKELL__=700 -Dlinux_BUILD_OS -Dlinux_HOST_OS -Dx86_64_BUILD_ARCH -Dx86_64_HOST_ARCH -I/usr/lib/ghc-7.0.3/bytestring-0.9.1.10/include -I/usr/lib/ghc-7.0.3/base-4.3.1.0/include -I/usr/lib/ghc-7.0.3/include -I/usr/lib/ghc-7.0.3/include -I/usr/lib/ghc-7.0.3/include/
cabal: Error: some packages failed to install:
zlib-0.5.3.2 failed during the building phase. The exception was:
ExitFailure 1

谁能解释一下这个构建错误?

Can anyone shed some light on this build error?

这是来自 Stream.hsc 的带有行号的片段:

Here's a snippet from Stream.hsc with line numbers:

 82 import Foreign
 83          ( Word8, Ptr, nullPtr, plusPtr, peekByteOff, pokeByteOff, mallocBy    tes  
 84          , ForeignPtr, FinalizerPtr, newForeignPtr_, addForeignPtrFinalizer
 85          , withForeignPtr, touchForeignPtr )
 86 #if MIN_VERSION_base(4,4,0)
 87 import Foreign.ForeignPtr.Unsafe ( unsafeForeignPtrToPtr )
 88 import System.IO.Unsafe          ( unsafePerformIO )
 89 #else
 90 import Foreign ( unsafeForeignPtrToPtr, unsafePerformIO )
 91 #endif

推荐答案

由于某种原因,MIN_VERSION_base 宏没有被展开,因此预处理器看到条件 MIN_VERSION_base(4,4,0) 它当然无法处理.我还没有发现为什么宏没有扩展,但解决方法是

For some reason, the MIN_VERSION_base macro doesn't get expanded, thus the preprocessor sees the condition MIN_VERSION_base(4,4,0) which it of course cannot handle. I've not yet found out why the macro isn't expanded, but workarounds are

  1. 改为安装 zlib-0.5.3.1
  2. 解压 tarball 并编辑 Codec/Compression/Zlib/Stream.hsc 以删除违规宏(您使用的是 7.0.3,因此您的基本版本是 4.3.1.0,您可以替换带有 0) 的宏
  1. install zlib-0.5.3.1 instead
  2. unpack the tarball and edit Codec/Compression/Zlib/Stream.hsc to remove the offending macro (you're using 7.0.3, so your base version is 4.3.1.0, you can replace the macro with 0)

经过一番摸索后,我发现要隐藏这些不供 hsc2hs 处理的预处理器指令,必须将它们屏蔽由一个额外的#".正在报告错误.

After poking around a bit, I found out that to hide these preprocessor directives, which aren't intended for hsc2hs to process, they have to be masked by an extra '#'. Bug report underway.

这篇关于使用 GHC 构建 zlib 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆