welcome: please sign in
location: Raspberry Pi / build / Raspbian(Hardfloat)

This tutorial assumes you're using the rasbian debian wheezy (hardfloat) image. Tested with version 2012-07-15-wheezy-raspbian.zip. See http://www.raspberrypi.org/downloads

For other distributions, see Raspberry Pi.

Howto

Adding additional package sources

Add the following line to /etc/apt/sources.list:

deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free

Then update the packages list:

sudo apt-get update

Install additional packages

sudo apt-get install lsb-release debhelper bison flex libmpfr-dev libmpc-dev zlib1g-dev libgmp3-dev git
sudo apt-get build-dep gcc-4.7

Enable swap

Compiling GCC needs lots of ram, so enable swap to make sure compiling doesn't fail because of out of memory errors:

sudo swapon /dev/yourswap

Replace /dev/yourswap with the correct path of your swap partition. I used a 256MB swap partition. (Note: swap isn't fast, especially if your swap partition is on a sd card. Flash media(sd cards, usb sticks) can get damaged by swap usage, you've been warned! For faster and safer swap, use a USB harddisk)

Download debian gcc sources

apt-get source gcc-4.7

Edit debian sources

The debian sources already include patches for an older gdc version. We have to disable those patches:

cd gcc-4.7-4.7.1

Edit the debian/rules.patch file: Find this line

  debian_patches += gcc-d-lang

and replace it with this:

#  debian_patches += gcc-d-lang

Patch debian sources

We should now apply the debian specific patches to the gcc source:

debian/rules clean
debian/rules patch

Download gdc

Latest tested revision: 9bcc0b7159638bf14864015988d41953a621e20c

cd ~
git clone https://github.com/D-Programming-GDC/GDC.git
cd GDC
git checkout gdc-4.7

Add gdc to gcc sources

./setup-gcc.sh /home/pi/gcc-4.7-4.7.1/src

Configure GCC

cd ~
mkdir objdir
cd objdir
../gcc-4.7-4.7.1/src/configure --with-bugurl="http://gdcproject.org/bugzilla" --enable-languages=d --prefix=/opt/gdc --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --without-included-gettext --enable-threads=posix --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --enable-checking=yes --disable-bootstrap

Note: The gdc compiler is quite slow on the Raspberry Pi. Using "--enable-checking=release" should produce a faster compiler, but it makes debugging gdc more difficult.

Build it

DFLAGS="-fno-section-anchors" make 2>&1 | tee build.log

Install

 sudo make install

Troubleshooting:

Compile process fails with some "out of memory" message

The PI's ram is too small to compile GCC, make sure you've enabled enough swap!

Compiling insn-recog.c takes ages

This is normal. Compiling this file uses lots of ram and it uses swap. You can probably speed up building this file be using faster swap. (usb harddisk instead of sd card)

Raspberry Pi/build/Raspbian(Hardfloat) (last edited 2012-10-14 10:50:09 by ibuclaw)