How to build a GCC cross compiler?
Building a GCC cross compiler from
scratch is a very tedious task. The process consists of a quite
high number of undocumented steps, and mostly relies on the users'
experience. Fortunately a community sharing its experience, the
crossgcc mailing list,
actively supports a tool, crosstool-NG, that considerably
simplifies the process of building a GCC cross compiler.
This will create a file named ".config" within the crosstool-NG
directory.
1. Get crosstool-NG
Download the crosstool-NG archive (e.g crosstool-ng-1.13.2.tar.bz2) from this page.2. Uncompress crosstool-NG archive
$ tar jxvf crosstool-ng-1.13.2.tar.bz2
3. Configure crosstool-NG
$ cd crosstool-ng-1.13.2
$ ./configure --local
$ ./configure --local
4. Compile crosstool-NG
$ make
5. Customize your own gcc cross compiler build
$ ./ct-ng menuconfig
The crosstool-NG user interface enables customizing the cross-tool
chain to build. It means that you can choose and configure:
- the C/C++ compiler,
- the C Library (either glibc, eglibc, newlib),
- the target processor (e.g. PowerPC or ARM),
- the operating system (e.g. Linux),
- the debug facilities (e.g. a debugger),
- etc.
Crosstool-NG cross compiler configuration menu |
Crosstool-NG cross compiler configuration saving |
6. Build your custom gcc cross compiler
$ ./ct-ng build