summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2025-05-22 20:52:35 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-06-16 22:26:38 +0100
commit5317a214c5932aa04609acbc136be9b2f98a228c (patch)
tree9c7252d235e23c0773d7540ad9a5ca23a20de0c6
parentc49991441c9a5bf0d0ec2dd951e4ad2d76a42eca (diff)
downloadpoky-5317a214c5932aa04609acbc136be9b2f98a228c.tar.gz
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. (From OE-Core rev: 45bdedd213aff8df3214b95ef2a8551c0abd93a0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-global/base.bbclass15
-rw-r--r--meta/classes/toolchain/clang.bbclass (renamed from meta/conf/toolchain/clang.inc)0
-rw-r--r--meta/classes/toolchain/gcc-native.bbclass (renamed from meta/conf/toolchain/build-gcc.inc)0
-rw-r--r--meta/classes/toolchain/gcc.bbclass (renamed from meta/conf/toolchain/gcc.inc)0
-rw-r--r--meta/conf/bitbake.conf3
-rw-r--r--meta/recipes-devtools/binutils/binutils-cross.inc2
-rw-r--r--meta/recipes-devtools/clang/clang-cross_git.bb1
-rw-r--r--meta/recipes-devtools/clang/clang-crosssdk_git.bb1
8 files changed, 19 insertions, 3 deletions
diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
index 4ac3b83eb5..e55a538e36 100644
--- a/meta/classes-global/base.bbclass
+++ b/meta/classes-global/base.bbclass
@@ -19,6 +19,21 @@ PACKAGECONFIG_CONFARGS ??= ""
19 19
20inherit metadata_scm 20inherit metadata_scm
21 21
22PREFERRED_TOOLCHAIN_TARGET ??= "gcc"
23PREFERRED_TOOLCHAIN_NATIVE ??= "gcc"
24PREFERRED_TOOLCHAIN_SDK ??= "gcc"
25
26PREFERRED_TOOLCHAIN = "${PREFERRED_TOOLCHAIN_TARGET}"
27PREFERRED_TOOLCHAIN:class-native = "${PREFERRED_TOOLCHAIN_NATIVE}"
28PREFERRED_TOOLCHAIN:class-cross = "${PREFERRED_TOOLCHAIN_NATIVE}"
29PREFERRED_TOOLCHAIN:class-crosssdk = "${PREFERRED_TOOLCHAIN_SDK}"
30PREFERRED_TOOLCHAIN:class-nativesdk = "${PREFERRED_TOOLCHAIN_SDK}"
31
32TOOLCHAIN ??= "${PREFERRED_TOOLCHAIN}"
33
34inherit toolchain/gcc-native
35inherit_defer toolchain/${TOOLCHAIN}
36
22def lsb_distro_identifier(d): 37def lsb_distro_identifier(d):
23 adjust = d.getVar('LSB_DISTRO_ADJUST') 38 adjust = d.getVar('LSB_DISTRO_ADJUST')
24 adjust_func = None 39 adjust_func = None
diff --git a/meta/conf/toolchain/clang.inc b/meta/classes/toolchain/clang.bbclass
index 8a0a2c315a..8a0a2c315a 100644
--- a/meta/conf/toolchain/clang.inc
+++ b/meta/classes/toolchain/clang.bbclass
diff --git a/meta/conf/toolchain/build-gcc.inc b/meta/classes/toolchain/gcc-native.bbclass
index a708bd0389..a708bd0389 100644
--- a/meta/conf/toolchain/build-gcc.inc
+++ b/meta/classes/toolchain/gcc-native.bbclass
diff --git a/meta/conf/toolchain/gcc.inc b/meta/classes/toolchain/gcc.bbclass
index 75f9abe999..75f9abe999 100644
--- a/meta/conf/toolchain/gcc.inc
+++ b/meta/classes/toolchain/gcc.bbclass
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 8686c0a25f..aa184ff9f5 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -834,9 +834,6 @@ include conf/licenses.conf
834require conf/sanity.conf 834require conf/sanity.conf
835include conf/bblock.conf 835include conf/bblock.conf
836 836
837require toolchain/gcc.inc
838require toolchain/build-gcc.inc
839
840################################################################## 837##################################################################
841# Weak variables (usually to retain backwards compatibility) 838# Weak variables (usually to retain backwards compatibility)
842################################################################## 839##################################################################
diff --git a/meta/recipes-devtools/binutils/binutils-cross.inc b/meta/recipes-devtools/binutils/binutils-cross.inc
index 9c371e7e13..c545ea2ad9 100644
--- a/meta/recipes-devtools/binutils/binutils-cross.inc
+++ b/meta/recipes-devtools/binutils/binutils-cross.inc
@@ -9,6 +9,8 @@ TARGET_ARCH[vardepvalue] = "${TARGET_ARCH}"
9INHIBIT_DEFAULT_DEPS = "1" 9INHIBIT_DEFAULT_DEPS = "1"
10INHIBIT_AUTOTOOLS_DEPS = "1" 10INHIBIT_AUTOTOOLS_DEPS = "1"
11 11
12TOOLCHAIN = "gcc"
13
12SRC_URI += "file://0002-binutils-cross-Do-not-generate-linker-script-directo.patch" 14SRC_URI += "file://0002-binutils-cross-Do-not-generate-linker-script-directo.patch"
13 15
14# Specify lib-path else we use a load of search dirs which we don't use 16# Specify lib-path else we use a load of search dirs which we don't use
diff --git a/meta/recipes-devtools/clang/clang-cross_git.bb b/meta/recipes-devtools/clang/clang-cross_git.bb
index 9b9b120a3d..323cc0d880 100644
--- a/meta/recipes-devtools/clang/clang-cross_git.bb
+++ b/meta/recipes-devtools/clang/clang-cross_git.bb
@@ -11,6 +11,7 @@ PN = "clang-cross-${TARGET_ARCH}"
11require common-clang.inc 11require common-clang.inc
12require common-source.inc 12require common-source.inc
13inherit cross 13inherit cross
14TOOLCHAIN = "clang"
14DEPENDS += "clang-native virtual/cross-binutils" 15DEPENDS += "clang-native virtual/cross-binutils"
15 16
16#INHIBIT_PACKAGE_STRIP = "1" 17#INHIBIT_PACKAGE_STRIP = "1"
diff --git a/meta/recipes-devtools/clang/clang-crosssdk_git.bb b/meta/recipes-devtools/clang/clang-crosssdk_git.bb
index 47ac96f4f9..ef162ef153 100644
--- a/meta/recipes-devtools/clang/clang-crosssdk_git.bb
+++ b/meta/recipes-devtools/clang/clang-crosssdk_git.bb
@@ -11,6 +11,7 @@ PN = "clang-crosssdk-${SDK_SYS}"
11require common-clang.inc 11require common-clang.inc
12require common-source.inc 12require common-source.inc
13inherit crosssdk 13inherit crosssdk
14TOOLCHAIN = "clang"
14DEPENDS += "clang-native nativesdk-clang-glue virtual/nativesdk-cross-binutils virtual/nativesdk-libc" 15DEPENDS += "clang-native nativesdk-clang-glue virtual/nativesdk-cross-binutils virtual/nativesdk-libc"
15 16
16do_install() { 17do_install() {