Skip to content
Cristoforo Cataldo edited this page Jun 9, 2014 · 3 revisions

HOW TO: Build your customized Cross Compiler Toolchain

This is a guide to make a custom build of your toolchain on Ubuntu Linux (I use version 12.10 and 13.04, but should also fit on 12.04).

1. Open the terminal, install the following packages (I hope the list is complete, let me know if something is missing):

sudo apt-get install mercurial mercurial-common flex bison gperf ncurses-dev texinfo gcc g++ \

autoconf automake libtool gawk patch autotools-dev libsigsegv2 libmpfr-dev libgmp-dev \

libltdl-dev libgmpxx4ldbl libmpc-dev expat libexpat1-dev libpython3.3 libpython3.3-stdlib \

libssl-dev libssl-dev zlib1g-dev subversion

2A. Clone my customized Linaro CrossTool-NG repository

git clone https://github.com/Christopher83/linaro_crosstool-ng.git

OR 2B. Clone Linaro CrossTool-NG repository

bzr branch lp:~linaro-toolchain-dev/crosstool-ng/linaro crosstool-ng

OR 2C. Clone Standard CrossTool-NG repository

hg clone http://crosstool-ng.org/hg/crosstool-ng

3. If you chose 2B or 2C, download, if you wish, the compressed archive containing my configuration files Sample configs for Linaro CrossTool-NG OR Sample configs for Standard CrossTool-NG and unzip it inside the folder crosstool-ng/samples (note: crosstool-ng is the folder of the builder sources you previously cloned)

4. Configure the folder where you would like to install the builder script (replace /crosstool-ng_install_path with the absolute path you prefer):

cd crosstool-ng

./bootstrap

./configure --prefix=/crosstool-ng_install_path

5) Build the sources and install the builder:

make

make install

Within your target folder /crosstool-ng_install_path you will find a new folder named bin with only an executable script named ct-ng

Edit your .bashrc

gedit ~/.bashrc

and add, at the bottom of the file, the reference to the installation location of the builder /crosstool-ng_install_path

export PATH=${PATH}:/crosstool-ng_install_path

6) You should be ready, try running these commands Display the script help

ct-ng help

View the list of samples configurations

ct-ng list-samples

Display the information about a sample configuration

ct-ng show config_name

7) Now proceed with the configuration of your toolchain 7A) Starting from a default configuration file sample

ct-ng arm-unknown-linux-gnueabi

ct-ng menuconfig

Remember to enable debugging, so if something goes wrong you can restart from the last successfull step

Paths and misc options --->

(*) Debug crosstool-NG

( ) Pause between every steps

(*) Save intermediate steps

(*) gzip saved states

7B) Starting from one of my configurations you can find inside the samples package

ct-ng chosen_configuration_name

ct-ng menuconfig

If the GCC version or the Linux version is not ready also after the sync of ct_ng repo, you have to temporarly edit the files:

  • config/cc/gcc.in
  • config/kernel/linux.in The same may be necessary for the other tools.

8) Build your toolchain (replace the 4 with the number of parallel jobs that you want, based on your number of cores)

ct-ng build.4

The build process takes a long time, depending on your network speed (you need to download all the source packages of the tools and libraries of the toolchain) and on your PC configuration.

NOTE: If the build fails, write down the last step was successful, check the error message and correct the configuration or install any missing package. You can get a list of the steps that can be used by running

ct-ng list-steps

After resolving the problem, you can restore the build simply running (replace last_successfull_step with your successfull built step)

ct-ng last_successfull_step+

The + after the name of the step means "restart from the step after the one indicated"

I hope I'm not missing anything. Let me know...

Clone this wiki locally