[clang] [clang] Only build clang-tblgen if it is actually needed (PR #161952)
Ross Burton via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 7 03:49:59 PDT 2025
https://github.com/rossburton updated https://github.com/llvm/llvm-project/pull/161952
>From 98669ac9410e5b8c46c104f2ed2a4f91c4268250 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton at arm.com>
Date: Fri, 3 Oct 2025 20:34:02 +0100
Subject: [PATCH] [clang] Only build clang-tblgen if it is actually needed
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 then building another copy of clang-tblgen that won't be
used is pointless.
However, currently the clang tests explicitly depend on clang-tblgen
being built, so also check if CLANG_INCLUDE_TESTS is enabled to ensure
that the targets exist.
---
clang/CMakeLists.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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 "")
More information about the cfe-commits
mailing list