Adding a secondary toolchain

Revision as of 22:39, 13 November 2012 by Mhatle (Talk | contribs)

Jump to: navigation, search



In OpenEmbedded-Core there in an included toolchain that is built up of GNU binutils, gcc, and eglibc. In addition related components such as gdb, cross-prelink, mklibs and others provider additional toolchain functionality. In this document we focus on explaining best practices for including an additional toolchain that is capable of assembling, compiling and linking code. This document does not cover replacing the existing toolchain or toolchain components with external elements.

Many companies have commercial / highly optimized toolchains for specific purposes, such as ICC from Intel, LLVM, ARM Ltd toolchains, etc.. In some cases, these highly optimized toolchains may result in better performance for some applications, however they are often not generally applicable as they can not compile all of the system software. So instead of replacing the included GNU toolchain, a mechanism for providing an alternative/secondary toolchain is desired.


Secondary Toolchains should be implemented in a layer

In order to facilitate re-use and make it easier to completely disable the secondary toolchain, a layer must be used to implement the secondary toolchain.

Secondary Toolchain must be generally compatible with GNU toolchain

The secondary toolchain must be generally compatible with the idea of sysroots, linking to the defined libc, and various GNU conventions. This compatibility may be implemented directly by the secondary toolchain or via a wrapper of some type.

Per recipe selection of toolchain usage

A mechanism is needed to activate this alternative toolchain on a per-recipe basis. Using variables it should be possible to specify on a per-recipe basis which toolchain should be used, leaving the default up to the user. (It's assumed if the user does not select a default, the system GNU toolchain will be defaulted.)


Even with the requirement to be generally compatible, we can not expect all of the possible recipes to build properly with the secondary toolchain. As a consequence of this, it will be necessary to implement a blacklist (or whitelist) of specific recipes that are known to work. This way only supported components can be build by the user, avoid numerous complaints and unresolvable defects.


The SDK generated by OpenEmbedded-Core also includes the included toolchain components. It would be useful to also provide support for the secondary toolchain within the SDK environment.


Bitbake variables

A set of common bitbake variables, defined in meta/conf/bitbake.conf, are used to define how to run the toolchain components and the proper arguments.

A number of key items may need to be changed, depending on the toolchain being provided. These items may include:

  * CC
  * CXX
  * F77
  * CPP
  * LD
  * CCLD
  * AR
  * AS
  * NM

Each of the above items has a default definition within the meta/conf/bitbake.conf file. In addition, many of the components are based on specific tune variables such as:


Deciding which items need to be overridden is up to the author of the layer. It is expected that only a subset of the above referenced variables will need secondary toolchain specific versions for most implementations.


In order to allow for the layer to selectively override the variables listed above, a standard override syntax is needed.

The standard override syntax will be 'toolchain-${TOOLCHAIN}'. This will allow us to specify multiple alternative and primary toolchain combinations as necessary.

Each of the toolchain related variables can then be overridden using the standard override syntax: _toolchain-<toolchain>, such as:

CC_toolchain-icc = "icc ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"

In order for an individual recipe to use the secondary toolchain, the user would define: TOOLCHAIN_pn-<recipe> = 'toolchain', such as:

TOOLCHAIN_pn-bash = "icc"


A standard blacklist/whitelist facility is to be implemented. This facility is independent of the existing blacklist class that is part of OpenEmbedded-Core.

Similar to the existing blacklist class, you will be able to define a blacklist, per toolchain type, such as:

  TCBLACKLIST[pn] = "toolchain"

or alternatively create a whitelist facility using:

  TCBLACKLIST = "toolchain"
  TCWHITELIST[pn] = "toolchain"

Using the second approach will allow you to blacklist all recipes, and only enable those known to work with the alternative toolchain. A standard implementation is available in the secondary toolchain example.


MGH: Add SDK extension details

Implementation Example

The following example implements a secondary toolchain. The example is generated in a new layer named: meta-toolchain-test

MGH: include example here..

Further comments and information

Personal tools

OE services