在Raspberry Pi上编译Haskell

问题描述:

我想在Raspberry Pi上编译GHC 7.6.3。 Raspbian附带的7.4版GHC不支持ghci。 我打算打包v 7.6.3并使其可用。在Raspberry Pi上编译Haskell

一个looong时间后,我得到淠此错误:

HC [stage 0] utils/hp2ps/dist/build/Key.o 
HC [stage 0] utils/hp2ps/dist/build/PsFile.o 
HC [stage 0] utils/hp2ps/dist/build/Shade.o 
HC [stage 0] utils/hp2ps/dist/build/Utilities.o 
"inplace/bin/mkdirhier" utils/hp2ps/dist/build/tmp//. 
HC [stage 0] utils/hp2ps/dist/build/tmp/hp2ps 
Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. 
Call hs_init_ghc() from your main() function to set these options. 
"cp" -p utils/hp2ps/dist/build/tmp/hp2ps inplace/bin/hp2ps 
cp driver/ghc-usage.txt inplace/lib/ghc-usage.txt 
cp driver/ghci-usage.txt inplace/lib/ghci-usage.txt 
HC [stage 0] utils/genapply/dist/build/GenApply.o 
"inplace/bin/mkdirhier" utils/genapply/dist/build/tmp//. 
HC [stage 0] utils/genapply/dist/build/tmp/genapply 
"cp" -p utils/genapply/dist/build/tmp/genapply inplace/bin/genapply 
HC [stage 1] libraries/ghc-prim/dist-install/build/GHC/Types.o 
Stack dump: 
0. Program arguments: /usr/bin/llc -O3 -relocation-model=static /tmp/ghc467_0/ghc467_0.bc -o /tmp/ghc467_0/ghc467_0.lm_s --enable-tbaa=true 
1. Running pass 'Function Pass Manager' on module '/tmp/ghc467_0/ghc467_0.bc'. 
2. Running pass 'ARM Instruction Selection' on function '@ghczmprim_GHCziTypes_Dzh_info' 
/tmp/ghc467_0/ghc467_0.lm_s: openBinaryFile: does not exist (No such file or directory) 
make[1]: *** [libraries/ghc-prim/dist-install/build/GHC/Types.o] Error 1 
make: *** [all] Error 2 

real 308m59.437s 
user 292m8.320s 
sys  10m18.220s 

任何想法是怎么回事?

我该如何结束由构建系统产生的缺失中间文件?

+0

看起来像构建工具链中某处的错误。也许最好在x86系统上尝试一个交叉编译器。交叉编译器是一个薄弱的环节(很可能会暴露一些错误),但至少其他工具都经过了很好的测试。看到这里的指示(从x86 Linux到Raspberry Linux的交叉似乎得到很好的支持):http://ghc.haskell.org/trac/ghc/wiki/CrossCompilation –

+1

Debian提供[GHC 7.6.3 on arm](http ://packages.debian.org/sid/ghc),因此您可能想查看与ARM相关的[Patched](http://patch-tracker.debian.org/package/ghc/7.6.3-3 )由Debian应用。 –

+0

谢谢你们。其实我试图暂时切换到sid存储库来安装ghc,但这最终导致了一个依赖关系的噩梦(它坚持要升级我的libc)。所以我决定自己编译它。 –

您可以随时查看R-Pi的官方haskell页面。希望它能帮助你,而不是帮助我。那里有一些非常有用的链接。

http://www.haskell.org/haskellwiki/Raspberry_Pi

我GHC-7.8.3从上游源编译树莓PI。这不是非常快,但它能够完成任务:

[email protected] ~ $ ghci 
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help 
Loading package ghc-prim ... linking ... done. 
Loading package integer-gmp ... linking ... done. 
Loading package base ... linking ... done. 
Prelude> 1+1 
2 

关键的事情是做到以下几点:

  1. 有足够的内存。插入外部硬盘并创建一个4千兆字节的交换分区。首先在fdisk中选择分区类型为Linux swap,然后做mkswap /dev/sdXX,最后做swapon /dev/sdXX,其中XX是磁​​盘id的字母和分区号。
  2. 使用rpi-update将内核更新到最新版本以防止挂起。我还将smsc95xx.turbo_mode=N slub_debug=FP添加到/boot/cmdline.txt文件内核命令行的末尾。
  3. 安装黄金链接器apt-get install binutils-gold,因为常规ld.bfd将无法​​创建动态库。问题在于你不能使用gold来链接所有内容,但需要将第1阶段与ld.bfd连接起来。您需要按照说明in this scriptoriginal information from here),除了您需要使用ld.bfd来运行初始./configure调用。
  4. 有耐心 - 编辑将需要几天。
+0

谢谢。我设法建立了GHC 7.8。3在我的古代Rev1 Raspberry Pi遵循这些指示。作为一个额外的步骤,我必须[调整GPU内存分配](http://raspberrypi.stackexchange.com/a/674)降至16G。花了一个星期的时间编译,我不得不重新编译几次,因为它被杀死了。 – pico