clang: Replace OE-specific test guard with upstream backport
PATCH 1/1 clang: Replace OE-specific test guard with upstream backport
From: Deepesh Varatharajan <[email protected]>
Drop 0034-guard-clang-tools-extra-test.patch (Upstream-Status:
Inappropriate) in favor of the upstream fix that introduces a separate CLANG_TOOLS_EXTRA_INCLUDE_TESTS CMake option.
https://github.com/llvm/llvm-project/commit/f5fd1587149a039f4592b6e15647668175bb17a7
This lets Clang be built with CLANG_INCLUDE_TESTS=ON while disabling clang-tools-extra tests, avoiding the missing llvm-bcanalyzer target error when Clang is built separately from LLVM. Set -DCLANG_TOOLS_EXTRA_INCLUDE_TESTS=OFF in clang_git.bb accordingly.
Signed-off-by Deepesh Varatharajan <[email protected]>
--- ...a-Add-separate-CLANG_TOOLS_EXTRA_INC.patch | 82 ++++++++++++++++++ .../0034-guard-clang-tools-extra-test.patch | 85 ------------------- meta/recipes-devtools/clang/clang_git.bb | 1 + meta/recipes-devtools/clang/common.inc | 2 +- 4 files changed, 84 insertions(+), 86 deletions(-) create mode 100644 meta/recipes-devtools/clang/clang/0034-clang-tools-extra-Add-separate-CLANG_TOOLS_EXTRA_INC.patch delete mode 100644 meta/recipes-devtools/clang/clang/0034-guard-clang-tools-extra-test.patch
meta/recipes-devtools/clang/clang/0034-clang-tools-extra-Add-separate-CLANG_TOOLS_EXTRA_INC.patch new file +82 -0
@@ -0,0 +1,82 @@ +From f5fd1587149a039f4592b6e15647668175bb17a7 Mon Sep 17 00:00:00 2001 +From: Deepesh Varatharajan <[email protected]> +Date: Sun, 30 Aug 2026 01:34:52 +0530 +Subject: [PATCH] [clang-tools-extra] Add separate + CLANG_TOOLS_EXTRA_INCLUDE_TESTS option (#215761) + +clang-tools-extra tests depend on the llvm-bcanalyzer CMake target, +which exists in LLVM's CMake project but is not visible when Clang is +built separately from LLVM. This causes CMake errors when +CLANG_INCLUDE_TESTS is ON but the LLVM tools are not available. + +This patch introduces CLANG_TOOLS_EXTRA_INCLUDE_TESTS as a separate +CMake option to control clang-tools-extra tests independently, allowing +users to build Clang with tests enabled (CLANG_INCLUDE_TESTS=ON) while +disabling clang-tools-extra tests (CLANG_TOOLS_EXTRA_INCLUDE_TESTS=OFF) +when building Clang separately from LLVM. + +For backwards compatibility, CLANG_INCLUDE_TESTS=OFF continues +to turn off clang-tools-extra tests as well. + +Upstream-Status: Backport [https://github.com/llvm/llvm-project/commit/f5fd1587149a039f4592b6e15647668175bb17a7] +Signed-off-by: Deepesh Varatharajan <[email protected]> +--- + clang-tools-extra/CMakeLists.txt | 6 ++++-- + clang-tools-extra/clangd/CMakeLists.txt | 2 +- + clang-tools-extra/include-cleaner/CMakeLists.txt | 2 +- + 3 files changed, 6 insertions(+), 4 deletions(-) + +diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt +index 0dbdeaed9a9a..291e130ca390 100644 +--- a/clang-tools-extra/CMakeLists.txt ++++ b/clang-tools-extra/CMakeLists.txt +@@ -7,8 +7,10 @@ option(CLANG_TIDY_ENABLE_STATIC_ANALYZER + "Include static analyzer checks in clang-tidy" ON) + option(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS + "Enable query-based custom checks in clang-tidy" ON) ++option(CLANG_TOOLS_EXTRA_INCLUDE_TESTS ++ "Generate build targets for Clang Extra Tools tests." ON) + +-if(CLANG_INCLUDE_TESTS) ++if(CLANG_INCLUDE_TESTS AND CLANG_TOOLS_EXTRA_INCLUDE_TESTS) + umbrella_lit_testsuite_begin(check-clang-tools) + + option(CLANG_TOOLS_TEST_USE_VG "Run Clang tools' tests under Valgrind" OFF) +@@ -46,7 +48,7 @@ if (CLANG_ENABLE_CLANGD) + endif() + + # Add the common testsuite after all the tools. +-if(CLANG_INCLUDE_TESTS) ++if(CLANG_INCLUDE_TESTS AND CLANG_TOOLS_EXTRA_INCLUDE_TESTS) + add_subdirectory(test) + add_subdirectory(unittests) + umbrella_lit_testsuite_end(check-clang-tools) +diff --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt +index 151f4ee028b8..3aa1b7bddb99 100644 +--- a/clang-tools-extra/clangd/CMakeLists.txt ++++ b/clang-tools-extra/clangd/CMakeLists.txt +@@ -219,7 +219,7 @@ endif() + option(CLANGD_BUILD_DEXP "Build the dexp tool as part of Clangd" ON) + llvm_canonicalize_cmake_booleans(CLANGD_BUILD_DEXP) + +-if(CLANG_INCLUDE_TESTS) ++if(CLANG_INCLUDE_TESTS AND CLANG_TOOLS_EXTRA_INCLUDE_TESTS) + add_subdirectory(test) + add_subdirectory(unittests) + endif() +diff --git a/clang-tools-extra/include-cleaner/CMakeLists.txt b/clang-tools-extra/include-cleaner/CMakeLists.txt +index dc147f9ca08d..4ccd3da21f70 100644 +--- a/clang-tools-extra/include-cleaner/CMakeLists.txt ++++ b/clang-tools-extra/include-cleaner/CMakeLists.txt +@@ -1,7 +1,7 @@ + include_directories(include) + add_subdirectory(lib) + add_subdirectory(tool) +-if(CLANG_INCLUDE_TESTS) ++if(CLANG_INCLUDE_TESTS AND CLANG_TOOLS_EXTRA_INCLUDE_TESTS) + add_subdirectory(test) + add_subdirectory(unittests) + endif() +-- +2.49.0 +
meta/recipes-devtools/clang/clang/0034-guard-clang-tools-extra-test.patch deleted +0 -85
85 lines not on this page · raw message
meta/recipes-devtools/clang/clang_git.bb +1 -0
@@ -67,6 +67,7 @@ EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \ -DLLVM_TABLEGEN_EXE=${STAGING_BINDIR_NATIVE}/llvm-tblgen \ -DCLANG_TABLEGEN_EXE=${STAGING_BINDIR_NATIVE}/clang-tblgen \ -DLLVM_INCLUDE_TESTS=OFF \ + -DCLANG_TOOLS_EXTRA_INCLUDE_TESTS=OFF \ -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-native.cmake' \ -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \ -DCMAKE_AR=${STAGING_BINDIR_NATIVE}/llvm-ar \
meta/recipes-devtools/clang/common.inc +1 -1
@@ -53,7 +53,7 @@ SRC_URI = "\ file://0031-Only-build-clang-tblgen-if-it-is-actually-needed.patch \ file://0032-llvm-libgcc-Fix-symlink-path-for-libcc-when-LLVM_ENA.patch \ file://0033-Consolidate-and-fix-sysroot-based-compiler-rt-search.patch \ - file://0034-guard-clang-tools-extra-test.patch \ + file://0034-clang-tools-extra-Add-separate-CLANG_TOOLS_EXTRA_INC.patch \ " # Fallback to no-PIE if not set GCCPIE ??= ""
Signature · 1 line
2.49.0