10

I am trying to compile GHC 7.6.3 on the Raspberry Pi. The 7.4 version of GHC that ships with Raspbian, does not support ghci. I intend to package v 7.6.3 and make it available.

After a looong time, I get this error on the Pi:

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

Any idea what is going wrong?

How can I end up with missing intermediate files, that are produced by the build system?

  • Looks like a bug somewhere in the build tool chain. Perhaps better try a cross compiler on a x86 system. The cross compiler is a weak link (very likely to expose some bugs) but at least the other tools are then quite well tested. See here for instructions (cross from x86 Linux to Raspberry Linux seems to be supported quite well): http://ghc.haskell.org/trac/ghc/wiki/CrossCompilation – stefan.schwetschke Jul 20 '13 at 20:56
  • 1
    Debian provides [GHC 7.6.3 on arm](http://packages.debian.org/sid/ghc), so you might want to check out the ARM-related [Patched](http://patch-tracker.debian.org/package/ghc/7.6.3-3) applied by Debian. – Joachim Breitner Jul 20 '13 at 21:58
  • Thank you guys. Actually I tried to temporarily switch to the sid repository to install ghc, but this ended up in a dependencies nightmare (it insisted to upgrade my libc). So I decided to compile it myself. – Nick Kanellopoulos Jul 21 '13 at 00:06
  • I tried to compile the Debian sid version of ghc on Raspberry Pi, and hit exactly the same error as you did. Tell if you can get the cross compilation working! – ipuustin Jul 26 '13 at 19:58
  • Ugh, spent the last two days compiling and also got to this point. I wonder if the same problem exists on 7.8? Might try compiling that. – Bzzt Mar 03 '14 at 20:22

2 Answers2

2

I got GHC-7.8.3 compiled with Raspberry PI from upstream sources. It's not very fast, but it gets the job done:

pi@arlanda ~ $ 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

Key things are to do the following:

  1. Have enough memory. Plug in an external hard disk and create a 4-gigabyte swap partition. First in fdisk select the partition type to be Linux swap, then do mkswap /dev/sdXX, finally do swapon /dev/sdXX, where XX is the disk id letter and partition number.
  2. Update kernel to the latest version with rpi-update to prevent hangs. I had also smsc95xx.turbo_mode=N slub_debug=FP added to the end of kernel command line in /boot/cmdline.txt file.
  3. Install gold linker with apt-get install binutils-gold, because regular ld.bfd will fail to create the dynamic libraries. The problem is that you can't use gold for linking everything, but need to link the stage 1 with ld.bfd. You need to follow the instructions in this script (original information from here) with the exception that you need to use ld.bfd for running the initial ./configure call too.
  4. Have patience -- the compilation will take days.
ipuustin
  • 108
  • 6
  • Thanks. I managed to build GHC 7.8.3 on my ancient Rev1 Raspberry Pi following these instructions. I had to [adjust the GPU memory allocation](http://raspberrypi.stackexchange.com/a/674) down to 16G as an additional step. It took one week to compile and I had to restart the compilation couple times as it got killed. – pico Sep 08 '14 at 19:44
0

You can always check the official haskell page for R-Pi. Hope it helps you more than it helped me. There are some really useful links there.

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