poky/meta/recipes-devtools/clang/clang-crosssdk_git.bb
Richard Purdie 5317a214c5 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>
2025-06-16 22:26:38 +01:00

35 lines
1.3 KiB
BlitzBasic

# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
# Released under the MIT license (see COPYING.MIT for the terms)
SUMMARY = "SDK Cross compiler wrappers for LLVM based C/C++ compiler"
HOMEPAGE = "http://clang.llvm.org/"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab"
SECTION = "devel"
PN = "clang-crosssdk-${SDK_SYS}"
require common-clang.inc
require common-source.inc
inherit crosssdk
TOOLCHAIN = "clang"
DEPENDS += "clang-native nativesdk-clang-glue virtual/nativesdk-cross-binutils virtual/nativesdk-libc"
do_install() {
install -d ${D}${bindir}
for tool in clang clang++ clang-tidy lld ld.lld llvm-profdata \
llvm-nm llvm-ar llvm-as llvm-ranlib llvm-strip llvm-objcopy llvm-objdump llvm-readelf \
llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov
do
ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
done
}
SSTATE_SCAN_FILES += "*-clang *-clang++ *-llvm-profdata *-lld *-ld.lld \
*-llvm-nm *-llvm-ar *-llvm-as *-llvm-ranlib *-llvm-strip \
*-llvm-objcopy *-llvm-objdump *-llvm-readelf *-llvm-addr2line \
*-llvm-dwp *-llvm-size *-llvm-strings *-llvm-cov"
sysroot_stage_all () {
sysroot_stage_dir ${D}${bindir} ${SYSROOT_DESTDIR}${bindir}
}
PACKAGES = ""