Skip to content

Commit ff54c4c

Browse files
committed
toolchain: Provide abstraction for recipe specific toolchain selection
This implements a toolchain selection mechanism, defaulting to gcc as per the existing defaults. Introduce a variable called TOOLCHAIN, which denotes 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 TOOLCHAIN variable has a global fallback to "gcc" in configuration metadata. A distro can switch to using say "clang" as default system compiler by defining TOOLCHAIN ?= "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 demand a given toolchain e.g. glibc can not be built with clang therefore glibc recipe sets. TOOLCHAIN = "gcc" Based on ideas/work by Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
1 parent 74ce7e4 commit ff54c4c

File tree

8 files changed

+10
-3
lines changed

8 files changed

+10
-3
lines changed

meta/classes-global/base.bbclass

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ PACKAGECONFIG_CONFARGS ??= ""
1919

2020
inherit metadata_scm
2121

22+
TOOLCHAIN ??= "gcc"
23+
TOOLCHAIN:class-native ??= "gcc"
24+
TOOLCHAIN:class-nativesdk ??= "gcc"
25+
inherit toolchain/gcc-native
26+
inherit_defer toolchain/${TOOLCHAIN}
27+
2228
def lsb_distro_identifier(d):
2329
adjust = d.getVar('LSB_DISTRO_ADJUST')
2430
adjust_func = None
File renamed without changes.
File renamed without changes.

meta/conf/bitbake.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,6 @@ include conf/licenses.conf
834834
require conf/sanity.conf
835835
include conf/bblock.conf
836836

837-
require toolchain/gcc.inc
838-
require toolchain/build-gcc.inc
839-
840837
##################################################################
841838
# Weak variables (usually to retain backwards compatibility)
842839
##################################################################

meta/recipes-devtools/binutils/binutils-cross.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ TARGET_ARCH[vardepvalue] = "${TARGET_ARCH}"
99
INHIBIT_DEFAULT_DEPS = "1"
1010
INHIBIT_AUTOTOOLS_DEPS = "1"
1111

12+
TOOLCHAIN = "gcc"
13+
1214
SRC_URI += "file://0002-binutils-cross-Do-not-generate-linker-script-directo.patch"
1315

1416
# Specify lib-path else we use a load of search dirs which we don't use

meta/recipes-devtools/clang/clang-cross_git.bb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PN = "clang-cross-${TARGET_ARCH}"
1111
require common-clang.inc
1212
require common-source.inc
1313
inherit_defer cross
14+
TOOLCHAIN = "clang"
1415
DEPENDS += "clang-native virtual/cross-binutils"
1516

1617
#INHIBIT_PACKAGE_STRIP = "1"

meta/recipes-devtools/clang/clang-crosssdk_git.bb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PN = "clang-crosssdk-${SDK_SYS}"
1111
require common-clang.inc
1212
require common-source.inc
1313
inherit_defer crosssdk
14+
TOOLCHAIN = "clang"
1415
DEPENDS += "clang-native nativesdk-clang-glue virtual/nativesdk-cross-binutils virtual/nativesdk-libc"
1516

1617
do_install() {

0 commit comments

Comments
 (0)