[clang] [clang] Only build clang-tblgen if it is actually needed (PR #161952)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 7 09:20:14 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Ross Burton (rossburton)

<details>
<summary>Changes</summary>

It's possible to build clang with an existing clang-tblgen (common when cross-compiling, for instance) by setting CLANG_TABLEGEN_EXE.  If this is the case there's no need to build it, as it won't be used.

---
Full diff: https://github.com/llvm/llvm-project/pull/161952.diff


1 Files Affected:

- (modified) clang/CMakeLists.txt (+3-1) 


``````````diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index e4cb1a359620d..b650b3b986f4c 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -479,7 +479,9 @@ option(CLANG_ENABLE_HLSL "Include HLSL build products" Off)
 # While HLSL support is experimental this should stay hidden.
 mark_as_advanced(CLANG_ENABLE_HLSL)
 
-add_subdirectory(utils/TableGen)
+if (NOT DEFINED CLANG_TABLEGEN_EXE OR CLANG_INCLUDE_TESTS)
+  add_subdirectory(utils/TableGen)
+endif()
 
 # Export CLANG_TABLEGEN_EXE for use by flang docs.
 set(CLANG_TABLEGEN_EXE "${CLANG_TABLEGEN_EXE}" CACHE INTERNAL "")

``````````

</details>


https://github.com/llvm/llvm-project/pull/161952


More information about the cfe-commits mailing list