[libc-commits] [libc] [libc][docs] Avoid docgen target collisions and restore pthread docs (PR #188221)

Petter Berntsson via libc-commits libc-commits at lists.llvm.org
Tue Mar 24 04:10:57 PDT 2026


https://github.com/petbernt created https://github.com/llvm/llvm-project/pull/188221

Fixes llvm/llvm-project#123821.

Re-enabling pthread docs created a global CMake utility target named `pthread`, which collides in combined runtime builds where `pthread` is expected to be a library name. Namespace the internal libc docgen helper targets under `libc-docgen-*` and restore the generated pthread docs page. `docs-libc-html` is unchanged.

>From f9176ae2693fbd70f91a20e42b8eadeabef42de3 Mon Sep 17 00:00:00 2001
From: Petter Berntsson <petter.berntsson at arm.com>
Date: Tue, 24 Mar 2026 10:12:18 +0000
Subject: [PATCH] [libc][docs] Avoid docgen target collisions and restore
 pthread docs

Namespace generated libc docgen helper targets under libc-docgen-* so they do not claim global names like pthread in combined runtime builds. With that collision removed, re-enable the generated pthread docs page.
---
 libc/docs/CMakeLists.txt    | 11 ++++++-----
 libc/docs/headers/index.rst |  2 --
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/libc/docs/CMakeLists.txt b/libc/docs/CMakeLists.txt
index 68fe9fc545781..259902f62791f 100644
--- a/libc/docs/CMakeLists.txt
+++ b/libc/docs/CMakeLists.txt
@@ -54,8 +54,7 @@ if (SPHINX_FOUND)
       locale
       net/if
       netinet/in
-      # TODO: https://github.com/llvm/llvm-project/issues/123821
-      # pthread
+      pthread
       setjmp
       signal
       stdbit
@@ -81,15 +80,17 @@ if (SPHINX_FOUND)
     foreach(stem IN LISTS docgen_list)
       # It is an error in cmake to have a target name that contains a "/", but
       # docgen relies on the "/" to find headers nested under directories.
-      # Replace with underscore.
+      # Replace with underscore and namespace the target to avoid collisions
+      # with other runtime targets in combined builds.
       string(REPLACE "/" "_" stem_rst ${stem})
+      set(docgen_target_name libc-docgen-${stem_rst})
 
       # docgen invocation.
-      add_custom_target(${stem_rst}
+      add_custom_target(${docgen_target_name}
         COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../utils/docgen/docgen.py ${stem}.h >
                 ${CMAKE_CURRENT_BINARY_DIR}/headers/${stem}.rst)
       # depend on the docgen invocation.
-      add_dependencies(docs-libc-html ${stem_rst})
+      add_dependencies(docs-libc-html ${docgen_target_name})
     endforeach()
   endif()
 endif()
diff --git a/libc/docs/headers/index.rst b/libc/docs/headers/index.rst
index 573c5d185f38a..f4ad77b490761 100644
--- a/libc/docs/headers/index.rst
+++ b/libc/docs/headers/index.rst
@@ -44,6 +44,4 @@ Implementation Status
    unistd
    wchar
    wctype
-..
-   TODO: https://github.com/llvm/llvm-project/issues/123821
    pthread



More information about the libc-commits mailing list