[libc-commits] [libc] [libc][test] Gate HashTable tests without linking hsearch (PR #247015)

Roland McGrath via libc-commits libc-commits at lists.llvm.org
Sun Nov 29 13:30:42 PST 2026


https://github.com/frobtech created https://github.com/llvm/llvm-project/pull/247015

Commit 6fd1c1b8ef40 (#74371) added `libc.src.search.hsearch` to the `DEPENDS` list of `bitmask_test`, `table_test`, and `group_test` solely so those tests are skipped on targets where `hsearch` is not enabled. Listing the entrypoint in `DEPENDS` also links `hsearch.cpp` and its global table state into unit tests that never call `hsearch`.

Check `TARGET_LLVMLIBC_ENTRYPOINTS` at the top of `libc/test/src/__support/HashTable/CMakeLists.txt` instead, drop `libc.src.search.hsearch` from all three `DEPENDS` lists, and list the direct `libc.hdr.types.ENTRY` dependency on `table_test`.

Assisted-by: Gemini

>From 82a649fe888d3981dc4ab4336bdc173a6bb32a60 Mon Sep 17 00:00:00 2001
From: Roland McGrath <mcgrathr at google.com>
Date: Sun, 29 Nov 2026 13:18:29 -0800
Subject: [PATCH] [libc][test] Gate HashTable tests without linking hsearch

Commit 6fd1c1b8ef40 (#74371) added libc.src.search.hsearch to the
DEPENDS list of bitmask_test, table_test, and group_test solely so
those tests are skipped on targets where hsearch is not enabled.
Listing the entrypoint in DEPENDS also links hsearch.cpp and its global
table state into unit tests that never call hsearch.

Check TARGET_LLVMLIBC_ENTRYPOINTS at the top of
libc/test/src/__support/HashTable/CMakeLists.txt instead, drop
libc.src.search.hsearch from all three DEPENDS lists, and list the
direct libc.hdr.types.ENTRY dependency on table_test.

Assisted-by: Gemini
---
 libc/test/src/__support/HashTable/CMakeLists.txt | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libc/test/src/__support/HashTable/CMakeLists.txt b/libc/test/src/__support/HashTable/CMakeLists.txt
index 800c18f7366189..660b476f1bcdfc 100644
--- a/libc/test/src/__support/HashTable/CMakeLists.txt
+++ b/libc/test/src/__support/HashTable/CMakeLists.txt
@@ -1,3 +1,7 @@
+if(NOT "libc.src.search.hsearch" IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS)
+  return()
+endif()
+
 add_libc_test(
   bitmask_test
   SUITE
@@ -6,7 +10,6 @@ add_libc_test(
     bitmask_test.cpp
   DEPENDS
     libc.src.__support.HashTable.bitmask
-    libc.src.search.hsearch
 )
 
 add_libc_test(
@@ -16,10 +19,10 @@ add_libc_test(
   SRCS
     table_test.cpp
   DEPENDS
+    libc.hdr.types.ENTRY
     libc.src.__support.HashTable.randomness
     libc.src.__support.HashTable.table
     libc.src.__support.common
-    libc.src.search.hsearch
 )
 
 add_libc_test(
@@ -32,5 +35,4 @@ add_libc_test(
     libc.hdr.stdint_proxy
     libc.src.__support.HashTable.bitmask
     libc.src.stdlib.rand
-    libc.src.search.hsearch
 )



More information about the libc-commits mailing list