[clang] [llvm] [clang][LIT] Add LIT "features" for build configs with ICU or iconv (PR #159245)

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 22:46:31 PDT 2025


https://github.com/hubert-reinterpretcast created https://github.com/llvm/llvm-project/pull/159245

... in preparation for `-finput-charset` and `-fexec-charset` tests that rely on the availability of one or the other; however, this does not address the problem of varying `iconv` support of (and names for) character encodings.

>From 35627b36982087c6b227ff8796a6e9950550214e Mon Sep 17 00:00:00 2001
From: Hubert Tong <hstong at ca.ibm.com>
Date: Wed, 17 Sep 2025 01:25:57 -0400
Subject: [PATCH] [clang][LIT] Add LIT "features" for build configs with ICU or
 iconv

... in preparation for `-finput-charset` and `-fexec-charset` tests that
rely on the availability of one or the other; however, this does not
address the problem of varying `iconv` support of (and names for)
character encodings.

Co-authored-by: Abhina Sreeskantharajan <Abhina.Sreeskantharajan at ibm.com>
---
 clang/test/CMakeLists.txt         | 2 ++
 clang/test/lit.site.cfg.py.in     | 2 ++
 llvm/cmake/config-ix.cmake        | 2 ++
 llvm/utils/lit/lit/llvm/config.py | 6 ++++++
 4 files changed, 12 insertions(+)

diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index e9f4f83f98923..cf746367202ad 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -16,6 +16,8 @@ llvm_canonicalize_cmake_booleans(
   LLVM_BUILD_EXAMPLES
   LLVM_BYE_LINK_INTO_TOOLS
   LLVM_ENABLE_PLUGINS
+  HAVE_ICU
+  HAVE_ICONV
   LLVM_ENABLE_ZLIB
   LLVM_ENABLE_ZSTD
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index f50953a93a412..c6d2164a5041c 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -18,6 +18,8 @@ config.clang_lib_dir = path(r"@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
+config.have_icu = @HAVE_ICU@
+config.have_iconv = @HAVE_ICONV@
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.have_zstd = @LLVM_ENABLE_ZSTD@
 config.clang_objc_rewriter = @CLANG_ENABLE_OBJC_REWRITER@
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index ed2bfa6df68f4..ebc2a7c6cf890 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -310,6 +310,7 @@ if (LLVM_ENABLE_ICU STREQUAL FORCE_ON AND LLVM_ENABLE_ICONV STREQUAL FORCE_ON)
 endif()
 
 # Check for ICU. Only allow an optional, dynamic link for ICU so we don't impact LLVM's licensing.
+set(HAVE_ICU 0)
 if(LLVM_ENABLE_ICU AND NOT(LLVM_ENABLE_ICONV STREQUAL FORCE_ON))
   set(LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
   set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_SHARED_LIBRARY_SUFFIX}")
@@ -326,6 +327,7 @@ if(LLVM_ENABLE_ICU AND NOT(LLVM_ENABLE_ICONV STREQUAL FORCE_ON))
 endif()
 
 # Check only for builtin iconv to avoid licensing issues.
+set(HAVE_ICONV 0)
 if(LLVM_ENABLE_ICONV AND NOT HAVE_ICU)
   if (LLVM_ENABLE_ICONV STREQUAL FORCE_ON)
     find_package(Iconv REQUIRED)
diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index 2f2df68ac0cff..b2f5e0f965940 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -145,6 +145,12 @@ def __init__(self, lit_config, config):
         have_zstd = getattr(config, "have_zstd", None)
         if have_zstd:
             features.add("zstd")
+        have_icu = getattr(config, "have_icu", None)
+        if have_icu:
+            features.add("icu")
+        have_iconv = getattr(config, "have_iconv", None)
+        if have_iconv:
+            features.add("iconv")
 
         if getattr(config, "reverse_iteration", None):
             features.add("reverse_iteration")



More information about the llvm-commits mailing list