GCC Build Instructions

From Dmz-portal

Jump to: navigation, search

Contents

Introduction

These instructions describe how to use the build_toolchain script to build a GCC toolchain for MIPS that runs on an x86 GNU Linux system. It can be used to build a toolchain that targets a MIPS bare-metal system or a MIPS GNU Linux system. This script is not an officially supported product of Imagination but is provided for the convenience of users who may wish to build their own toolchain. If you have questions or run into problems with using this script you can ask for help on the Imagination MIPS Forum page.

Build Instructions

The syntax for running this script is:

build_toolchain <ACTION> <OPTIONS> <COMPONENTS>

ACTION

<ACTION> can be either 'build', 'update', or 'test'. For the purposes of these insructions <ACTION> will always be 'build'. If you wanted you could use 'update' to download and unpack all the sources before building and then later rerun the script with the 'build' action to build the toolchain. This is not necessary though because the build action will automatically do any update actions needed to access sources if they are not already in place.

OPTIONS

Here are the <OPTIONS> you will need to specify when running this script:

--target=<TARGET_NAME>

To build a toolchain for MIPS bare-metal you should use 'mips-mti-elf' as the <TARGET_NAME>, for MIPS GNU Linux targets you should use 'mips-mti-linux-gnu' as the <TARGET_NAME>. Both of these targets are 'multilib' targets and will support MIPS builds for the mips32, mips32r2, mips64, and mips64r2 architectures. They also support big and little endian compilations, soft and hard float compilations, mips16 and micromips compilations, and legacy and nan2008 compilations. Note that not every possible combination of these options is supported.

--prefix=<INSTALLDIR>

<INSTALLDIR> is the directory where you want the toolchain installed. Multiple directories, including a bin directory, will be created under <INSTALLDIR>

--source=<SRCDIR>

<SRCDIR> is the directory where the sources used to build the GCC toolchain will be installed.

--build=<BLDDIR>

<BLDDIR> is the directory where object files are put while building the GCC toolchain.

--jobs=<N>

<N> should be an integer greater then one that tells the build script how much work can be done in parallel. This option is passed to the GNU make command so it can build multiple objects at once. Using this will shorten the build time for the toolchain but will increase the load on your system.

--src=<COMPONENT_NAME>:<LOCATION>

The GCC toolchain consists of multiple components (GCC, binutils, glibc, newlib, etc.) and you need to tell the build script where to find the sources for each component. By default sources will be picked up from the GIT repositories on dmz-portal.mips.com. These repositories track the latest FSF sources for each component and should only be used if you want to build from the absolute latest sources. These sources are unreleased and unsupported and should never be used to build a product to be released to customers. Examples of other --src possibilies are given below.

COMPONENTS

<COMPONENTS> is the list of components to be built. For a complete MIPS GNU Linux build (targeting mips-mti-linux-gnu) the components you want to build are 'binutils-gdb initial_gcc linux_headers sysroot gcc qemu'. For a MIPS bare-metal build you would build the components 'binutils-gdb initial_gcc newlib gcc qemu'. Depending on where you are getting your sources from you may want to build one combined 'binutils-gdb' component or two seperate components 'binutils' and 'gdb'. If you are building from the FSF or dmz-portal GIT repositories, binutils and gdb sources are in one tree and you should use 'binutils-gdb'. If you are building from released tarballs then the gdb sources and the binutils sources are released seperately and you should build 'binutils' and 'gdb' seperately.

Examples

Build a MIPS bare-metal GCC using the Top-of-tree sources from the Imagination dmz-portal repositories:

DIR=/path/to/an/empty/or/nonexistent/directory
build_toolchain build --target=mips-mti-elf --prefix=$DIR/install --source=$DIR/src --build=$DIR/obj --jobs=5 binutils-gdb gmp mpfr mpc initial_gcc newlib gcc

Build a MIPS GNU Linux GCC using the Top-of-tree sources from the Imagination dmz-portal repositories:

DIR=/path/to/an/empty/or/nonexistent/directory
build_toolchain build --target=mips-mti-elf --prefix=$DIR/install --source=$DIR/src --build=$DIR/obj --jobs=5 binutils-gdb gmp mpfr mpc initial_gcc linux glibc gcc qemu

Build a MIPS GNU Linux GCC using released FSF sources:

DIR=/path/to/an/empty/or/nonexistent/directory
build_toolchain build --source=$DIR/src --build=$DIR/obj --prefix=$DIR/install --target=mips-mti-linux-gnu --jobs=5 \
        --src=gcc:ftp://ftp.gnu.org/gnu/gcc/gcc-4.9.1/gcc-4.9.1.tar.bz2 \
        --src=binutils:ftp://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.bz2 \
        --src=gdb:ftp://ftp.gnu.org/gnu/gdb/gdb-7.8.tar.gz \
        --src=glibc:ftp://ftp.gnu.org/gnu/glibc/glibc-2.19.tar.bz2 \
        --src=qemu:http://wiki.qemu-project.org/download/qemu-2.1.0.tar.bz2 \
        --src=gmp:ftp://ftp.gnu.org/gnu/gmp/gmp-6.0.0a.tar.bz2 \
        --src=mpfr:ftp://ftp.gnu.org/gnu/mpfr/mpfr-3.1.2.tar.bz2 \
        --src=mpc:ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.2.tar.gz \
        --src=linux:ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.4.tar.bz2 \
                binutils gdb initial_gcc linux glibc gcc qemu

FAQ

  1. Do I need to build the gmp, mpfr, and mpc components?
    If you have recent versions of these libraries on your system you do not need to include them in the components to be built. But not including them means that the compiler you build will only work on systems that have those libraries installed on them.
  2. Does the order I build the components in matter?
    Yes, some of the components depend on earlier components being built. binutils (or binutils-gdb) must be built before gcc. initial_gcc must be built before glibc or newlib and gcc must be built after them.
  3. Why is there an initial_gcc and a gcc component?
    initial_gcc is a gcc compiler without runtime libraries needed to build glibc or newlib (the runtime libraries). After these have been built a final gcc compiler that uses the newly built libraries can be built.
  4. What does this error mean:

            checking installed Linux kernel header files... 2.6.19 or later
            checking for kernel header at least 10.0.0... too old!
            configure: error: *** The available kernel headers are older than the requested
            *** compatible kernel version
            Error: Configure command failed, stopping build.

  1. If you build multilibs that include libraries supporting the IEEE 2008 NaN format then you need to modify the ports/sysdeps/unix/sysv/linux/mips/configure file in the glibc source tree to comment out the final if statement in that script where the kernel version is checked. Currently support for the IEEE 2008 NaN format is not in the Linux kernel.
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox