Crosstool-NG: Difference between revisions

From Linux/Xtensa
Jump to navigation Jump to search
(update ct-ng status)
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
== Configure and build Crosstool-NG ==
== 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:
Starting with release 1.22.0 the mainline crosstool-NG repository includes support for Xtensa. Using tip of the cloned git tree for work is not always a good idea, unless you need the latest mainline changes using official releases (marked by tags) would give more predictable results.  


  git clone git@github.com:foss-xtensa/crosstool-NG.git
  git clone https://github.com/crosstool-ng/crosstool-ng.git
git checkout crosstool-ng-1.22.0


=== 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. Since we cloned it from the repository, it is not yet preconfigured with 'autoconf', so run autoconf first:
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, its build system is not configured yet, use ./bootstrap script to create it:


  autoconf
  ./bootstrap


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:
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. It is also possible to configure ct-ng for use without installation with --enable-local configure option:


  ./configure --prefix=$PWD/usr
  ./configure --enable-local


Finally, run 'make install' to build ct-ng and install it:
Finally, run 'make' to build ct-ng (and 'make install' to install it if needed):


  make install
  make
 
=== Xtensa core overlay file ===
The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by the crosstool-NG. For a script to convert the overlay file, and additional information, please go to [[Toolchain Overlay File]]. The current version of crosstool-NG requires that the overlay file name has the format xtensa_<CORE_NAME>.tar, where CORE_NAME can be any user selected name.


== Building a 'bare' toolchain without a C-library ==
== Building a 'bare' toolchain without a C-library ==
Line 31: Line 35:
  ./ct-ng menuconfig
  ./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 [[Create Overlay|here]]. Note that the processor configuration name is currently not used.
Make the following changes (---> means to enter the sub-menu). We are assuming that the overlay tar image (xtensa_<CORE_NAME>.tar) has been copied to ABSOLUTE_PATH_TO_OVERLAY.
   
   
  Target options  --->                                         
  Target options  --->                                         
  Target Architecture (xtensa)  
  Target Architecture (xtensa)  
  Target Architecture Variant (Custom Xtensa processor configuration)
  Target Architecture Variant (Custom Xtensa processor configuration)
  (PROCESSOR_NAME) Custom Xtensa process configuration name
  (CORE_NAME) Custom Xtensa process configuration file name
(OVERLAY_TARFILE) Custom Xtensa overlay file name
  (ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations   
  (ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations   
 
  C-library  --->                                               
  C-library  --->                                               
  C library (none)
  C library (none)
Line 59: Line 62:
  xtensa-unknown-linux-gnu-gcc t.c
  xtensa-unknown-linux-gnu-gcc t.c


== Building uClibc-ng based toolchain ==
=== 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).
Paths and misc options --->
[*] Try features marked as EXPERIMENTAL
Target options  --->                                       
Target Architecture (xtensa)
Target Architecture Variant (Custom Xtensa processor configuration)
(CORE_NAME) Custom Xtensa process configuration name
(ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations 
Operating system --->
Target OS (linux)
C-library  --->                                             
C library (uClibc)
=== Build and install the toolchain ===
Finally, build and install the toolchain.
./ct-ng build


== Building a 'glibc' based toolchain ''(experimental)'' ==
== Building a 'glibc' based toolchain ''(experimental)'' ==
Line 74: Line 107:
  ./ct-ng menuconfig
  ./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.
and make the following changes (---> means to enter the sub-menu).


  Paths and misc options --->
  Paths and misc options --->
Line 82: Line 115:
  Target Architecture (xtensa)  
  Target Architecture (xtensa)  
  Target Architecture Variant (Custom Xtensa processor configuration)
  Target Architecture Variant (Custom Xtensa processor configuration)
  (PROCESSOR_NAME) Custom Xtensa process configuration name
  (CORE_NAME) Custom Xtensa process configuration name
(OVERLAY_TARFILE) Custom Xtensa overlay file name
  (ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations   
  (ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations   
 
  C-library  --->                                               
  C-library  --->                                               
  C library (glibc)
  C library (glibc)

Latest revision as of 03:04, 19 November 2015

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

Starting with release 1.22.0 the mainline crosstool-NG repository includes support for Xtensa. Using tip of the cloned git tree for work is not always a good idea, unless you need the latest mainline changes using official releases (marked by tags) would give more predictable results.

git clone https://github.com/crosstool-ng/crosstool-ng.git
git checkout crosstool-ng-1.22.0

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, its build system is not configured yet, use ./bootstrap script to create it:

./bootstrap

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. It is also possible to configure ct-ng for use without installation with --enable-local configure option:

./configure --enable-local

Finally, run 'make' to build ct-ng (and 'make install' to install it if needed):

make

Xtensa core overlay file

The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by the crosstool-NG. For a script to convert the overlay file, and additional information, please go to Toolchain Overlay File. The current version of crosstool-NG requires that the overlay file name has the format xtensa_<CORE_NAME>.tar, where CORE_NAME can be any user selected name.

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 (xtensa_<CORE_NAME>.tar) has been copied to ABSOLUTE_PATH_TO_OVERLAY.

Target options  --->                                         
Target Architecture (xtensa) 
Target Architecture Variant (Custom Xtensa processor configuration)
(CORE_NAME) Custom Xtensa process configuration 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 uClibc-ng based toolchain

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).

Paths and misc options --->
[*] Try features marked as EXPERIMENTAL
Target options  --->                                         
Target Architecture (xtensa) 
Target Architecture Variant (Custom Xtensa processor configuration)
(CORE_NAME) Custom Xtensa process configuration name
(ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations  
Operating system --->
Target OS (linux)
C-library  --->                                              
C library (uClibc)

Build and install the toolchain

Finally, build and install the toolchain.

./ct-ng build

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).

Paths and misc options --->
[*] Try features marked as EXPERIMENTAL
Target options  --->                                         
Target Architecture (xtensa) 
Target Architecture Variant (Custom Xtensa processor configuration)
(CORE_NAME) Custom Xtensa process configuration 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