Programming - programming languages that might be used on the Raspberry Pi.

Overview

This page explains how to build yourself a version of Linaro GCC specifically for building software for the RPi.

From the Linaro website: "Linaro GCC is performance focused branch of the current GCC stable release and includes backports of the improvements and bug fixes that Linaro and others have done upstream" [1]

Requirements

This process should be carried out on the Linux system you wish to compile RPi software on. Therefore, you will require a reasonably powerful computer (preferably 64bit). If you are running on Windows, it is possible to use a linux virtual machine running on Virtualbox. The only software required is crosstool-NG (plus its dependencies).

Procedure

The whole process takes about an hour on a dual-core 2.8GHz 64-bit AMD system using an 8Mbit ADSL connection.
NOTE: This procedure was tested on 24th November 2012 using crosstool-ng 1.17.0. It may not be accurate for newer versions of the software.

Install crosstool-NG

Change to the extracted directory, then configure it. You should specify an installation prefix to keep it separate from the OS in case you want to run multiple versions - we are using /opt/crosstool-ng-1.17.0 in this example:

./configure --prefix=/opt/crosstool-ng-1.17.0

If configure fails due to missing dependencies, install them for your platform using the package manager (i.e. yum install, apt-get install, etc.)

When configure completes successfully, make and install it:

make
make install

Add the crosstool-NG bin folder to your path. The easiest way to do this is add it to PATH in your .profile, for example:

PATH=$PATH:/opt/crosstool-ng-1.17.0/bin

Build GCC Linaro

Make a new directory in your home directory where you want to run crosstool-NG, then change to it.

Configure crosstool-NG:

ct-ng menuconfig

Set the following options (derived from the arm-bcm2708hardfp-linux-gnueabi build on GitHub):

Paths & Misc:

Check "Try features marked as EXPERIMENTAL"

Set "Prefix directory" to whereever you want the finished toolchain to be placed (e.g. /home/<yourname>/crosscompile)

Set "Number of parallel jobs" to be the number of processor cores in your system x1.5

Target options:

Set "Target architecture" to "ARM"

Set "Endianness" to "Little endian"

Set "Bitness" to "32-bit"

Set "Architecture level" to "armv6zk"

Set "Emit assembly for CPU" to "arm1176jzf-s"

Set "Tune for CPU" to "arm1176jzf-s"

Set "Use specific FPU" to "vfp"

Set "Floating point" to "hardware (FPU)"

Set "Default instruction set mode" to "arm"

Check "Use EABI"

General toolchain:

Set "Tuple's vendor string" to "rpi" - you can choose whatever you like here and it will appear in the compiler filenames.

Operating system:

Set "Target OS" to "linux"

Set "Linux kernel version" to match that running on the RPI (it was tested with the 3.6 branch patched to version 3.6.3)

Binary utilities:

Set "Binary format" to "ELF"

Set "binutils version" to "2.22"

C compiler:

Check "Show linaro versions"

Set "gcc version" to "linaro-4.7-2012.10"

Check "C++"

Set "gcc extra config" to "--with-float=hard" (Note: see "Discussion" page)

Check "Link libstdc++ statically into gcc binary"

C-library:

Set "C library" to "eglibc"

Set "eglibc version" to "2_13"

Build it:

ct-ng build

All the required source will now be downloaded and built - exact times vary according to processing power and internet connection speed.

Configure system to use new compiler

Your compiler will be located in /home/<yourname>/crosscompile (or whereever you specified in the configuration). You can choose to move it to another location (e.g. /opt/arm) if you want to. Then, add that location to your PATH:

PATH=$PATH:/opt/arm/bin:/opt/crosstool-ng-1.17.0/bin

Now if you run:

arm-rpi-linux-gnueabi-gcc -v

you should get the version information from your new build. It should end something like: