diff mbox series

clang: Replace OE-specific test guard with upstream backport

Message ID 20260928071940.3890993-1-Deepesh.Varatharajan@windriver.com
State New
Headers show
Series clang: Replace OE-specific test guard with upstream backport | expand

Commit Message

Varatharajan, Deepesh Sept. 28, 2026, 7:19 a.m. UTC
From: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>

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 <Deepesh.Varatharajan@windriver.com>
---
 ...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
diff mbox series

Patch

diff --git a/meta/recipes-devtools/clang/clang/0034-clang-tools-extra-Add-separate-CLANG_TOOLS_EXTRA_INC.patch b/meta/recipes-devtools/clang/clang/0034-clang-tools-extra-Add-separate-CLANG_TOOLS_EXTRA_INC.patch
new file mode 100644
index 0000000000..f7b5d03703
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0034-clang-tools-extra-Add-separate-CLANG_TOOLS_EXTRA_INC.patch
@@ -0,0 +1,82 @@ 
+From f5fd1587149a039f4592b6e15647668175bb17a7 Mon Sep 17 00:00:00 2001
+From: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
+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 <Deepesh.Varatharajan@windriver.com>
+---
+ 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
+
diff --git a/meta/recipes-devtools/clang/clang/0034-guard-clang-tools-extra-test.patch b/meta/recipes-devtools/clang/clang/0034-guard-clang-tools-extra-test.patch
deleted file mode 100644
index 5e53d43944..0000000000
--- a/meta/recipes-devtools/clang/clang/0034-guard-clang-tools-extra-test.patch
+++ /dev/null
@@ -1,85 +0,0 @@ 
-From 9463b5d24fc62372fc2731d4d4665c64c72b55b2 Mon Sep 17 00:00:00 2001
-From: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
-Date: Wed, 19 Aug 2026 22:46:10 +0530
-Subject: [PATCH] guard clang-tools-extra test
-
-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. To run clang tests, disable clang-tools-extra tests for now.
-
-Without this patch when CLANG_INCLUDE_TESTS is ON got the following error
-
---------------------------------------------------------------------------------
-| CMake Error at ../clang/21.1.8/recipe-sysroot/usr/lib/cmake/llvm/AddLLVM.cmake:2113 (add_dependencies):
-|   The dependency target "llvm-bcanalyzer" of target
-|   "check-clang-extra-clang-tidy-infrastructure-header-filter-from-config-file-simple"
-|   does not exist.
-| Call Stack (most recent call first):
-|   ../clang/21.1.8/recipe-sysroot/usr/lib/cmake/llvm/AddLLVM.cmake:2221 (add_lit_target)
-|   tools/extra/test/CMakeLists.txt:87 (add_lit_testsuites)
-|
-| CMake Error at ../clang/21.1.8/recipe-sysroot/usr/lib/cmake/llvm/AddLLVM.cmake:2113 (add_dependencies):
-|   The dependency target "llvm-bcanalyzer" of target
-|   "check-clang-extra-modularize" does not exist.
-| Call Stack (most recent call first):
-|   ../clang/21.1.8/recipe-sysroot/usr/lib/cmake/llvm/AddLLVM.cmake:2221 (add_lit_target)
-|   tools/extra/test/CMakeLists.txt:87 (add_lit_testsuites)
--------------------------------------------------------------------------------
-
-Upstream-Status: Inappropriate [OE-Specific]
-
-Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
----
- clang-tools-extra/CMakeLists.txt                 | 4 ++--
- clang-tools-extra/clangd/CMakeLists.txt          | 2 +-
- clang-tools-extra/include-cleaner/CMakeLists.txt | 2 +-
- 3 files changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt
-index 87050db..3824129 100644
---- a/clang-tools-extra/CMakeLists.txt
-+++ b/clang-tools-extra/CMakeLists.txt
-@@ -8,7 +8,7 @@ option(CLANG_TIDY_ENABLE_STATIC_ANALYZER
- option(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
-   "Enable query-based custom checks in clang-tidy" ON)
- 
--if(CLANG_INCLUDE_TESTS)
-+if(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)
-@@ -45,7 +45,7 @@ if (CLANG_ENABLE_CLANGD)
- endif()
- 
- # Add the common testsuite after all the tools.
--if(CLANG_INCLUDE_TESTS)
-+if(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 890562d..c4d6623 100644
---- a/clang-tools-extra/clangd/CMakeLists.txt
-+++ b/clang-tools-extra/clangd/CMakeLists.txt
-@@ -217,7 +217,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_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 dc147f9..4855577 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_TOOLS_EXTRA_INCLUDE_TESTS)
-   add_subdirectory(test)
-   add_subdirectory(unittests)
- endif()
diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb
index c54a49b618..3b93f0d02c 100644
--- a/meta/recipes-devtools/clang/clang_git.bb
+++ b/meta/recipes-devtools/clang/clang_git.bb
@@ -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 \
diff --git a/meta/recipes-devtools/clang/common.inc b/meta/recipes-devtools/clang/common.inc
index 5b358f7284..d10337a720 100644
--- a/meta/recipes-devtools/clang/common.inc
+++ b/meta/recipes-devtools/clang/common.inc
@@ -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 ??= ""