Building an ARM development environment

Setting up all the tools you need for development on an ARM system can be a little daunting at first.  This page should contain all the information you need to get going.  Although this is mostly intended for people who want to use ELF on a Linux/ARM system most of the details here are also applicable to standalone and a.out systems.

The latest toolchain news can be found on this page.  The information below isn't so frequently updated.

1.  Binutils

Before you can do anything else you need to install an assembler and linker.  These are in the binutils package.  Currently the latest release known to work on ARM systems is 2.9.1.0.19a; the very latest version is currently 2.9.1.0.21 and this may also be OK.  Binutils can usually be found here or here.  Either of the versions mentioned earlier should work for the following target systems:

Support for the arm-elf configuration is more experimental than the others.  In particular, Cygnus have been working on an independent port to ARM/ELF which is not currently 100% compatible with this one.  Only use it if you know what you are doing.

Once you have the source code in place, follow the instructions provided to compile it.  To build a native compiler on a Linux/ARM system you should configure with something like

$ .../configure arm-linux --prefix=/usr

To build a cross-compiler from some other machine to Linux/ARM you should use something like

$ .../configure --target=arm-linux --prefix=/usr

Then you should be able to do "make" and "make install" without problems.  If you use "make check" you should expect some failures at the moment.

2. GCC

The recommended compiler is currently EGCS 1.1.1.  You can download the source from this site and again there is a patch to apply to it.
If you are building on a Linux/ARM system you need to have the kernel headers available before the compiler will build.  Assuming your kernel source is in /usr/src/linux you can do something like this:

# cd PREFIX/arm-linux                                        # eg /usr/arm-linux
# mkdir include
# cd include
# ln -s /usr/src/linux/include/asm-arm asm
# ln -s /usr/src/linux/include/linux linux

If you haven't already done so, you must also configure the kernel appropriately.

Then configure the compiler using the same arguments you gave to binutils, build it and off you go.

If you are trying to bootstrap a development environment for the first time on this system you will find that not everything will build first time around.  The only things that matter at this stage are those that are built if you type `make LANGUAGES="c"' in the `gcc' subdirectory.  Once enough of the compiler is built you can install it - again you may need to be in the gcc subdirectory and use LANGUAGES="c" to get this to complete without errors.

You now have enough of an environment to build kernels and standalone "C" programs.  If this is all you are interested in you can stop now and congratulate yourself on a job well done.  If you want to use other languages or build programs that link with the C library (including most user-space binaries for Linux) then you need to continue.

3. libc

For ARM systems you need glibc 2.1.  You will need the linuxthreads and crypt add-ons as well as the library itself.  The primary distribution site for glibc is here but this server is located in the USA and people from other countries must not download the crypt add-on from there.  Instead you can find it on ftp.funet.fi.

Compiling the libc natively is simple and you can just follow the instructions.  If you are building on a system that is already based on glibc then be careful if you install your new library -- a mistake may mean you are hosed.

In a cross-compile environment things are a little more difficult.  You need to use a configure line of the following form:

$ CC=arm-linux-gcc .../configure arm-linux --build=i586-linux --prefix=/usr/arm-linux --enable-add-ons=...

Specifying the compiler is compulsory, otherwise you will end up building the library with your native compiler which will leave you with a horrendous mix of architectures and a broken library.  Specifying the build system is also necessary to ensure the make process goes smoothly.  The name you give here doesn't need to be 100% accurate, it basically just has to be different from the name of the host system.  It makes no sense to use --target when configuring glibc.  Do NOT just give the same --prefix argument that you used for compiling gcc and binutils, make sure you add the extra component so that the library installs into the correct target directory.  Installing a cross library in /usr by mistake will bring you to grief quite quickly.

For standalone environments you might like to investigate the newlib package instead.

4. Other compilers

Once libc is installed you can build basic user-space applications.  In particular you can now go back to egcs and compile all the parts that didn't build the first time around like the C++ and Fortran front ends.