Clone wiki

gdc / Raspberry Pi

Building gdc on the Raspberry Pi

This tutorial assumes you're using the debian squeeze raspberry pi image. Tested with version See

1. Install additional packages:

sudo apt-get install bison flex libmpfr-dev libmpc-dev zlib1g-dev libgmp3-dev git

2. 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, be warned! For faster and safer swap, use a USB harddisk)

3. Download GCC snapshot


4. Download gdc (tested revision: 55277e4ff35d27757481cc4bc639c0cff2b46196)

git clone

5. Extract GCC

tar xf gcc-4.8-20120624.tar.bz2

6. Add D to GCC source

cd GDC
./ /home/pi/gcc-4.8-20120624
cd ../

Fixme For some reason this didn't apply the toplev patch for me. To make sure the patch is applied:

cat ../configure | grep libphobos

should say something like


If it's giving an empty result, use

patch -p1 -i ../GDC/gcc/d/patches/patch-toplev-4.8.x

7. Configure GCC

mkdir gcc-4.8-20120624/objdir
cd gcc-4.8-20120624/objdir
../configure --enable-languages=d --disable-bootstrap --disable-shared --disable-nls --prefix=/opt/gdc --with-bugurl="" --disable-libgomp --disable-libmudflap --enable-multiarch --enable-linker-build-id --with-system-zlib --without-included-gettext --enable-threads=posix --enable-clocale=gnu --build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi

8. Build it

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

9. Install

sudo make install


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)

gdc install worked, but gdc complains about object.d

This can have two reasons: Either the toplev patch wasn't applied correctly (see step 6 above) or for some reason the include path isn't correct. In the second case you can use these include paths:

gdc -I /opt/gdc/include/d2/4.8.0/ -I  /opt/gdc/include/d/4.8.0/arm-linux-gnueabi/