Difference between revisions of "Crosstool-NG"

From Linux/Xtensa
Jump to: navigation, search
(Building a 'glibc' based toolchain (experimental))
Line 7: Line 7:
 
The mainline repository for crosstool-NG does not yet include support for Xtensa, so you need to clone the repository from linux-xtensa.org:
 
The mainline repository for crosstool-NG does not yet include support for Xtensa, so you need to clone the repository from linux-xtensa.org:
  
  git clone git@github.com:foss-xtensa/crosstool-NG.git
+
  git clone https://github.com/foss-xtensa/crosstool-NG.git
  
 
=== Build ct-ng ===
 
=== Build ct-ng ===

Revision as of 19:36, 11 November 2013

Contents

Overview

Crosstool-NG provides a system to build a complete toolchain. It supports various C-libraries (newlib, uClibc, glibc, and eglibc), but can also be used to build a toolchain without a C-library. The following paragraphs describe the steps to build a toolchain tailored for an Xtensa configuration.

Configure and build Crosstool-NG

The mainline repository for crosstool-NG does not yet include support for Xtensa, so you need to clone the repository from linux-xtensa.org:

git clone https://github.com/foss-xtensa/crosstool-NG.git

Build ct-ng

ct-ng is similar to the command 'make' for other projects, and is used to configure and build the toolchain. Since we cloned it from the repository, it is not yet preconfigured with 'autoconf', so run autoconf first:

autoconf

The next step is to configure ct-ng for your system. The default installation path is /usr/local/ but can be overwritten with the --prefix option. In this example, we install it in the current directory. Note that the prefix option requires an absolute path, so we use $PWD in this example:

./configure --prefix=$PWD/usr

Finally, run 'make install' to build ct-ng and install it:

make install

Building a 'bare' toolchain without a C-library

Configure the toolchain

The first step is to configure the toolchain:

./ct-ng menuconfig

Make the following changes (---> means to enter the sub-menu). We are assuming that the overlay tar image (OVERLAY_TARFILE) has been copied to ABSOLUTE_PATH_TO_OVERLAY. More information about the overlay file can be found here. Note that the processor configuration name is currently not used.

Target options  --->                                         
Target Architecture (xtensa) 
Target Architecture Variant (Custom Xtensa processor configuration)
(PROCESSOR_NAME) Custom Xtensa process configuration name
(OVERLAY_TARFILE) Custom Xtensa overlay file name
(ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations  

C-library  --->                                              
C library (none)

The default directory for the created toolchain is $HOME/x-tools, but can be configured under 'Paths and misc options':

Paths and misc options  --->
(${HOME}/x-tools/${CT_TARGET}) Prefix directory

Build and install the toolchain

Finally, build and install the toolchain.

./ct-ng build

Test it

export PATH=$PATH:$HOME/x-tools/xtensa-unknown-linux-gnu/bin
xtensa-unknown-linux-gnu-gcc t.c


Building a 'glibc' based toolchain (experimental)

NOTE THAT THE REPOSITORY IS CURRENTLY NOT AVAILABLE.

The glibc port is experimental at the moment and also not part of the main repository yet. A version for Xtensa can be found on linux-xtensa.org, so you can clone it from there:

git clone git://.../git/glibc

Configure the toolchain

Similar to the 'bare' version above, the first step is to configure crosstool-NG. Simply run

./ct-ng menuconfig

and make the following changes (---> means to enter the sub-menu). We are assuming that the overlay file (Create Overlay) has been copied to ABSOLUTE_PATH_TO_OVERLAY/CPUNAME.tar.gz.

Paths and misc options --->
[*] Try features marked as EXPERIMENTAL
Target options  --->                                         
Target Architecture (xtensa) 
Target Architecture Variant (Custom Xtensa processor configuration)
(PROCESSOR_NAME) Custom Xtensa process configuration name
(OVERLAY_TARFILE) Custom Xtensa overlay file name
(ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations  

C-library  --->                                              
C library (glibc)
glibc version (Custom glibc)
(ABSOLUTE_PATH_TO_glibc-2.17) Full path to custom glibc source
(ports) Extra addons

Build and install the toolchain

Finally, build and install the toolchain.

./ct-ng build