Difference between revisions of "Toolchains"

From LinuxMIPS
Jump to: navigation, search
(H.J.Lu version)
(See also: update link to MIPS ABI History page.)
(37 intermediate revisions by 15 users not shown)
Line 1: Line 1:
 
A toolchain is a complete collection of compiler and binutils programs and can be run either as a cross-compiler, or native on the target (if performance allows).
 
A toolchain is a complete collection of compiler and binutils programs and can be run either as a cross-compiler, or native on the target (if performance allows).
  
== MIPS SDE ==
+
== Pre-built/Build Kits ==
MIPS Technologies UK (formerly [[Algorithmics]]) maintain their own source tree for the toolchain components.  SDE combines all necessary GNU tools, is infrequently resynchronized with mainstream GNU releases (which inevitably have bugs for less widely used architectures such as MIPS) and focuses on providing the most reliable, best-performing compiler for the largest range of MIPS CPUs. The current SDE release is 5.03.06, and is based on GCC 2.96 with many local bug fixes and improvements. But if you are already using a GCC 3.x based MIPS toolchain then you should probably not try to ''downgrade'' to this version, due to ABI and library differences.
+
  
The Linux/386 cross-compiler is available as a single file, in RPM format:
+
=== MIPS SDE ===
                                                                               
+
MIPS Technologies UK maintains their own source tree
; Linux/386 cross for little-endian target : ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-5.03.06-1.i386.rpm
+
for the toolchain components. SDE combines all necessary GNU tools,
; Linux/386 cross for big-endian target : ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinuxeb-5.03.06-1.i386.rpm.
+
is infrequently resynchronized with mainstream GNU releases (which
 +
inevitably have bugs for less widely used architectures such as MIPS)
 +
and focuses on supporting the full range of ISAs, ASEs and cores, as
 +
well as providing the most reliable, best-performing compiler for the
 +
largest range of MIPS CPUs. See [[MIPS SDE Installation]].  
 +
Note that the pre-built cross-compiler is only suitable for building a Linux kernel,
 +
and '''cannot''' be used to create Linux applications or shared objects. Note: We have been using the sde toolkit for both shared objects and applications. Maybe the issue was fixed?
  
The Linux/MIPS native compiler is organised into separate RPM files, mirroring the RedHat 7.x toolchain organisation:
+
=== Maciej W. Rozycki ===
 +
A stable set of toolchain components provided by Maciej can be downloaded from ftp://ftp.linux-mips.org/pub/linux/mips/people/macro/. This is based on GCC 2.95.3 (patched) and up-to-date binutils.  Versions 4.0.1 and 4.1.2 of GCC are available too.
  
; Native big-endian
+
The former mirror at ftp.rfc822.org is now gone. Thanks, Florian, for providing this service over the years.
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-binutils-5.03.06-1.mips.rpm
+
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-c++-5.03.06-1.mips.rpm
+
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-cpp-5.03.06-1.mips.rpm
+
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-gcc-5.03.06-1.mips.rpm
+
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-libstdc++-5.03.06-1.mips.rpm
+
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-libstdc++-devel-5.03.06-1.mips.rpm
+
  
; Native little-endian
+
=== Dan Kegel ===
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-binutils-5.03.06-1.mipsel.rpm
+
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-c++-5.03.06-1.mipsel.rpm
+
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-cpp-5.03.06-1.mipsel.rpm
+
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-gcc-5.03.06-1.mipsel.rpm
+
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-libstdc++-5.03.06-1.mipsel.rpm
+
: ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-libstdc++-devel-5.03.06-1.mipsel.rpm
+
 
+
To avoid conflicts with an existing '''native''' MIPS toolchain only, you can uninstall the old compiler and libstdcc
+
installations using these commands:
+
 
+
# rpm -e `rpm -q -f /usr/bin/gcc`
+
# rpm -e `rpm -q -f /usr/include/g++-3/streambuf.h`
+
 
+
The new sdelinux RPMs can then be installed in the normal way:
+
 
+
# rpm -Uv sdelinux-*-5.03.06-1*.rpm
+
 
+
MTUK would like to hear how well it worked, so contact them on sde@mips.com.
+
 
+
== Maciej W. Rozycki ==
+
A stable set of toolchain components provided by Maciej can be downloaded from  ftp://ftp3.ds.pg.gda.pl/pub/macro/ or the mirror at ftp://ftp.rfc822.org/pub/mirror/ftp3.ds.pg.gda.pl/people/macro/. This is based on gcc 2.95.3 (patched) and up-to-date binutils.
+
 
+
== Dan Kegel ==
+
 
Dan Kegel has a page at http://kegel.com/crosstool/ with a nice script to automatize the build procedure. Crosstool can only generate toolchains that use the GNU C Library, support for the smaller C Library http://www.uclibc.org uClibc might be added in the future.
 
Dan Kegel has a page at http://kegel.com/crosstool/ with a nice script to automatize the build procedure. Crosstool can only generate toolchains that use the GNU C Library, support for the smaller C Library http://www.uclibc.org uClibc might be added in the future.
  
== H.J.Lu ==
+
=== H.J.Lu ===
H.J.Lu distributes a toolchain as part of his [[Distributions#RedHat_7.1_based | Red Hat 7.1 port]]. It can be found at ftp://ftp.linux-mips.org/pub/linux/mips/redhat/7.1/ . This toolchain-20020423-1.rpm is based on the RedHat's [http://gcc.gnu.org/gcc-2.96.html | GCC 2.96], binutils 2.13 and glibc 2.2.5 .
+
H.J.Lu distributes a toolchain as part of his [[Distributions#RedHat_7.1_based | Red Hat 7.1 port]]. It can be found at ftp://ftp.linux-mips.org/pub/linux/mips/redhat/7.1/ . This toolchain-20020423-1.rpm is based on the RedHat's [[GCC]] 2.96, binutils 2.13 and glibc 2.2.5 .
  
== uClibc Toolchain and Buildroot ==
+
=== uClibc Toolchain and Buildroot ===
 
[http://www.uclibc.org/ uClibc] developers provide [http://www.uclibc.org/toolchains.html tools to generate toolchains and root filesystems] with the uClibc standard C library.
 
[http://www.uclibc.org/ uClibc] developers provide [http://www.uclibc.org/toolchains.html tools to generate toolchains and root filesystems] with the uClibc standard C library.
  
Line 55: Line 32:
 
The [http://buildroot.uclibc.org/ Buildroot] tool allows to generate both a toolchain and a root filesystem for a variety of architectures, including MIPS and MIPSel. Using a configuration tool (similar to the one used for the Linux Kernel), you can select compiler version, binutils version, and all softwares that should be included in the root filesystem. Then the Makefiles will automatically download, configure, compile, install and generate the toolchain and the root filesystem image.
 
The [http://buildroot.uclibc.org/ Buildroot] tool allows to generate both a toolchain and a root filesystem for a variety of architectures, including MIPS and MIPSel. Using a configuration tool (similar to the one used for the Linux Kernel), you can select compiler version, binutils version, and all softwares that should be included in the root filesystem. Then the Makefiles will automatically download, configure, compile, install and generate the toolchain and the root filesystem image.
  
== OpenEmbedded ==
+
=== Steven J. Hill ===
 +
Steven J. Hill has a set of glibc/uClibc cross-toolchains over at: [ftp://ftp.realitydiluted.com/linux/MIPS/toolchains]
 +
 
 +
=== OpenEmbedded ===
 
The OpenEmbedded meta distribution also includes an automatic build of a full cross-toolchain for it's target architecture.
 
The OpenEmbedded meta distribution also includes an automatic build of a full cross-toolchain for it's target architecture.
 
http://www.openembedded.org
 
http://www.openembedded.org
  
== Linux4.BE SDK ==
+
=== DENX ELDK ===
provides sources and precompiled toolcain binaries for Linux and [http://www.cygwin.com/ Win32/Cygwin] hosts:
+
[http://www.denx.de/ DENX Software Engineering] provides the ELDK (Embedded Linux Development Kit), which includes both cross development and native tools for big and little endian MIPS processors (also for ARM and PowerPC). As it is Free Software it can be [http://www.denx.de/wiki/view/DULG/ELDKAvailability downloaded] for FREE.
http://www.linux4.be/~jal0/
+
See http://www.denx.de/wiki/DULG/ELDK
  
== DENX ELDK ==
+
=== Gentoo crossdev ===
[http://www.denx.de/ DENX Software Engineering] provides the ELDK (Embedded Linux Development Kit), which includes both cross development and native tools for big and little endian MIPS processors (also for ARM and PowerPC). It can be [http://www.denx.de/twiki/bin/view/DULG/ELDKAvailability downloaded] for FREE.
+
See http://www.denx.de/twiki/bin/view/DULG/ELDK
+
  
== Commercial Toolchains ==
+
Gentoo provides a tool for creating full cross-compiling toolchains for a number of targets.  On any Gentoo system, set up PORTAGE_OVERLAY in make.conf, then ''emerge crossdev'' to install it.  Using a small [http://dev.gentoo.org/~redhatter/misc/xdistcc.sh.gz startup shell script], these toolchains can be used with [http://distcc.samba.org distcc] as well, to allow distribution of a compile job over a cluster.
 +
 
 +
=== Debian ===
 +
 
 +
[http://www.emdebian.org/ Embedded Debian project] provides [http://www.emdebian.org/tools/crosstools.html cross toolchains] for various platforms, including mips and mipsel.
 +
 
 +
An alternative repository with newer toolchains built from Debian sources is available from [http://people.debian.org/~ths/toolchain].
 +
 
 +
=== Commercial Toolchains ===
 
All commercial Linux/MIPS [[distributions]] come with appropriate toolchain deliverables.
 
All commercial Linux/MIPS [[distributions]] come with appropriate toolchain deliverables.
 +
 +
== Roll-your-own ==
 +
 +
You're adverse to using someone else's toolchains, and cannot remember how to build one yourself, no matter how hard you try. Fear not. Outlined here is the proceedure to build a bootstrap toolchain; one which is minus the C library and is just enough to build the kernel.
 +
 +
=== Prologue ===
 +
 +
What you'll need:
 +
 +
* [http://ftp.gnu.org/gnu/binutils binutils-2.21.1] (latest as of [[2011]]-09-14)
 +
* [http://gcc.gnu.org/gcc-4.6/ gcc-4.6.1] (current [[GCC|recommended]] version)
 +
* [http://www.gnu.org/software/gdb/download/ gdb-7.3.1] ([http://www.gnu.org/software/gdb/download/ANNOUNCEMENT latest] as of [[2011]]-09-14)
 +
 +
Note that in general you want to use the latest versions released by the time a kernel was released.  The versions listed here are known to be working well for recent kernels as of the time of writing.  Using tools more recent than the kernel means that combination will not have been tested exhaustively so the likelihood of encountering incompatibilities increases.  Sometimes tool compatibility versions are fixed in -stable but there is no guarantee that this also covers your favourite esoteric configuration.
 +
 +
Now, export a few environment variables for your convenience. If you're building for big-endian MIPS, your <code>TARGET</code> should be <code>mips-unknown-linux-gnu</code> instead. If you wish to install to a different location other than ''/opt/cross/'', substitute in your <code>PREFIX</code> accordingly. A common alternative is ''/usr/local/''.
 +
 +
% export WDIR=/tmp
 +
% export TARGET=mipsel-unknown-linux-gnu
 +
% export PREFIX=/opt/cross
 +
 +
You'll need to re-export your <code>PATH</code> with the new install location so when building a bootstrap gcc, it may locate the shiny new cross-binutils:
 +
 +
% export PATH="${PATH}":${PREFIX}/bin
 +
 +
Now change to the staging directory:
 +
 +
% cd $WDIR
 +
% mkdir ${TARGET}-toolchain  && cd ${TARGET}-toolchain
 +
 +
=== Binutils ===
 +
 +
Extract, configure, build and install:
 +
 +
% tar xjf binutils-2.16.1.tar.bz2
 +
% mkdir build-binutils && cd build-binutils
 +
% ../binutils-2.16.1/configure --target=$TARGET --prefix=$PREFIX
 +
% make
 +
% make install
 +
% cd ..
 +
 +
You should now have the cross-binutils installed under ''<code>${PREFIX}</code>/bin/'' with names prefixed by <code>mipsel-unknown-linux-gnu-*</code> (or <code>mips-unknown-linux-gnu-*</code> if you're building for big-endian MIPS).
 +
 +
=== GCC ===
 +
 +
Extract, configure, build and install a bootstrap GCC.
 +
 +
Enable any other language front-ends as you see fit. For building the kernel however, you can get away with just the C language front-end.
 +
Also, tell the configure script not to look for target libc headers -- we don't have them, and don't need them at this point.
 +
 +
% tar xjf gcc-3.4.4.tar.bz2
 +
% mkdir build-gcc-bootstrap && cd build-gcc-bootstrap
 +
% ../gcc-3.4.4/configure --target=$TARGET --prefix=$PREFIX \
 +
  --enable-languages=c --without-headers \
 +
  --with-gnu-ld --with-gnu-as \
 +
  --disable-shared --disable-threads
 +
% make -j2
 +
% make install
 +
% cd ..
 +
 +
=== GDB ===
 +
 +
You'll need this for debugging either the kernel (with [[KGDB]]) or userspace (natively or with <code>gdbserver</code>). If this doesn't apply in your case, you may safely skip this section.
 +
 +
Extract, configure, build and install:
 +
 +
% tar xjf gdb-6.3.tar.bz2
 +
% mkdir build-gdb && cd build-gdb
 +
% ../gdb-6.3/configure --target=$TARGET --prefix=$PREFIX
 +
% make
 +
% make install
 +
% cd ..
 +
 +
=== Summary ===
 +
 +
Your shiny new toolchain should be in your <code>PATH</code>, given you re-exported it earlier. Otherwise, you'll need to prefix your <code>PATH</code> with:
 +
 +
% ${PREFIX}/bin/mipsel-unknown-linux-gnu-
 +
 +
or for a big-endian target:
 +
 +
% ${PREFIX}/bin/mips-unknown-linux-gnu-
 +
 +
Enjoy.
  
 
== See also ==
 
== See also ==
 
* [[GCC]] The Linux/MIPS GCC page
 
* [[GCC]] The Linux/MIPS GCC page
* Bradley D. LaRonde: [http://laronde.org/~brad/mips/mips-cross-toolchain/ Building a Modern MIPS Cross-Toolchain for Linux]
+
* Bradley D. LaRonde: [http://laronde.org/~brad/mips/mips-cross-toolchain/ Building a Modern MIPS Cross-Toolchain for Linux] ([http://web.archive.org/www.ltc.com/~brad/mips/mips-cross-toolchain.html Webarchive copy])
 +
* [[MIPS ABI History]]: A review of MIPS ABIs, old and new
 +
* [[Wikipedia:Cross-compilation|Cross-compilation]] at [http://www.wikipedia.org Wikipedia]
 +
 
 +
[[Category:Toolchain]]

Revision as of 10:38, 18 July 2012

A toolchain is a complete collection of compiler and binutils programs and can be run either as a cross-compiler, or native on the target (if performance allows).

Pre-built/Build Kits

MIPS SDE

MIPS Technologies UK maintains their own source tree for the toolchain components. SDE combines all necessary GNU tools, is infrequently resynchronized with mainstream GNU releases (which inevitably have bugs for less widely used architectures such as MIPS) and focuses on supporting the full range of ISAs, ASEs and cores, as well as providing the most reliable, best-performing compiler for the largest range of MIPS CPUs. See MIPS SDE Installation. Note that the pre-built cross-compiler is only suitable for building a Linux kernel, and cannot be used to create Linux applications or shared objects. Note: We have been using the sde toolkit for both shared objects and applications. Maybe the issue was fixed?

Maciej W. Rozycki

A stable set of toolchain components provided by Maciej can be downloaded from ftp://ftp.linux-mips.org/pub/linux/mips/people/macro/. This is based on GCC 2.95.3 (patched) and up-to-date binutils. Versions 4.0.1 and 4.1.2 of GCC are available too.

The former mirror at ftp.rfc822.org is now gone. Thanks, Florian, for providing this service over the years.

Dan Kegel

Dan Kegel has a page at http://kegel.com/crosstool/ with a nice script to automatize the build procedure. Crosstool can only generate toolchains that use the GNU C Library, support for the smaller C Library http://www.uclibc.org uClibc might be added in the future.

H.J.Lu

H.J.Lu distributes a toolchain as part of his Red Hat 7.1 port. It can be found at ftp://ftp.linux-mips.org/pub/linux/mips/redhat/7.1/ . This toolchain-20020423-1.rpm is based on the RedHat's GCC 2.96, binutils 2.13 and glibc 2.2.5 .

uClibc Toolchain and Buildroot

uClibc developers provide tools to generate toolchains and root filesystems with the uClibc standard C library.

The Toolchain tool allows to generate a toolchain for a variety of architectures, including MIPS and MIPSel.

The Buildroot tool allows to generate both a toolchain and a root filesystem for a variety of architectures, including MIPS and MIPSel. Using a configuration tool (similar to the one used for the Linux Kernel), you can select compiler version, binutils version, and all softwares that should be included in the root filesystem. Then the Makefiles will automatically download, configure, compile, install and generate the toolchain and the root filesystem image.

Steven J. Hill

Steven J. Hill has a set of glibc/uClibc cross-toolchains over at: [1]

OpenEmbedded

The OpenEmbedded meta distribution also includes an automatic build of a full cross-toolchain for it's target architecture. http://www.openembedded.org

DENX ELDK

DENX Software Engineering provides the ELDK (Embedded Linux Development Kit), which includes both cross development and native tools for big and little endian MIPS processors (also for ARM and PowerPC). As it is Free Software it can be downloaded for FREE. See http://www.denx.de/wiki/DULG/ELDK

Gentoo crossdev

Gentoo provides a tool for creating full cross-compiling toolchains for a number of targets. On any Gentoo system, set up PORTAGE_OVERLAY in make.conf, then emerge crossdev to install it. Using a small startup shell script, these toolchains can be used with distcc as well, to allow distribution of a compile job over a cluster.

Debian

Embedded Debian project provides cross toolchains for various platforms, including mips and mipsel.

An alternative repository with newer toolchains built from Debian sources is available from [2].

Commercial Toolchains

All commercial Linux/MIPS distributions come with appropriate toolchain deliverables.

Roll-your-own

You're adverse to using someone else's toolchains, and cannot remember how to build one yourself, no matter how hard you try. Fear not. Outlined here is the proceedure to build a bootstrap toolchain; one which is minus the C library and is just enough to build the kernel.

Prologue

What you'll need:

Note that in general you want to use the latest versions released by the time a kernel was released. The versions listed here are known to be working well for recent kernels as of the time of writing. Using tools more recent than the kernel means that combination will not have been tested exhaustively so the likelihood of encountering incompatibilities increases. Sometimes tool compatibility versions are fixed in -stable but there is no guarantee that this also covers your favourite esoteric configuration.

Now, export a few environment variables for your convenience. If you're building for big-endian MIPS, your TARGET should be mips-unknown-linux-gnu instead. If you wish to install to a different location other than /opt/cross/, substitute in your PREFIX accordingly. A common alternative is /usr/local/.

% export WDIR=/tmp
% export TARGET=mipsel-unknown-linux-gnu
% export PREFIX=/opt/cross

You'll need to re-export your PATH with the new install location so when building a bootstrap gcc, it may locate the shiny new cross-binutils:

% export PATH="${PATH}":${PREFIX}/bin

Now change to the staging directory:

% cd $WDIR
% mkdir ${TARGET}-toolchain  && cd ${TARGET}-toolchain

Binutils

Extract, configure, build and install:

% tar xjf binutils-2.16.1.tar.bz2
% mkdir build-binutils && cd build-binutils
% ../binutils-2.16.1/configure --target=$TARGET --prefix=$PREFIX
% make
% make install
% cd ..

You should now have the cross-binutils installed under ${PREFIX}/bin/ with names prefixed by mipsel-unknown-linux-gnu-* (or mips-unknown-linux-gnu-* if you're building for big-endian MIPS).

GCC

Extract, configure, build and install a bootstrap GCC.

Enable any other language front-ends as you see fit. For building the kernel however, you can get away with just the C language front-end. Also, tell the configure script not to look for target libc headers -- we don't have them, and don't need them at this point.

% tar xjf gcc-3.4.4.tar.bz2
% mkdir build-gcc-bootstrap && cd build-gcc-bootstrap
% ../gcc-3.4.4/configure --target=$TARGET --prefix=$PREFIX \
  --enable-languages=c --without-headers \
  --with-gnu-ld --with-gnu-as \
  --disable-shared --disable-threads 
% make -j2
% make install
% cd ..

GDB

You'll need this for debugging either the kernel (with KGDB) or userspace (natively or with gdbserver). If this doesn't apply in your case, you may safely skip this section.

Extract, configure, build and install:

% tar xjf gdb-6.3.tar.bz2
% mkdir build-gdb && cd build-gdb
% ../gdb-6.3/configure --target=$TARGET --prefix=$PREFIX
% make
% make install
% cd ..

Summary

Your shiny new toolchain should be in your PATH, given you re-exported it earlier. Otherwise, you'll need to prefix your PATH with:

% ${PREFIX}/bin/mipsel-unknown-linux-gnu-

or for a big-endian target:

% ${PREFIX}/bin/mips-unknown-linux-gnu-

Enjoy.

See also