Skip to content

[clang][python][test] Move python binding tests to lit framework #142948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 25, 2025

Conversation

rorth
Copy link
Collaborator

@rorth rorth commented Jun 5, 2025

As discussed in PR #142353, the current testsuite of the clang Python bindings has several issues:

  • If libclang.so cannot be loaded into python to run the testsuite, the whole ninja check-all aborts.
  • The result of running the testsuite isn't report like the lit-based tests, rendering them almost invisible.
  • The testsuite is disabled in a non-obvious way (RUN_PYTHON_TESTS) in tests/CMakeLists.txt, which again doesn't show up in the test results.

All these issues can be avoided by integrating the Python bindings tests with lit, which is what this patch does:

  • The actual test lives in clang/test/bindings/python/bindings.sh and is run by lit.
  • The current clang/bindings/python/tests directory (minus the now-superfluous CMakeLists.txt) is moved into the same directory.
  • The check if libclang is loadable (originally from PR [clang][python][test] Check if libclang.so is loadable #142353) is now handled via a new lit feature, libclang-loadable.
  • The various ways to disable the tests have been turned into XFAILs as appropriate. This isn't complete and not completely tested yet.
  • It keeps the check-clang-python target for use by the Clang Python CI.

Tested on sparc-sun-solaris2.11, sparcv9-sun-solaris2.11, i386-pc-solaris2.11, amd64-pc-solaris2.11, i686-pc-linux-gnu, and x86_64-pc-linux-gnu.

@rorth rorth requested a review from Endilll June 5, 2025 11:43
@rorth rorth requested a review from DeinAlptraum as a code owner June 5, 2025 11:43
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:as-a-library libclang and C++ API labels Jun 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 5, 2025

@llvm/pr-subscribers-github-workflow

@llvm/pr-subscribers-clang

Author: Rainer Orth (rorth)

Changes

As discussed in PR #142353, the current testsuite of the clang Python bindings has several issues:

  • It libclang.so cannot be loaded into python to run the testsuite, the whole ninja check-all aborts.
  • The result of running the testsuite isn't report like the lit-based tests, rendering them almost invisible.
  • The testsuite is disabled in a non-obvious way (RUN_PYTHON_TESTS) in tests/CMakeLists.txt, which again doesn't show up in the test results.

All these issues can be avoided by integrating the Python bindings tests with lit, which is what this patch does:

  • The actual test lives in clang/test/bindings/python/bindings.sh and is run by lit.
  • The current clang/bindings/python/tests directory (minus the now-subperfluous CMakeLists.txt) is moved into the same directory.
  • The check if libclang is loadable (originally from PR #142353) is now handled via a new lit feature, libclang-loadable.
  • The various ways to disable the tests have been turned into XFAILs as appropriate. This isn't complete and not completely tested yet.

Tested on sparc-sun-solaris2.11, sparcv9-sun-solaris2.11, i386-pc-solaris2.11, amd64-pc-solaris2.11, i686-pc-linux-gnu, and x86_64-pc-linux-gnu.


Full diff: https://github.com/llvm/llvm-project/pull/142948.diff

38 Files Affected:

  • (modified) clang/CMakeLists.txt (-1)
  • (removed) clang/bindings/python/tests/CMakeLists.txt (-66)
  • (added) clang/test/bindings/python/bindings.sh (+48)
  • (added) clang/test/bindings/python/lit.local.cfg (+22)
  • (renamed) clang/test/bindings/python/tests/init.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/INPUTS/a.inc ()
  • (renamed) clang/test/bindings/python/tests/cindex/INPUTS/b.inc ()
  • (renamed) clang/test/bindings/python/tests/cindex/INPUTS/compile_commands.json ()
  • (renamed) clang/test/bindings/python/tests/cindex/INPUTS/header1.h ()
  • (renamed) clang/test/bindings/python/tests/cindex/INPUTS/header2.h ()
  • (renamed) clang/test/bindings/python/tests/cindex/INPUTS/header3.h ()
  • (renamed) clang/test/bindings/python/tests/cindex/INPUTS/hello.cpp ()
  • (renamed) clang/test/bindings/python/tests/cindex/INPUTS/include.cpp ()
  • (renamed) clang/test/bindings/python/tests/cindex/INPUTS/parse_arguments.c ()
  • (renamed) clang/test/bindings/python/tests/cindex/INPUTS/testfile.c ()
  • (renamed) clang/test/bindings/python/tests/cindex/init.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_access_specifiers.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_cdb.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_code_completion.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_comment.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_cursor.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_cursor_kind.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_diagnostics.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_enums.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_exception_specification_kind.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_file.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_index.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_lib.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_linkage.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_location.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_rewrite.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_source_range.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_tls_kind.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_token_kind.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_tokens.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_translation_unit.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/test_type.py ()
  • (renamed) clang/test/bindings/python/tests/cindex/util.py ()
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index ab2ac9bc6b9ad..5111953397d04 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -533,7 +533,6 @@ if( CLANG_INCLUDE_TESTS )
     clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg
   )
   add_subdirectory(test)
-  add_subdirectory(bindings/python/tests)
 
   if(CLANG_BUILT_STANDALONE)
     umbrella_lit_testsuite_end(check-all)
diff --git a/clang/bindings/python/tests/CMakeLists.txt b/clang/bindings/python/tests/CMakeLists.txt
deleted file mode 100644
index a0ddabc21bb41..0000000000000
--- a/clang/bindings/python/tests/CMakeLists.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-# Test target to run Python test suite from main build.
-
-# Avoid configurations including '-include' from interfering with
-# our tests by setting CLANG_NO_DEFAULT_CONFIG.
-add_custom_target(check-clang-python
-    COMMAND ${CMAKE_COMMAND} -E env
-            CLANG_NO_DEFAULT_CONFIG=1
-            CLANG_LIBRARY_PATH=$<TARGET_FILE_DIR:libclang>
-            "${Python3_EXECUTABLE}" -m unittest discover
-    DEPENDS libclang
-    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
-
-set(RUN_PYTHON_TESTS TRUE)
-set_target_properties(check-clang-python PROPERTIES FOLDER "Clang/Tests")
-
-# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
-if(NOT LLVM_ENABLE_PIC)
-  set(RUN_PYTHON_TESTS FALSE)
-endif()
-
-# Do not try to run if libclang was built with sanitizers because
-# the sanitizer library will likely be loaded too late to perform
-# interception and will then fail.
-# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
-# portable so its easier just to not run the tests when building
-# with ASan.
-if(NOT LLVM_USE_SANITIZER STREQUAL "")
-  set(RUN_PYTHON_TESTS FALSE)
-endif()
-
-# Tests fail on Windows, and need someone knowledgeable to fix.
-# It's not clear whether it's a test or a valid binding problem.
-if(WIN32)
-  set(RUN_PYTHON_TESTS FALSE)
-endif()
-
-# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
-if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
-  set(RUN_PYTHON_TESTS FALSE)
-endif()
-
-# AArch64, Hexagon, and Sparc have known test failures that need to be
-# addressed.
-# SystemZ has broken Python/FFI interface:
-# https://reviews.llvm.org/D52840#1265716
-if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
-  set(RUN_PYTHON_TESTS FALSE)
-endif()
-
-# Tests will fail if cross-compiling for a different target, as tests will try
-# to use the host Python3_EXECUTABLE and make FFI calls to functions in target
-# libraries.
-if(CMAKE_CROSSCOMPILING)
-  # FIXME: Consider a solution that allows better control over these tests in
-  # a crosscompiling scenario. e.g. registering them with lit to allow them to
-  # be explicitly skipped via appropriate LIT_ARGS, or adding a mechanism to
-  # allow specifying a python interpreter compiled for the target that could
-  # be executed using qemu-user.
-  message(WARNING "check-clang-python not added to check-all as these tests fail in a cross-build setup")
-  set(RUN_PYTHON_TESTS FALSE)
-endif()
-
-if(RUN_PYTHON_TESTS)
-    set_property(GLOBAL APPEND PROPERTY
-                 LLVM_ALL_ADDITIONAL_TEST_TARGETS check-clang-python)
-endif()
diff --git a/clang/test/bindings/python/bindings.sh b/clang/test/bindings/python/bindings.sh
new file mode 100755
index 0000000000000..ec4ca55e41822
--- /dev/null
+++ b/clang/test/bindings/python/bindings.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# UNSUPPORTED: !libclang-loadable
+
+# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
+#
+# Covered by libclang-loadable, may need to augment test for lack of
+# libclang.so.
+
+# Do not try to run if libclang was built with sanitizers because
+# the sanitizer library will likely be loaded too late to perform
+# interception and will then fail.
+# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
+# portable so its easier just to not run the tests when building
+# with ASan.
+#
+# FIXME: Handle !LLVM_USE_SANITIZER = "".
+# lit.site.cfg.py has config.llvm_use_sanitizer = ""
+
+# Tests fail on Windows, and need someone knowledgeable to fix.
+# It's not clear whether it's a test or a valid binding problem.
+# XFAIL: target={{.*windows.*}}
+
+# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
+# XFAIL: target={{.*-aix.*}}
+
+# AArch64, Hexagon, and Sparc have known test failures that need to be
+# addressed.
+# SystemZ has broken Python/FFI interface:
+# https://reviews.llvm.org/D52840#1265716
+# XFAIL: target={{(aarch64|hexagon|sparc*|s390x)-.*}}
+
+# Tests will fail if cross-compiling for a different target, as tests will try
+# to use the host Python3_EXECUTABLE and make FFI calls to functions in target
+# libraries.
+#
+# FIXME: Consider a solution that allows better control over these tests in
+# a crosscompiling scenario. e.g. registering them with lit to allow them to
+# be explicitly skipped via appropriate LIT_ARGS, or adding a mechanism to
+# allow specifying a python interpreter compiled for the target that could
+# be executed using qemu-user.
+#
+# FIXME: Handle CMAKE_CROSSCOMPILING.
+# Again, might already be handled by libclang-loadable.
+
+# RUN: env PYTHONPATH=%S/../../../bindings/python \
+# RUN:   CLANG_LIBRARY_PATH=`llvm-config --libdir` \
+# RUN:   %python -m unittest discover -s %S/tests
diff --git a/clang/test/bindings/python/lit.local.cfg b/clang/test/bindings/python/lit.local.cfg
new file mode 100644
index 0000000000000..d3608565f5aef
--- /dev/null
+++ b/clang/test/bindings/python/lit.local.cfg
@@ -0,0 +1,22 @@
+def is_libclang_loadable():
+    try:
+        sys.path.append(os.path.join(config.clang_src_dir, "bindings/python"))
+        from clang.cindex import Config
+        conf = Config()
+        Config.set_library_path(config.clang_lib_dir)
+        conf.lib
+        return True
+    except Exception as e:
+        # Benign error modes.
+        if "wrong ELF class: ELFCLASS32" in str(e):
+            return False
+        elif "No such file or directory" in str(e):
+            return False
+        # Unknown error modes.
+        else:
+            return True
+
+if is_libclang_loadable():
+    config.available_features.add("libclang-loadable")
+
+config.suffixes = ['.sh']
diff --git a/clang/bindings/python/tests/__init__.py b/clang/test/bindings/python/tests/__init__.py
similarity index 100%
rename from clang/bindings/python/tests/__init__.py
rename to clang/test/bindings/python/tests/__init__.py
diff --git a/clang/bindings/python/tests/cindex/INPUTS/a.inc b/clang/test/bindings/python/tests/cindex/INPUTS/a.inc
similarity index 100%
rename from clang/bindings/python/tests/cindex/INPUTS/a.inc
rename to clang/test/bindings/python/tests/cindex/INPUTS/a.inc
diff --git a/clang/bindings/python/tests/cindex/INPUTS/b.inc b/clang/test/bindings/python/tests/cindex/INPUTS/b.inc
similarity index 100%
rename from clang/bindings/python/tests/cindex/INPUTS/b.inc
rename to clang/test/bindings/python/tests/cindex/INPUTS/b.inc
diff --git a/clang/bindings/python/tests/cindex/INPUTS/compile_commands.json b/clang/test/bindings/python/tests/cindex/INPUTS/compile_commands.json
similarity index 100%
rename from clang/bindings/python/tests/cindex/INPUTS/compile_commands.json
rename to clang/test/bindings/python/tests/cindex/INPUTS/compile_commands.json
diff --git a/clang/bindings/python/tests/cindex/INPUTS/header1.h b/clang/test/bindings/python/tests/cindex/INPUTS/header1.h
similarity index 100%
rename from clang/bindings/python/tests/cindex/INPUTS/header1.h
rename to clang/test/bindings/python/tests/cindex/INPUTS/header1.h
diff --git a/clang/bindings/python/tests/cindex/INPUTS/header2.h b/clang/test/bindings/python/tests/cindex/INPUTS/header2.h
similarity index 100%
rename from clang/bindings/python/tests/cindex/INPUTS/header2.h
rename to clang/test/bindings/python/tests/cindex/INPUTS/header2.h
diff --git a/clang/bindings/python/tests/cindex/INPUTS/header3.h b/clang/test/bindings/python/tests/cindex/INPUTS/header3.h
similarity index 100%
rename from clang/bindings/python/tests/cindex/INPUTS/header3.h
rename to clang/test/bindings/python/tests/cindex/INPUTS/header3.h
diff --git a/clang/bindings/python/tests/cindex/INPUTS/hello.cpp b/clang/test/bindings/python/tests/cindex/INPUTS/hello.cpp
similarity index 100%
rename from clang/bindings/python/tests/cindex/INPUTS/hello.cpp
rename to clang/test/bindings/python/tests/cindex/INPUTS/hello.cpp
diff --git a/clang/bindings/python/tests/cindex/INPUTS/include.cpp b/clang/test/bindings/python/tests/cindex/INPUTS/include.cpp
similarity index 100%
rename from clang/bindings/python/tests/cindex/INPUTS/include.cpp
rename to clang/test/bindings/python/tests/cindex/INPUTS/include.cpp
diff --git a/clang/bindings/python/tests/cindex/INPUTS/parse_arguments.c b/clang/test/bindings/python/tests/cindex/INPUTS/parse_arguments.c
similarity index 100%
rename from clang/bindings/python/tests/cindex/INPUTS/parse_arguments.c
rename to clang/test/bindings/python/tests/cindex/INPUTS/parse_arguments.c
diff --git a/clang/bindings/python/tests/cindex/INPUTS/testfile.c b/clang/test/bindings/python/tests/cindex/INPUTS/testfile.c
similarity index 100%
rename from clang/bindings/python/tests/cindex/INPUTS/testfile.c
rename to clang/test/bindings/python/tests/cindex/INPUTS/testfile.c
diff --git a/clang/bindings/python/tests/cindex/__init__.py b/clang/test/bindings/python/tests/cindex/__init__.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/__init__.py
rename to clang/test/bindings/python/tests/cindex/__init__.py
diff --git a/clang/bindings/python/tests/cindex/test_access_specifiers.py b/clang/test/bindings/python/tests/cindex/test_access_specifiers.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_access_specifiers.py
rename to clang/test/bindings/python/tests/cindex/test_access_specifiers.py
diff --git a/clang/bindings/python/tests/cindex/test_cdb.py b/clang/test/bindings/python/tests/cindex/test_cdb.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_cdb.py
rename to clang/test/bindings/python/tests/cindex/test_cdb.py
diff --git a/clang/bindings/python/tests/cindex/test_code_completion.py b/clang/test/bindings/python/tests/cindex/test_code_completion.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_code_completion.py
rename to clang/test/bindings/python/tests/cindex/test_code_completion.py
diff --git a/clang/bindings/python/tests/cindex/test_comment.py b/clang/test/bindings/python/tests/cindex/test_comment.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_comment.py
rename to clang/test/bindings/python/tests/cindex/test_comment.py
diff --git a/clang/bindings/python/tests/cindex/test_cursor.py b/clang/test/bindings/python/tests/cindex/test_cursor.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_cursor.py
rename to clang/test/bindings/python/tests/cindex/test_cursor.py
diff --git a/clang/bindings/python/tests/cindex/test_cursor_kind.py b/clang/test/bindings/python/tests/cindex/test_cursor_kind.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_cursor_kind.py
rename to clang/test/bindings/python/tests/cindex/test_cursor_kind.py
diff --git a/clang/bindings/python/tests/cindex/test_diagnostics.py b/clang/test/bindings/python/tests/cindex/test_diagnostics.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_diagnostics.py
rename to clang/test/bindings/python/tests/cindex/test_diagnostics.py
diff --git a/clang/bindings/python/tests/cindex/test_enums.py b/clang/test/bindings/python/tests/cindex/test_enums.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_enums.py
rename to clang/test/bindings/python/tests/cindex/test_enums.py
diff --git a/clang/bindings/python/tests/cindex/test_exception_specification_kind.py b/clang/test/bindings/python/tests/cindex/test_exception_specification_kind.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_exception_specification_kind.py
rename to clang/test/bindings/python/tests/cindex/test_exception_specification_kind.py
diff --git a/clang/bindings/python/tests/cindex/test_file.py b/clang/test/bindings/python/tests/cindex/test_file.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_file.py
rename to clang/test/bindings/python/tests/cindex/test_file.py
diff --git a/clang/bindings/python/tests/cindex/test_index.py b/clang/test/bindings/python/tests/cindex/test_index.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_index.py
rename to clang/test/bindings/python/tests/cindex/test_index.py
diff --git a/clang/bindings/python/tests/cindex/test_lib.py b/clang/test/bindings/python/tests/cindex/test_lib.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_lib.py
rename to clang/test/bindings/python/tests/cindex/test_lib.py
diff --git a/clang/bindings/python/tests/cindex/test_linkage.py b/clang/test/bindings/python/tests/cindex/test_linkage.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_linkage.py
rename to clang/test/bindings/python/tests/cindex/test_linkage.py
diff --git a/clang/bindings/python/tests/cindex/test_location.py b/clang/test/bindings/python/tests/cindex/test_location.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_location.py
rename to clang/test/bindings/python/tests/cindex/test_location.py
diff --git a/clang/bindings/python/tests/cindex/test_rewrite.py b/clang/test/bindings/python/tests/cindex/test_rewrite.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_rewrite.py
rename to clang/test/bindings/python/tests/cindex/test_rewrite.py
diff --git a/clang/bindings/python/tests/cindex/test_source_range.py b/clang/test/bindings/python/tests/cindex/test_source_range.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_source_range.py
rename to clang/test/bindings/python/tests/cindex/test_source_range.py
diff --git a/clang/bindings/python/tests/cindex/test_tls_kind.py b/clang/test/bindings/python/tests/cindex/test_tls_kind.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_tls_kind.py
rename to clang/test/bindings/python/tests/cindex/test_tls_kind.py
diff --git a/clang/bindings/python/tests/cindex/test_token_kind.py b/clang/test/bindings/python/tests/cindex/test_token_kind.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_token_kind.py
rename to clang/test/bindings/python/tests/cindex/test_token_kind.py
diff --git a/clang/bindings/python/tests/cindex/test_tokens.py b/clang/test/bindings/python/tests/cindex/test_tokens.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_tokens.py
rename to clang/test/bindings/python/tests/cindex/test_tokens.py
diff --git a/clang/bindings/python/tests/cindex/test_translation_unit.py b/clang/test/bindings/python/tests/cindex/test_translation_unit.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_translation_unit.py
rename to clang/test/bindings/python/tests/cindex/test_translation_unit.py
diff --git a/clang/bindings/python/tests/cindex/test_type.py b/clang/test/bindings/python/tests/cindex/test_type.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/test_type.py
rename to clang/test/bindings/python/tests/cindex/test_type.py
diff --git a/clang/bindings/python/tests/cindex/util.py b/clang/test/bindings/python/tests/cindex/util.py
similarity index 100%
rename from clang/bindings/python/tests/cindex/util.py
rename to clang/test/bindings/python/tests/cindex/util.py

@AaronBallman
Copy link
Collaborator

CC @llvm/infrastructure-area-team -- I'm not certain who is the best person to review lit work; that's sort of the confluence between infraustructure and the rest of the project. Do you have any good suggestions? (We don't have a maintainer listed for it that I could find.)

Copy link
Contributor

@DeinAlptraum DeinAlptraum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR, imo this is a much better approach than the previous one.

As I mentioned before, I'm not familiar with the testing infrastructure, but insofar as it works, this looks good to me.

Do note that the libclang CI should also be adapted: .github/workflows/libclang-python-tests.yml
The target it uses doesn't exist anymore, and the paths that trigger the workflow should also be changed to remove the old path and include clang/tests/bindings/python. You can now also remove the trigger on clang/CMakeLists.txt, which should make this run far less often on unrelated PRs.

Comment on lines 10 to 34
# Benign error modes.
if "wrong ELF class: ELFCLASS32" in str(e):
return False
elif "No such file or directory" in str(e):
return False
# Unknown error modes.
else:
return True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems backwards - (either the implementation or the comment) if the error modes are benign, wouldn't that mean it's OK/libclang /is/ loadable?

(& also in general, I'd have thought we'd look for specific error modes we can recover from, and anything else means "no recovery" rather than assuming anything other than these bad ones are good?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent (and it worked for me) is as follows:

  • If libclang.so cannot be loaded, this can be for two reasons so far:
    • In a 32-bit build on a 64-bit system, the resulting 32-bit libclang.so cannot be loaded into the system's 64-bit python. This is as expected, nothing to be done about that, thus the lib is truely considered unloadable.
    • If libclang.so is missing completely, this must be because building it has been disabled somehow (probably with -DLLVM_ENABLE_PIC=OFF. Again, this is intentional and nothing to be done.
  • However, in other cases there may well be a bug lurking here. Consider (just for the sake of argument) a libclang.so matching python's ELF class, but built with missing dependencies so it's not self-contained and cannot be loaded. This is simply a bug that could/should be fixed. Therefore, I return True for unknown/unhandled errors, which lets the test to FAIL, forcing investigation. The failure may be benign yet not currently handled, or there may be a real bug that needs fixing.

If I always return False on a failure to load libclang.so, such bugs would go unnoticed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. Some more comments might be helpful - like "if the failure is unexpected, return true, allowing the test to run and fail so developers can see the failure" or something like that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the update addresses your concern. I also decided to log unexpected errors from lit.local.cfg to avoid every developer encountering this having to add their own debug code.

@DeinAlptraum
Copy link
Contributor

@rorth have you tested that your is_libclang_loadable works as intended w.r.t the "Benign error modes"?
Do correct me if I made a mistake here, but I just tried testing this by manually adding raise Exception("wrong ELF class: ELFCLASS32") at the start of get_cindex_library and then running the tests via build/bin/llvm-lit clang/test/bindings/python, and this just gives me a regular FAIL. Adding some debugging statements into is_libclang_loadable shows that the except block is never entered for some reason...

@rorth
Copy link
Collaborator Author

rorth commented Jun 6, 2025

Thank you for the PR, imo this is a much better approach than the previous one.

Thanks. The previous approach was just a minimal fix (hack?) to avoid breaking the build in a specific situation. This one (if completed) should handle all known issues with Python bindings testing.

As I mentioned before, I'm not familiar with the testing infrastructure, but insofar as it works, this looks good to me.

It will certainly need more testing in situations currently covered by RUN_PYTHON_TESTS that I known nothing about and probably cannot test myself.

Do note that the libclang CI should also be adapted: .github/workflows/libclang-python-tests.yml The target it uses doesn't exist anymore, and the paths that trigger the workflow should also be changed to remove the old path and include clang/tests/bindings/python. You can now also remove the trigger on clang/CMakeLists.txt, which should make this run far less often on unrelated PRs.

Ah, I see. I've made the obvious adjustments locally, but am at a bit of a loss how to handle build_target now. Doing this manually would be an invocation of bin/llvm-lit clang/test --filter=bindings/python or some such. Maybe a new implementation of the check-clang-python target needs to be introduced? Don't know if/how I can test this myself.

@rorth
Copy link
Collaborator Author

rorth commented Jun 6, 2025

@rorth have you tested that your is_libclang_loadable works as intended w.r.t the "Benign error modes"? Do correct me if I made a mistake here, but I just tried testing this by manually adding raise Exception("wrong ELF class: ELFCLASS32") at the start of get_cindex_library and then running the tests via build/bin/llvm-lit clang/test/bindings/python, and this just gives me a regular FAIL. Adding some debugging statements into is_libclang_loadable shows that the except block is never entered for some reason...

As mentioned in the description, I've tested the patch in a variety of configurations:

  • Solaris/amd64 (where libclang.so matches python, causing the test to PASS)
  • Solaris/i386 (where the 32-bit libclang.so cannot be loaded into the system python, which causes the test to become UNSUPPORTED.
  • Similarly Solaris/sparcv9, Solaris/sparc, Linux/x86_64, Linux/i686 (and also, not mentioned above) Linux/sparc64 and Linux/sparc.

Besides, I've manually moved libclang.so aside to test the libclang missing case.

I've got no explanation why your explicit raise didn't come through (but then I known very little Python).

@DeinAlptraum
Copy link
Contributor

I've got no explanation why your explicit raise didn't come through (but then I known very little Python).

Strange, I'll see if I can find out why, but as long as it works also for the expected failure case for you, that's good enough for me.

am at a bit of a loss how to handle build_target now [...] Don't know if/how I can test this myself.

All the check-clang-python did is depend on the libclang target and then call unittest, so I think it should be enough to change the build_target to libclang, and then add another step to the workflow that calls lit as you described.
Feel free to abuse the CI to test this until it works.

@rorth
Copy link
Collaborator Author

rorth commented Jun 11, 2025

am at a bit of a loss how to handle build_target now [...] Don't know if/how I can test this myself.

All the check-clang-python did is depend on the libclang target and then call unittest, so I think it should be enough to change the build_target to libclang, and then add another step to the workflow that calls lit as you described. Feel free to abuse the CI to test this until it works.

I've made some adjustments. The weird thing is that build_target isn't even documented in Workflow syntax for GitHub Actions. I've added an llvm-lit invocation that should run the test, but don't know anything about the layout of the build tree. Attempts to test this may have to wait until I return from vacation in a week and a half.

@rorth
Copy link
Collaborator Author

rorth commented Jun 11, 2025

Two issues are worth mentioning about the updated PR:

  • Although I'd originally disabled the Clang Python tests on SPARC in [python, tests] Disable Clang Python tests on SPARC, they now PASS on Solaris/sparcv9, while on Linux/sparc64 python SEGVs when loading libclang.so. In a Debug build, however, I get a SIGBUS which seems to point to an FFI issue again, so I'm restricting the XFAIL to Linux/sparc64.
  • I'm now logging unhandled failures from lit.local.cfg so there's a clear indication what's wrong and where to look.

Copy link
Contributor

@DeinAlptraum DeinAlptraum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, LGTM!

You can fix the code formatting if you want to, but I can also do this separately... since it's completely unrelated to what you did.

@rorth
Copy link
Collaborator Author

rorth commented Jun 25, 2025

You can fix the code formatting if you want to, but I can also do this separately... since it's completely unrelated to what you did.

I'd rather you do it separately: it feels strange to change code when the source is merely moved around. Thanks.

@rorth rorth merged commit 7dfcced into llvm:main Jun 25, 2025
8 of 9 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 25, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-win running on sie-win-worker while building clang at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/46/builds/19019

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Clang :: bindings/python/bindings.sh' FAILED ********************
Exit Code: 127

Command Output (stdout):
--
# RUN: at line 33
env PYTHONPATH=Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\bindings\python/../../../bindings/python    CLANG_LIBRARY_PATH=`llvm-config --libdir`    "C:\Program Files\Python310\python.exe" -m unittest discover -s Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\bindings\python/tests
# executed command: env 'PYTHONPATH=Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\bindings\python/../../../bindings/python' 'CLANG_LIBRARY_PATH=`llvm-config' '--libdir`' 'C:\Program Files\Python310\python.exe' -m unittest discover -s 'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\bindings\python/tests'
# .---command stderr------------
# | '--libdir`': command not found
# `-----------------------------
# error: command failed with exit status: 127

--

********************


@DeinAlptraum
Copy link
Contributor

I reverted this in #145774 since it causes build-failures. It seems that the substitution CLANG_LIBRARY_PATH=`llvm-config --libdir doesn't work in some cases


# Tests fail on Windows, and need someone knowledgeable to fix.
# It's not clear whether it's a test or a valid binding problem.
# XFAIL: target={{.*windows.*}}
Copy link
Collaborator

@dyung dyung Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this perhaps be system-windows instead?

This test failed on our Windows hosted, PS4 targeted buildbot.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspected something like that initially, but the problem with the llvm-clang-x86_64-sie-win buildbot is different: the build logs show

LLVM host triple: x86_64-pc-windows-msvc
LLVM default target triple: x86_64-sie-ps5

so this is the first instance of a cross-build. I found that lit already has a native feature that can be used here, which would resolve FIXME: Handle CMAKE_CROSSCOMPILING. in bindings.sh: just use

XFAIL: !native

I've never tried a cross-build of clang, so I'd really appreciate if someone with such a setup in place could try this.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 25, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve2-vla running on linaro-g4-01 while building clang at step 7 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/198/builds/5607

Here is the relevant piece of the build log for the reference
Step 7 (ninja check 1) failure: stage 1 checked (failure)
...
PASS: Clang Tools :: clang-tidy/checkers/bugprone/incorrect-roundings.cpp (22892 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/multiple-new-in-one-expression.cpp (22893 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/integer-division.cpp (22894 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/macro-parentheses-cmdline.cpp (22895 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-short.cpp (22896 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/macro-parentheses.cpp (22897 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/misleading-setter-of-reference.cpp (22898 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/move-forwarding-reference.cpp (22899 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/misplaced-widening-cast-explicit-only.cpp (22900 of 97976)
XPASS: Clang :: bindings/python/bindings.sh (22901 of 97976)
******************** TEST 'Clang :: bindings/python/bindings.sh' FAILED ********************
Exit Code: 0

Command Output (stderr):
--
env PYTHONPATH=/home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/clang/test/bindings/python/../../../bindings/python    CLANG_LIBRARY_PATH=`llvm-config --libdir`    "/usr/bin/python3.10" -m unittest discover -s /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/clang/test/bindings/python/tests # RUN: at line 33
++ llvm-config --libdir
+ env PYTHONPATH=/home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/clang/test/bindings/python/../../../bindings/python CLANG_LIBRARY_PATH=/home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/lib /usr/bin/python3.10 -m unittest discover -s /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/clang/test/bindings/python/tests
.....................................................................................................................................................................
----------------------------------------------------------------------
Ran 165 tests in 0.739s

OK

--

********************
PASS: Clang Tools :: clang-tidy/checkers/bugprone/misplaced-widening-cast-implicit-enabled.cpp (22902 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/altera/single-work-item-barrier.cpp (22903 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/misplaced-operator-in-strlen-in-alloc.cpp (22904 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/macro-repeated-side-effects.c (22905 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/narrowing-conversions-long-is-32bits.cpp (22906 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/multiple-statement-macro.cpp (22907 of 97976)
PASS: Clang :: utils/update_cc_test_checks/check-globals.test (22908 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/misplaced-pointer-arithmetic-in-alloc.c (22909 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/misplaced-operator-in-strlen-in-alloc.c (22910 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/incorrect-enable-shared-from-this.cpp (22911 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/multi-level-implicit-pointer-conversion.cpp (22912 of 97976)
PASS: Clang :: utils/update_cc_test_checks/mangled_names.test (22913 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/misplaced-pointer-arithmetic-in-alloc.cpp (22914 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/narrowing-conversions-narrowingfloatingpoint-option.cpp (22915 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/narrowing-conversions-pedanticmode-option.cpp (22916 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/infinite-loop.cpp (22917 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/narrowing-conversions-unsigned-char.cpp (22918 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/signal-handler.cpp (22919 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/narrowing-conversions.cpp (22920 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion-cpp11.cpp (22921 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/multi-level-implicit-pointer-conversion.c (22922 of 97976)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/optional-value-conversion-construct-from-std.cpp (22923 of 97976)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 25, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-quick running on linaro-clang-aarch64-quick while building clang at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/65/builds/18618

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
...
PASS: Clang Tools :: clang-tidy/checkers/modernize/raw-string-literal-delimiter.cpp (22020 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/make-unique-macros.cpp (22021 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/make-shared-header.cpp (22022 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/raw-string-literal-replace-shorter.cpp (22023 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/make-unique-header.cpp (22024 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/use-default-member-init.cpp (22025 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/deprecated-headers-cxx11.cpp (22026 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/redundant-void-arg-delayed.cpp (22027 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/loop-convert-lowercase.cpp (22028 of 85380)
XPASS: Clang :: bindings/python/bindings.sh (22029 of 85380)
******************** TEST 'Clang :: bindings/python/bindings.sh' FAILED ********************
Exit Code: 0

Command Output (stderr):
--
env PYTHONPATH=/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/bindings/python/../../../bindings/python    CLANG_LIBRARY_PATH=`llvm-config --libdir`    "/usr/bin/python3.10" -m unittest discover -s /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/bindings/python/tests # RUN: at line 33
++ llvm-config --libdir
+ env PYTHONPATH=/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/bindings/python/../../../bindings/python CLANG_LIBRARY_PATH=/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/lib /usr/bin/python3.10 -m unittest discover -s /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/bindings/python/tests
.....................................................................................................................................................................
----------------------------------------------------------------------
Ran 165 tests in 7.206s

OK

--

********************
PASS: Clang Tools :: clang-tidy/checkers/modernize/loop-convert-uppercase.cpp (22030 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/return-braced-init-list.cpp (22031 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/pass-by-value-macro-header.cpp (22032 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/loop-convert-multidimensional.cpp (22033 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/performance/enum-size.cpp (22034 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/use-std-format.cpp (22035 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/loop-convert-const.cpp (22036 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/use-default-member-init-macros.cpp (22037 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/use-std-numbers.cpp (22038 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/raw-string-literal.cpp (22039 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/readability/braces-around-statements-consteval-if.cpp (22040 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/pro-type-static-cast-downcast.cpp (22041 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/use-equals-default-macros.cpp (22042 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/replace-random-shuffle.cpp (22043 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/use-nodiscard.cpp (22044 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/loop-convert-negative.cpp (22045 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/use-nodiscard-gcc-unused.cpp (22046 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/use-nodiscard-cxx11.cpp (22047 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/hicpp/ignored-remove-result.cpp (22048 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/use-uncaught-exceptions.cpp (22049 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/use-equals-delete-macros.cpp (22050 of 85380)
PASS: Clang Tools :: clang-tidy/checkers/modernize/macro-to-enum.cpp (22051 of 85380)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 25, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve-vla running on linaro-g3-03 while building clang at step 7 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/17/builds/9106

Here is the relevant piece of the build log for the reference
Step 7 (ninja check 1) failure: stage 1 checked (failure)
...
PASS: Clang Tools :: clang-tidy/checkers/bugprone/virtual-near-miss.cpp (23239 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/avoid-capturing-lambda-coroutines.cpp (23240 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp (23241 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cert/setlongjmp.cpp (23242 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cert/str34-c.cpp (23243 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cert/oop54-cpp.cpp (23244 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cert/oop58-cpp.cpp (23245 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cert/oop57-cpp.cpp (23246 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cert/flp30-c.c (23247 of 98808)
XPASS: Clang :: bindings/python/bindings.sh (23248 of 98808)
******************** TEST 'Clang :: bindings/python/bindings.sh' FAILED ********************
Exit Code: 0

Command Output (stderr):
--
env PYTHONPATH=/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/clang/test/bindings/python/../../../bindings/python    CLANG_LIBRARY_PATH=`llvm-config --libdir`    "/usr/bin/python3.10" -m unittest discover -s /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/clang/test/bindings/python/tests # RUN: at line 33
++ llvm-config --libdir
+ env PYTHONPATH=/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/clang/test/bindings/python/../../../bindings/python CLANG_LIBRARY_PATH=/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/lib /usr/bin/python3.10 -m unittest discover -s /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/clang/test/bindings/python/tests
.....................................................................................................................................................................
----------------------------------------------------------------------
Ran 165 tests in 1.454s

OK

--

********************
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/pro-type-member-init-cxx20.cpp (23249 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/pro-type-member-init-cxx98.cpp (23250 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/macro-usage.cpp (23251 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cert/msc32-c.c (23252 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cert/msc51-cpp.cpp (23253 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/concurrency/mt-unsafe-any.cpp (23254 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp (23255 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cert/variadic-function-def.cpp (23256 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/concurrency/thread-canceltype-asynchronous.cpp (23257 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/macro-usage-custom.cpp (23258 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/special-member-functions-cxx-03.cpp (23259 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/init-variables-conflict.cpp (23260 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/concurrency/mt-unsafe-posix.cpp (23261 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/macro-usage-caps-only.cpp (23262 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/no-malloc-no-functions.cpp (23263 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/no-malloc-custom.cpp (23264 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/unsafe-functions-custom.c (23265 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/owning-memory-containers.cpp (23266 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/unsafe-functions-custom-regex.cpp (23267 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp (23268 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/google/module.cpp (23269 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/cppcoreguidelines/no-malloc.cpp (23270 of 98808)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 25, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve-vls running on linaro-g3-02 while building clang at step 7 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/143/builds/8751

Here is the relevant piece of the build log for the reference
Step 7 (ninja check 1) failure: stage 1 checked (failure)
...
PASS: Clang Tools :: clang-tidy/checkers/bugprone/suspicious-semicolon-fail.cpp (23148 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/signal-handler.c (23149 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/signed-char-misuse.cpp (23150 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/posix-return.cpp (23151 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/sizeof-expression-warn-on-sizeof-pointer-to-aggregate.cpp (23152 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/no-escape.m (23153 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/narrowing-conversions-ignoreconversionfromtypes-option.cpp (23154 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/parent-virtual-call.cpp (23155 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/undelegated-constructor-cxx98.cpp (23156 of 98808)
XPASS: Clang :: bindings/python/bindings.sh (23157 of 98808)
******************** TEST 'Clang :: bindings/python/bindings.sh' FAILED ********************
Exit Code: 0

Command Output (stderr):
--
env PYTHONPATH=/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/clang/test/bindings/python/../../../bindings/python    CLANG_LIBRARY_PATH=`llvm-config --libdir`    "/usr/bin/python3.10" -m unittest discover -s /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/clang/test/bindings/python/tests # RUN: at line 33
++ llvm-config --libdir
+ env PYTHONPATH=/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/clang/test/bindings/python/../../../bindings/python CLANG_LIBRARY_PATH=/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/lib /usr/bin/python3.10 -m unittest discover -s /home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/clang/test/bindings/python/tests
.....................................................................................................................................................................
----------------------------------------------------------------------
Ran 165 tests in 0.993s

OK

--

********************
PASS: Clang :: utils/update_cc_test_checks/check-globals.test (23158 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/sizeof-expression-any-pointer.cpp (23159 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/spuriously-wake-up-functions.c (23160 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/sizeof-expression-pointer-arithmetics.c (23161 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/spuriously-wake-up-functions.cpp (23162 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-int.cpp (23163 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-pointer-offset.cpp (23164 of 98808)
PASS: Clang :: utils/update_cc_test_checks/mangled_names.test (23165 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/reserved-identifier.cpp (23166 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp (23167 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/string-literal-with-embedded-nul.cpp (23168 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp (23169 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/unused-raii-crash.mm (23170 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/stringview-nullptr.cpp (23171 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/unhandled-exception-at-new.cpp (23172 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/suspicious-semicolon-constexpr.cpp (23173 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/suspicious-include.cpp (23174 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/suspicious-missing-comma.cpp (23175 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/suspicious-stringview-data-usage.cpp (23176 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/suspicious-memset-usage.c (23177 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp (23178 of 98808)
PASS: Clang Tools :: clang-tidy/checkers/bugprone/suspicious-memory-comparison.c (23179 of 98808)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 25, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-global-isel running on linaro-clang-aarch64-global-isel while building clang at step 7 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/125/builds/8663

Here is the relevant piece of the build log for the reference
Step 7 (ninja check 1) failure: stage 1 checked (failure)
...
PASS: Clang Tools :: clang-reorder-fields/MultipleFieldDeclsInStatement.cpp (21532 of 81199)
PASS: Clang Tools :: clang-reorder-fields/MacroExpansionField.cpp (21533 of 81199)
PASS: Clang Tools :: clang-reorder-fields/PlainCStructFieldsOrder.c (21534 of 81199)
PASS: Clang Tools :: clang-reorder-fields/MacroExpandsToMultipleFields.cpp (21535 of 81199)
PASS: Clang Tools :: clang-reorder-fields/FieldDependencyWarning.cpp (21536 of 81199)
PASS: Clang Tools :: clang-reorder-fields/PreprocessorDirectiveInDefinition.cpp (21537 of 81199)
PASS: Clang Tools :: clang-reorder-fields/PreprocessorDirectiveAroundDefinition.cpp (21538 of 81199)
PASS: Clang Tools :: clang-reorder-fields/PreprocessorDirectiveAroundFields.cpp (21539 of 81199)
PASS: Clang Tools :: clang-query/errors.c (21540 of 81199)
XPASS: Clang :: bindings/python/bindings.sh (21541 of 81199)
******************** TEST 'Clang :: bindings/python/bindings.sh' FAILED ********************
Exit Code: 0

Command Output (stderr):
--
env PYTHONPATH=/home/tcwg-buildbot/worker/clang-aarch64-global-isel/llvm/clang/test/bindings/python/../../../bindings/python    CLANG_LIBRARY_PATH=`llvm-config --libdir`    "/usr/bin/python3.10" -m unittest discover -s /home/tcwg-buildbot/worker/clang-aarch64-global-isel/llvm/clang/test/bindings/python/tests # RUN: at line 33
++ llvm-config --libdir
+ env PYTHONPATH=/home/tcwg-buildbot/worker/clang-aarch64-global-isel/llvm/clang/test/bindings/python/../../../bindings/python CLANG_LIBRARY_PATH=/home/tcwg-buildbot/worker/clang-aarch64-global-isel/stage1/lib /usr/bin/python3.10 -m unittest discover -s /home/tcwg-buildbot/worker/clang-aarch64-global-isel/llvm/clang/test/bindings/python/tests
.....................................................................................................................................................................
----------------------------------------------------------------------
Ran 165 tests in 2.459s

OK

--

********************
PASS: Clang Tools :: clang-tidy/CTTestTidyModule.cpp (21542 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/cleanup-ctad.cpp (21543 of 81199)
PASS: Clang Tools :: clang-move/move-used-helper-decls.cpp (21544 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/duration-division.cpp (21545 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/no-namespace.cpp (21546 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/faster-strsplit-delimiter.cpp (21547 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/duration-addition.cpp (21548 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/no-internal-dependencies.cpp (21549 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/duration-conversion-cast.cpp (21550 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/duration-factory-scale.cpp (21551 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/duration-subtraction.cpp (21552 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/duration-factory-float.cpp (21553 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/str-cat-append.cpp (21554 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/string-find-startswith.cpp (21555 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/duration-comparison.cpp (21556 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/redundant-strcat-calls.cpp (21557 of 81199)
PASS: Clang :: utils/update_cc_test_checks/generated-funcs.test (21558 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/duration-unnecessary-conversion.cpp (21559 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/altera/struct-pack-align-invalid-decl-no-crash.cpp (21560 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/altera/struct-pack-align-no-crash.cpp (21561 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/altera/id-dependent-backward-branch.cpp (21562 of 81199)
PASS: Clang Tools :: clang-tidy/checkers/abseil/time-comparison.cpp (21563 of 81199)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 26, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-win-x-armv7l running on as-builder-1 while building clang at step 10 "test-check-clang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/38/builds/4102

Here is the relevant piece of the build log for the reference
Step 10 (test-check-clang) failure: Test just built components: check-clang completed (failure)
******************** TEST 'Clang :: bindings/python/bindings.sh' FAILED ********************
Exit Code: 127

Command Output (stdout):
--
# RUN: at line 33
env PYTHONPATH=C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\bindings\python/../../../bindings/python    CLANG_LIBRARY_PATH=`llvm-config --libdir`    "C:\Python310\python.exe" -m unittest discover -s C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\bindings\python/tests
# executed command: env 'PYTHONPATH=C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\bindings\python/../../../bindings/python' 'CLANG_LIBRARY_PATH=`llvm-config' '--libdir`' 'C:\Python310\python.exe' -m unittest discover -s 'C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\bindings\python/tests'
# .---command stderr------------
# | '--libdir`': command not found
# `-----------------------------
# error: command failed with exit status: 127

--

********************


@rorth
Copy link
Collaborator Author

rorth commented Jun 26, 2025

I reverted this in #145774 since it causes build-failures. It seems that the substitution CLANG_LIBRARY_PATH=`llvm-config --libdir doesn't work in some cases

Thanks. When the failure reports began to trickle in, I started investigating, but it got very late.

I'd been operating under the assumption that the llvm part of the code is always built, which obviously isn't the case. I strongly suspect an alternative is to create a new substitution (%libdir) in lit.config.cfg, similar to clang/test/LibClang/lit.local.cfg, and use that. I'll give that a try.

What's the best way to move forward once the code is ready for review? Is there a way to reopen this PR and augment it or do I need to create a new one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:as-a-library libclang and C++ API clang Clang issues not falling into any other category github:workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants