https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/172685

None

>From 1125c8a25a5511629a5f0303624925802ed75e3a Mon Sep 17 00:00:00 2001
From: David Spickett <[email protected]>
Date: Wed, 17 Dec 2025 14:24:31 +0000
Subject: [PATCH] WIP: allow builds to opt out of single clang unit test binary

---
 clang/CMakeLists.txt                    |  4 +++
 clang/unittests/CMakeLists.txt          | 39 +++++++++++++++----------
 clang/unittests/Frontend/CMakeLists.txt |  1 +
 3 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index e4cb1a359620d..24b95011b57ad 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -475,6 +475,10 @@ option(CLANG_INCLUDE_TESTS
        "Generate build targets for the Clang unit tests."
        ${LLVM_INCLUDE_TESTS})
 
+option(CLANG_UNITTEST_SINGLE_BINARY
+       "Combine most Clang unit tests into a single binary."
+       ON)
+
 option(CLANG_ENABLE_HLSL "Include HLSL build products" Off)
 # While HLSL support is experimental this should stay hidden.
 mark_as_advanced(CLANG_ENABLE_HLSL)
diff --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index 438a5c4c2e711..3f8d30b7da6e3 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -58,6 +58,11 @@ define_property(GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS 
${doc_opts})
 # Adds unittests to the combined AllClangUnitTests binary. The unittest binary
 # is defined after adding all unittest subdirectories.
 function(add_clang_unittest test_name)
+  if (NOT CLANG_UNITTEST_SINGLE_BINARY)
+    add_distinct_clang_unittest(${ARGV})
+    return()
+  endif()
+
   cmake_parse_arguments(ARG
     ""
     ""
@@ -110,22 +115,24 @@ if (CLANG_ENABLE_CIR)
   add_subdirectory(CIR)
 endif()
 
-# If we're doing a single merged clang unit test binary, add that target after
-# all the previous subdirectories have been processed.
-get_property(SRCS GLOBAL PROPERTY CLANG_UNITTEST_SRCS)
-get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_UNITTEST_CLANG_LIBS)
-get_property(LINK_LIBS GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS)
-get_property(LLVM_COMPONENTS GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS)
-add_distinct_clang_unittest(AllClangUnitTests
-  ${SRCS}
-  AllClangUnitTests.cpp
-  CLANG_LIBS
-  ${CLANG_LIBS}
-  LINK_LIBS
-  ${LINK_LIBS}
-  LLVM_COMPONENTS
-  ${LLVM_COMPONENTS}
-)
+if (CLANG_UNITTEST_SINGLE_BINARY)
+  # If we're doing a single merged clang unit test binary, add that target 
after
+  # all the previous subdirectories have been processed.
+  get_property(SRCS GLOBAL PROPERTY CLANG_UNITTEST_SRCS)
+  get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_UNITTEST_CLANG_LIBS)
+  get_property(LINK_LIBS GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS)
+  get_property(LLVM_COMPONENTS GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS)
+  add_distinct_clang_unittest(AllClangUnitTests
+    ${SRCS}
+    AllClangUnitTests.cpp
+    CLANG_LIBS
+    ${CLANG_LIBS}
+    LINK_LIBS
+    ${LINK_LIBS}
+    LLVM_COMPONENTS
+    ${LLVM_COMPONENTS}
+  )
+endif()
 
 # The Tooling library has some internal headers. Make those work. If we like
 # the merged clang unit test binary, we can update the include paths and make
diff --git a/clang/unittests/Frontend/CMakeLists.txt 
b/clang/unittests/Frontend/CMakeLists.txt
index 0d9fc714212d5..a9c712c828b0a 100644
--- a/clang/unittests/Frontend/CMakeLists.txt
+++ b/clang/unittests/Frontend/CMakeLists.txt
@@ -24,6 +24,7 @@ add_clang_unittest(FrontendTests
   clangSerialization
   clangTooling
   LLVM_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
   Support
   TargetParser
   )

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to