[libc-commits] [libc] [libc] Remove duplicate clang-tidy pass in object rules (PR #231078)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Sun Oct 11 23:29:20 PDT 2026


https://github.com/kaladron created https://github.com/llvm/llvm-project/pull/231078

Entrypoint object linting ran clang-tidy a second time with --system-headers to run llvmlibc-restrict-system-libc-headers.

This check is already covered by libc/src/.clang-tidy in the primary invocation. The second pass doubled lint execution time and passed a host resource directory that could conflict with the linter.

Remove the second invocation and rely on the primary pass.

Assisted-by: Automated tooling, human reviewed.

>From 37d4b8fb6b6a5b0608c131db6f696e46f7708d05 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Mon, 12 Oct 2026 07:19:20 +0100
Subject: [PATCH] [libc] Remove duplicate clang-tidy pass in object rules

Entrypoint object linting ran clang-tidy a second time with
--system-headers to run llvmlibc-restrict-system-libc-headers.

This check is already covered by libc/src/.clang-tidy in the primary
invocation. The second pass doubled lint execution time and passed
a host resource directory that could conflict with the linter.

Remove the second invocation and rely on the primary pass.

Assisted-by: Automated tooling, human reviewed.
---
 libc/cmake/modules/LLVMLibCObjectRules.cmake | 25 --------------------
 1 file changed, 25 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index d05e3f183bcdb..c4108e5850ef9 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -368,28 +368,6 @@ function(create_entrypoint_object fq_target_name)
         "ON but LLVM_LIBC_CLANG_TIDY is not set.")
     endif()
 
-    # We only want a second invocation of clang-tidy to run
-    # restrict-system-libc-headers if the compiler-resource-dir was set in
-    # order to prevent false-positives due to a mismatch between the host
-    # compiler and the compiled clang-tidy.
-    if(COMPILER_RESOURCE_DIR)
-      # We run restrict-system-libc-headers with --system-headers to prevent
-      # transitive inclusion through compler provided headers.
-      set(restrict_system_headers_check_invocation
-        COMMAND ${LLVM_LIBC_CLANG_TIDY} --system-headers
-        --checks="-*,llvmlibc-restrict-system-libc-headers"
-        # We explicitly set the resource dir here to match the
-        # resource dir of the host compiler.
-        "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
-        --quiet
-        -p ${PROJECT_BINARY_DIR}
-        ${ADD_ENTRYPOINT_OBJ_SRCS}
-      )
-    else()
-      set(restrict_system_headers_check_invocation
-        COMMAND ${CMAKE_COMMAND} -E echo "Header file check skipped")
-    endif()
-
     add_custom_target(
       ${fq_target_name}.__lint__
       # --quiet is used to surpress warning statistics from clang-tidy like:
@@ -404,9 +382,6 @@ function(create_entrypoint_object fq_target_name)
         # Path to directory containing compile_commands.json
         -p ${PROJECT_BINARY_DIR}
         ${ADD_ENTRYPOINT_OBJ_SRCS}
-        # See above: this might be a second invocation of clang-tidy depending on
-        # the conditions above.
-        ${restrict_system_headers_check_invocation}
       # We have two options for running commands, add_custom_command and
       # add_custom_target. We don't want to run the linter unless source files
       # have changed. add_custom_target explicitly runs everytime therefore we



More information about the libc-commits mailing list