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.

+

In OpenEmbedded-Core there is 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.

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.

Line 63:

Line 63:

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.

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.

+

+

It is suggested that the secondary toolchain values be defined in a single configuration file. Within the example this is "conf/tc-example.conf". The standard name for the file should be 'conf/tc-<toolchain>.conf'.

=== Override ===

=== Override ===

Line 93:

Line 95:

TCWHITELIST[pn] = "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.

+

Using the second approach will allow you to blacklist all recipes, and only enable those known to work with the alternative toolchain.

+

+

The blacklist items should be defined within conf/tc-<toolchain>-blacklist.conf. The validation of the blacklist should use the standard tc-blacklist.bbclass implementation available within the example.

=== SDK ===

=== SDK ===

−

MGH: Add SDK extension details

+

In order to make it easier to use the alternative toolchain within the SDK. An additional environment-* file should be created. The purpose of this file is to simply override the settings in the main environment file.

+

+

See the example section for an implementation that will create this file automatically.

== Implementation Example ==

== Implementation Example ==

−

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

+

An example implementation has been created in the layer "meta-tc-example". The file format follows:

−

MGH: include example here..

+

meta-tc-example/

+

meta-tc-example/bin

+

meta-tc-example/bin/example-toolchain

+

meta-tc-example/conf

+

meta-tc-example/conf/layer.conf

+

meta-tc-example/conf/tc-example.conf

+

meta-tc-example/conf/tc-example-blacklist.conf

+

meta-tc-example/classes

+

meta-tc-example/classes/tc-secondary.bbclass

+

meta-tc-example/classes/tc-blacklist.bbclass

+

+

The following example is available at: [http://gate.crashing.org/~fray/yocto/meta-tc-example.tar.bz2 meta-tc-example.tar.bz2]

Above is standard layer configuration. Note, the commented out sections should be re-enabled if the secondary toolchain includes recipes and/or bbappend files.

+

+

PATH := "${PATH}:${LAYERDIR}/bin"

+

+

Add to the path a standard system path, a layer specific path. This is the way you can add a secondary toolchain to the path.

+

+

# Define the alternative toolchain

+

SECONDARYTC = 'example'

+

+

# Enable the secondary toolchain

+

INHERIT += 'tc-secondary tc-blacklist'

+

+

Define the alternative toolchain name in SECONDARYTC. The inherit causes the tc-secondary.bbclass and tc-blacklist.bbclass to be loaded later. Eventually this class used SECONDARYTC to load in the secondary toolchain configuration files.

+

+

=== conf/tc-example.conf ===

+

+

# Define default system toolchain (default to built-in)

+

TOOLCHAIN = 'gnu'

+

+

Define a reasonable default such as gnu. The purpose of this default is to allow someone to specify the default or provide default override items for the built-in toolchain.

+

+

# Define a secondary toolchain called 'example'

+

# the 'example' toolchain can be activated using:

+

#

+

# Per package (preferred):

+

# TOOLCHAIN_pn-bash = 'example'

+

#

+

# Globally:

+

# TOOLCHAIN = 'example'

+

# TOOLCHAIN_pn-eglibc = 'gnu'

+

+

The above is an example of how to use the alternative toolchain.

+

+

# When the secondary toolchain is used, we add an automatic depend...

+

DEPENDS_append_toolchain-example = " virtual/TOOLCHAIN-EXAMPLE"

+

+

# ...the depend can be provided by a recipe or as an ASSUME_PROVIDED

+

ASSUME_PROVIDED_append = " virtual/TOOLCHAIN-EXAMPLE"

+

+

Use the above as an example on how to add additional dependencies to specific packages. This can be used to trigger a recipe to build.

The above implements the necessary overrides for the example toolchain.

+

+

=== conf/tc-example-blacklist.conf ===

+

+

Example configuration file that enables the blacklist and defines the defaults.

+

+

# Blacklist certain items...

+

TCBLACKLIST[eglibc] = 'example'

+

TCBLACKLIST[bash] = 'example'

+

+

#

+

# or

+

#

+

+

# Switch to a global blacklist and whitelist situation...

+

# TCBLACKLIST = 'example'

+

# TCWHITELIST[bash] = 'example'

+

+

=== classes/tc-secondary.bbclass ===

+

+

This is the standard secondary toolchain class. It should be the same in all secondary toolchain layers.

+

+

# In order to add overrides, we need to do it later then in the layers.conf

+

# the only standard way is using an inherit, which requires a bbclass

+

+

# Add the necessary override

+

TOOLCHAINOVERRIDES = ":toolchain-${TOOLCHAIN}"

+

TOOLCHAINOVERRIDES[vardepsexclude] = "TOOLCHAIN"

+

+

OVERRIDES .= "${TOOLCHAINOVERRIDES}"

+

OVERRIDES[vardepsexclude] += "TOOLCHAINOVERRIDES"

+

+

require conf/tc-${SECONDARYTC}.conf

+

+

The above code configures the basic overrides and loads the configuration file. There is one limitation to the above however. It will only load one secondary toolchain. A simple way around this is to rename the inherit and change to using something other then SECONDARYTC. This likely will not be a problem.

The above code will add an additional environment-setup-*-<toolchain> file. This can be used to enable the right environment to use the alternative toolchain. Note, it does not add anything to the path so the user will still need to configure the path to the alternative toolchain. (The layer creator can always provide the necessary 'nativesdk' or similar package that provides the alternative toolchain as part of the SDK as well.)

+

+

=== classes/tc-blacklist.bbclass ===

+

+

This is the standard secondary toolchain blacklist class. It should be the same in all secondary toolchain layers.

In OpenEmbedded-Core there is 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.

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

Blacklist/Whitelist

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.

SDK

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.

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:

* TUNE_CCARGS
* TUNE_LDARGS
* TUNE_ASARGS

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.

It is suggested that the secondary toolchain values be defined in a single configuration file. Within the example this is "conf/tc-example.conf". The standard name for the file should be 'conf/tc-<toolchain>.conf'.

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.

The blacklist items should be defined within conf/tc-<toolchain>-blacklist.conf. The validation of the blacklist should use the standard tc-blacklist.bbclass implementation available within the example.

In order to make it easier to use the alternative toolchain within the SDK. An additional environment-* file should be created. The purpose of this file is to simply override the settings in the main environment file.

See the example section for an implementation that will create this file automatically.

Define the alternative toolchain name in SECONDARYTC. The inherit causes the tc-secondary.bbclass and tc-blacklist.bbclass to be loaded later. Eventually this class used SECONDARYTC to load in the secondary toolchain configuration files.

# When the secondary toolchain is used, we add an automatic depend...
DEPENDS_append_toolchain-example = " virtual/TOOLCHAIN-EXAMPLE"
# ...the depend can be provided by a recipe or as an ASSUME_PROVIDED
ASSUME_PROVIDED_append = " virtual/TOOLCHAIN-EXAMPLE"

Use the above as an example on how to add additional dependencies to specific packages. This can be used to trigger a recipe to build.

This is the standard secondary toolchain class. It should be the same in all secondary toolchain layers.

# In order to add overrides, we need to do it later then in the layers.conf
# the only standard way is using an inherit, which requires a bbclass
# Add the necessary override
TOOLCHAINOVERRIDES = ":toolchain-${TOOLCHAIN}"
TOOLCHAINOVERRIDES[vardepsexclude] = "TOOLCHAIN"
OVERRIDES .= "${TOOLCHAINOVERRIDES}"
OVERRIDES[vardepsexclude] += "TOOLCHAINOVERRIDES"
require conf/tc-${SECONDARYTC}.conf

The above code configures the basic overrides and loads the configuration file. There is one limitation to the above however. It will only load one secondary toolchain. A simple way around this is to rename the inherit and change to using something other then SECONDARYTC. This likely will not be a problem.

The above code will add an additional environment-setup-*-<toolchain> file. This can be used to enable the right environment to use the alternative toolchain. Note, it does not add anything to the path so the user will still need to configure the path to the alternative toolchain. (The layer creator can always provide the necessary 'nativesdk' or similar package that provides the alternative toolchain as part of the SDK as well.)