]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commit
toolchain: Provide abstraction for recipe specific toolchain selection
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 23 May 2025 03:52:35 +0000 (20:52 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 16 Jun 2025 21:26:35 +0000 (22:26 +0100)
commit45bdedd213aff8df3214b95ef2a8551c0abd93a0
treede6758144d16c5e7dfa0844b9c2ee52b2a90df72
parentd58f94d5684332bd4fac3747688558bb261b9c63
toolchain: Provide abstraction for recipe specific toolchain selection

This change implements a toolchain selection mechanism. Selection is
made using a set of variables, primarily PREFERRED_TOOLCHAIN_TARGET which
defaults to gcc.

It uses the familiar name for toolchain e.g. "gcc" which selects GNU
compiler + binutils as default C/C++ toolchain or "clang" which will
use LLVM/Clang Compiler. Layers an add their own toolchain definitions
too.

There are also PREFERRED_TOOLCHAIN_NATIVE and PREFERRED_TOOLCHAIN_SDK
which will ulitmately allow selection of the toolchain used for the
native/cross and nativesdk/crosssdk compilers. This currently isn't
functional but is essential to the patch to ensure things are set
to the existing gcc support in those cases.

Users would most commonly want to set:

PREFERRED_TOOLCHAIN_TARGET ?= "clang"

in local.conf or other distro specific global configuration metadata.

It is also selectable at recipe scope, since not all packages are
buildable with either clang or gcc, a recipe can explicitly require
a given toolchain using the TOOLCAHIN variable, e.g. glibc can not
be built with clang therefore glibc recipe sets:

TOOLCHAIN = "gcc"

The TOOLCHAIN variable is distinct from the user preference so recipes
with specific requirements can be identified. This also allows different
polcies to be be specified for native/SDK cases in the future.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-global/base.bbclass
meta/classes/toolchain/clang.bbclass [moved from meta/conf/toolchain/clang.inc with 100% similarity]
meta/classes/toolchain/gcc-native.bbclass [moved from meta/conf/toolchain/build-gcc.inc with 100% similarity]
meta/classes/toolchain/gcc.bbclass [moved from meta/conf/toolchain/gcc.inc with 100% similarity]
meta/conf/bitbake.conf
meta/recipes-devtools/binutils/binutils-cross.inc
meta/recipes-devtools/clang/clang-cross_git.bb
meta/recipes-devtools/clang/clang-crosssdk_git.bb