为什么我在树莓派上使用GHC 7.8.4无法安装任何软件包?

7
根据这篇文章,终于有一个支持模板哈斯克尔和ghci的GHC版本的debian软件包可用了。事实如此,我从全新的Raspbian开始,修改了/etc/apt/sources.list文件为:
deb http://http.debian.net/debian sid main contrib non-free
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspbian.org/raspbian/ wheezy main contrib non-free rpi

我执行了sudo apt-get update && sudo apt-get upgrade,然后我执行了sudo apt-get install ghcsudo apt-get install cabal-installghc --version显示版本为7.8.4。GHCi可以正常工作,TH也可以。
但是由于某些原因,我无法使用cabal安装任何软件包。无论我选择哪个软件包,都会出现以下错误的某个版本:
login as: pi
pi@192.168.1.5's password: 
Linux raspberrypi 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon May 11 17:17:22 2015

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.4
$ mkdir test
$ cd test
$ cabal sandbox init
Writing a default package environment file to
/home/pi/test/cabal.sandbox.config
Creating a new sandbox at /home/pi/test/.cabal-sandbox
$ cabal install array
Resolving dependencies...
Notice: installing into a sandbox located at /home/pi/test/.cabal-sandbox
Downloading array-0.5.1.0...
Configuring array-0.5.1.0...
Failed to install array-0.5.1.0
Build log ( /home/pi/test/.cabal-sandbox/logs/array-0.5.1.0.log ):
cabal: Error: some packages failed to install:
array-0.5.1.0 failed during the configure step. The exception was:
user error ('/usr/bin/ghc' exited with an error:
/tmp/ghc2287_0/ghc2287_6.s: Assembler messages:

/tmp/ghc2287_0/ghc2287_6.s:76:0:
Error: selected processor does not support ARM mode `movw
r7,:lower16:stg_bh_upd_frame_info'

/tmp/ghc2287_0/ghc2287_6.s:77:0:
Error: selected processor does not support ARM mode `movt
r7,:upper16:stg_bh_upd_frame_info'

/tmp/ghc2287_0/ghc2287_6.s:80:0:
Error: selected processor does not support ARM mode `movw
r7,:lower16:base_GHCziTopHandler_runMainIO_closure'

/tmp/ghc2287_0/ghc2287_6.s:81:0:
Error: selected processor does not support ARM mode `movt
r7,:upper16:base_GHCziTopHandler_runMainIO_closure'

/tmp/ghc2287_0/ghc2287_6.s:82:0:
Error: selected processor does not support ARM mode `movw
r8,:lower16:Cabalzm1zi22zi1zi1_DistributionziSimple_defaultMain_closure'

/tmp/ghc2287_0/ghc2287_6.s:83:0:
Error: selected processor does not support ARM mode `movt
r8,:upper16:Cabalzm1zi22zi1zi1_DistributionziSimple_defaultMain_closure'
)

请问有人知道我哪里偏离了轨道吗?

更新

$ cabal --version
cabal-install version 1.22.0.1
using version 1.22.1.1 of the Cabal library

1
运行 cabal install base-io-access,看看是否有效。我负责那个(微小的、未完成的,请勿在实际代码中使用)包,但它只依赖于 base,不涉及任何 FFI 或类似的内容。这是你可以要求的最简单的包。如果它无法编译,则会告诉你出了什么大问题;如果它能够编译,则取决于包的依赖关系。 - bheklilr
感谢@bheklilr,这是我用自己类似的包exact-pi运行的测试,它只依赖于基础库。我刚试了一下你的代码,得到了相同的结果。(基本上,只是临时文件名不同,但是行号和字符位置都相同。) - Doug McClean
在这种情况下,我不知道。我的初步猜测是尝试链接到一些C代码或其他东西。也许你需要一些额外的标志来使GHC正确编译?我从未尝试在我的RPi上安装GHC,所以我在这方面没有经验。 - bheklilr
是的,我也猜不出来了。很奇怪,因为其他人似乎已经让它工作了,所以它可能比看起来简单。 - Doug McClean
1个回答

6
需要在构建使用GHC或cabal安装任何东西时每次加上选项--ghc-options=-opta-march=armv7a。有了这个选项,就能够正常工作! 更新 如果您改为使用--ghc-options="-opta-mcpu=cortex-a7 -opta-mfpu=neon -opta-mtune=native -opta-mfloat-abi=hard,浮点也会正常工作。我是通过猜测和检查以及阅读旧的论坛帖子得出这个结论的,因此这些设置可能不是最佳设置。
Cabal还有一个用户配置文件,您可以在其中存储此设置,并在调用GHC时应用它。

1
我在树莓派3上使用ghc 7.10时遇到了同样的问题。我不得不在cabal中使用--ghc-options=-opta-march=armv7-a - zigazou
对于 Stack,我发现以下资料很有用: https://gist.github.com/blender/7c4c6e7224e622ee078e5b3320ac951d https://allocinit.io/haskell/haskell-on-raspberry-pi-3/#installing-stack https://github.com/commercialhaskell/stack/issues/2708 - Peter Becich

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接