RPi Linaro GCC Compilation
Back to the Hub.
Software & Distributions:
Software - an overview.
Distributions - operating systems and development environments for the Raspberry Pi.
Kernel Compilation - advice on compiling a kernel.
Performance - measures of the Raspberry Pi's performance.
Programming - programming languages that might be used on the Raspberry Pi.
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" 
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).
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.
- Download the crosstool-NG source (from http://crosstool-ng.org/).
- Extract the source tarball into your home directory:
tar -xjvf crosstool-ng-1.17.0.tar.bz2
- 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:
- 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:
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:
- 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"
- Check "Link libstdc++ statically into gcc binary"
- Set "C library" to "glibc"
- Set "glibc version" to "2.14.1"
- Paths & Misc:
- Build it:
- 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:
Now if you run:
you should get the version information from your new build. It should end something like:
gcc version 4.7.3 20121001 (prerelease) (crosstool-NG 1.17.0)