Crosstool-NG: Difference between revisions

From Linux/Xtensa
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
== Overview ==
== Overview ==


crosstool-NG provides a system to build a complete toolchain. It supports the c-libraries uClibc, glibc, and eglibc, but can also be used to build a 'bare' toolchain. The following describes the steps to build a toolchain tailored for an Xtensa configuration. In this example, we are building a 'bare' toolchain for the DC_D_233L processor configuration. 'Bare' in this sense means a toolchain without a c-library.  
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.  


== Building a 'bare' toolchain ==
== 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:
The mainline repository for crosstool-NG does not yet include support for Xtensa, so you need to clone the repository from linux-xtensa.org:
Line 11: Line 11:
=== Build ct-ng ===
=== Build ct-ng ===


ct-ng is similar to the command 'make' for other projects, and is used to configure and build the toolchain. Because this is not a released package but cloned from a repository, it is not yet preconfigured with 'autoconf'. So, the first step is to run autoconf:
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
  autoconf


The next step is to configure ct-ng for your system. crosstool-NG needs to install additional components. The default path is /usr/local/ but can be overwritten with the --prefix option. In this example, we install all additional files under $PWD in the current directory. Note that the prefix option requires an absolute path, so we use $PWD here:
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
  ./configure --prefix=$PWD/usr


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


  make install
  make install


=== Build the toolchain ===
== Building a 'bare' toolchain without a C-library ==


The first step is to configure crosstool-NG. Simply run
=== Configure the toolchain ===
 
The first step is to configure the toolchain:


  ./ct-ng menuconfig
  ./ct-ng menuconfig


Make sure to make the following changes (---> means to enter the sub-menu). We are assuming that the overlay file (src/xtensa-config-overlay.tar.gz) has been copied to /HOME/Overlay/CPUNAME.tar.gz.
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 [[Create Overlay|here]]. Note that the processor configuration name is currently not used.
 
Paths and misc options  --->                               
[*] Try features marked as EXPERIMENTAL
   
   
  Target options  --->                                         
  Target options  --->                                         
  Target Architecture (xtensa)  
  Target Architecture (xtensa)  
  Target Architecture Variant (Custom Xtensa processor configuration)
  Target Architecture Variant (Custom Xtensa processor configuration)
  (CPUNAME) Custom Xtensa process configuration name
  (PROCESSOR_NAME) Custom Xtensa process configuration name
  (/HOME/Overlay/) Full path to custom Xtensa processor configurations  
  (OVERLAY_TARFILE) Custom Xtensa overlay file name
(ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations
   
   
  C-library  --->                                               
  C-library  --->                                               
  C library (none)   
  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 ===
=== Build and install the toolchain ===


Finally, build and install the toolchain.  
Finally, build and install the toolchain.  
The default install directory is $HOME/x-tools, unless changed during the
configuration step above.


  ./ct-ng build
  ./ct-ng build
Line 55: Line 58:
  export PATH=$PATH:$HOME/x-tools/xtensa-unknown-linux-gnu/bin
  export PATH=$PATH:$HOME/x-tools/xtensa-unknown-linux-gnu/bin
  xtensa-unknown-linux-gnu-gcc t.c
  xtensa-unknown-linux-gnu-gcc t.c


== Building a 'glibc' based toolchain ''(experimental)'' ==
== Building a 'glibc' based toolchain ''(experimental)'' ==


The glibc port is experimental at the moment and also not part of the main repository yet. A version for Xtensa is on linux-xtensa.org, so you need to clone the glibc and crosstool-NG repositories:
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://linux-xtensa.org/git/crosstool-NG
  git clone git://linux-xtensa.org/git/glibc
  git clone git://linux-xtensa.org/git/glibc


[more instructions to follow...]
=== 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

Revision as of 21:21, 10 March 2013

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 git://linux-xtensa.org/git/crosstool-NG

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)

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://linux-xtensa.org/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