[PATCH 2/4] clang: Enable cmake flags for llvm, clang, lld tests

Deepesh.Varatharajan
2026-02-20T06:03:20Z

Enable the necessary CMake flags to build and run tests
for LLVM, Clang and LLD. Install the LLVM target tools
needed to run tests via llvm-lit inside QEMU.

Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
---
meta/recipes-devtools/clang/clang_git.bb | 2 ++
meta/recipes-devtools/clang/lld_git.bb | 2 ++
meta/recipes-devtools/clang/llvm_git.bb | 8 +++++++-
3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb
index e10c327a2a..a6950e433e 100644
--- a/meta/recipes-devtools/clang/clang_git.bb
+++ b/meta/recipes-devtools/clang/clang_git.bb
@@ -77,6 +77,8 @@ EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
-DCMAKE_STRIP=${STAGING_BINDIR_NATIVE}/llvm-strip \
"

+EXTRA_OECMAKE:append:class-target = "-DCLANG_INCLUDE_TESTS=ON -DLLVM_INCLUDE_TESTS=ON"
+
DEPENDS = "llvm-tblgen-native llvm-native llvm binutils zlib zstd libffi libxml2 libxml2-native"
DEPENDS:append:class-target = " ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcxx', '', d)}"

diff --git a/meta/recipes-devtools/clang/lld_git.bb b/meta/recipes-devtools/clang/lld_git.bb
index ba36942790..798e76746a 100644
--- a/meta/recipes-devtools/clang/lld_git.bb
+++ b/meta/recipes-devtools/clang/lld_git.bb
@@ -19,4 +19,6 @@ OECMAKE_SOURCEPATH = "${S}/lld"
EXTRA_OECMAKE += "-DLLVM_INCLUDE_TESTS=OFF -DLLVM_USE_SYMLINKS=ON \
-DLLVM_TABLEGEN_EXE=${STAGING_BINDIR_NATIVE}/llvm-tblgen"

+EXTRA_OECMAKE:append:class-target = "-DLLVM_INCLUDE_TESTS=ON"
+
BBCLASSEXTEND = "native nativesdk"
diff --git a/meta/recipes-devtools/clang/llvm_git.bb b/meta/recipes-devtools/clang/llvm_git.bb
index 96ea383731..d99d6336ff 100644
--- a/meta/recipes-devtools/clang/llvm_git.bb
+++ b/meta/recipes-devtools/clang/llvm_git.bb
@@ -48,6 +48,7 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=MinSizeRel \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_TOOL_OBJ2YAML_BUILD=OFF \
-DLLVM_TOOL_YAML2OBJ_BUILD=OFF \
+ -DLLVM_TOOL_LLVM_EXEGESIS_BUILD=ON \
-DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
-DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
-DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-native.cmake' \
@@ -58,6 +59,11 @@ EXTRA_OECMAKE:append:class-target = "\
-DLLVM_TARGET_ARCH=${HOST_ARCH} \
-DLLVM_HOST_TRIPLE=${TARGET_SYS}${HF} \
-DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config \
+ -DLLVM_INCLUDE_TESTS=ON \
+ -DLLVM_BUILD_TESTS=ON \
+ -DLLVM_INSTALL_GTEST=ON \
+ -DLLVM_TOOL_OBJ2YAML_BUILD=ON \
+ -DLLVM_TOOL_YAML2OBJ_BUILD=ON \
"

EXTRA_OECMAKE:append:class-nativesdk = "\
@@ -69,7 +75,6 @@ PACKAGECONFIG ??= "eh rtti shared-libs ${@bb.utils.filter('DISTRO_FEATURES', 'lt
PACKAGECONFIG:remove:class-native = "lto thin-lto"

PACKAGECONFIG[eh] = "-DLLVM_ENABLE_EH=ON,-DLLVM_ENABLE_EH=OFF"
-PACKAGECONFIG[exegesis] = "-DLLVM_TOOL_LLVM_EXEGESIS_BUILD=ON,-DLLVM_TOOL_LLVM_EXEGESIS_BUILD=OFF"
PACKAGECONFIG[libedit] = "-DLLVM_ENABLE_LIBEDIT=ON,-DLLVM_ENABLE_LIBEDIT=OFF,libedit"
PACKAGECONFIG[rtti] = "-DLLVM_ENABLE_RTTI=ON,-DLLVM_ENABLE_RTTI=OFF"
PACKAGECONFIG[shared-libs] = "-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON,-DLLVM_BUILD_LLVM_DYLIB=OFF -DLLVM_LINK_LLVM_DYLIB=OFF"
@@ -124,6 +129,7 @@ SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " llvm_sysroot_preprocess"
llvm_sysroot_preprocess() {
install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/
install -m 0755 ${S}/llvm/tools/llvm-config/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
+ install -m 0755 ${B}/bin/* ${SYSROOT_DESTDIR}${bindir}/
}

FILES:${PN}-dev += "${libdir}/llvm-config"
--
2.49.0