Skip to content

Commit 0503301

Browse files
committed
- Adjust libclang-python-tests.yml.
- Handle `LLVM_USE_SANITIZER` in `lit.local.cfg`. - Fix SPARC handling, restrict to Linux/sparc*. - Explain failure modes, log unhandled ones.
1 parent e57e53c commit 0503301

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

.github/workflows/libclang-python-tests.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ on:
1010
- 'main'
1111
paths:
1212
- 'clang/bindings/python/**'
13+
- 'clang/test/bindings/python/**'
1314
- 'clang/tools/libclang/**'
14-
- 'clang/CMakeList.txt'
1515
- '.github/workflows/libclang-python-tests.yml'
1616
- '.github/workflows/llvm-project-tests.yml'
1717
pull_request:
1818
paths:
1919
- 'clang/bindings/python/**'
20+
- 'clang/test/bindings/python/**'
2021
- 'clang/tools/libclang/**'
21-
- 'clang/CMakeList.txt'
2222
- '.github/workflows/libclang-python-tests.yml'
2323
- '.github/workflows/llvm-project-tests.yml'
2424

@@ -33,7 +33,9 @@ jobs:
3333
python-version: ["3.8", "3.13"]
3434
uses: ./.github/workflows/llvm-project-tests.yml
3535
with:
36-
build_target: check-clang-python
36+
build_target: libclang
37+
run: |
38+
llvm-lit -v tools/clang/test --filter=bindings.sh
3739
projects: clang
3840
# There is an issue running on "windows-2019".
3941
# See https://github.com/llvm/llvm-project/issues/76601#issuecomment-1873049082.

clang/test/bindings/python/bindings.sh

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,20 @@
22

33
# UNSUPPORTED: !libclang-loadable
44

5-
# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
6-
#
7-
# Covered by libclang-loadable, may need to augment test for lack of
8-
# libclang.so.
9-
10-
# Do not try to run if libclang was built with sanitizers because
11-
# the sanitizer library will likely be loaded too late to perform
12-
# interception and will then fail.
13-
# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
14-
# portable so its easier just to not run the tests when building
15-
# with ASan.
16-
#
17-
# FIXME: Handle !LLVM_USE_SANITIZER = "".
18-
# lit.site.cfg.py has config.llvm_use_sanitizer = ""
19-
205
# Tests fail on Windows, and need someone knowledgeable to fix.
216
# It's not clear whether it's a test or a valid binding problem.
227
# XFAIL: target={{.*windows.*}}
238

249
# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
2510
# XFAIL: target={{.*-aix.*}}
2611

27-
# AArch64, Hexagon, and Sparc have known test failures that need to be
28-
# addressed.
12+
# AArch64 and Hexagon have known test failures that need to be addressed.
2913
# SystemZ has broken Python/FFI interface:
3014
# https://reviews.llvm.org/D52840#1265716
31-
# XFAIL: target={{(aarch64|hexagon|sparc*|s390x)-.*}}
15+
# XFAIL: target={{(aarch64|hexagon|s390x)-.*}}
16+
# python SEGVs on Linux/sparc64 when loading libclang.so. Seems to be an FFI
17+
# issue, too.
18+
# XFAIL: target={{sparc.*-.*-linux.*}}
3219

3320
# Tests will fail if cross-compiling for a different target, as tests will try
3421
# to use the host Python3_EXECUTABLE and make FFI calls to functions in target

clang/test/bindings/python/lit.local.cfg

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
def is_libclang_loadable():
2+
# Do not try to run if libclang was built with sanitizers because
3+
# the sanitizer library will likely be loaded too late to perform
4+
# interception and will then fail.
5+
# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
6+
# portable so its easier just to not run the tests when building
7+
# with ASan.
8+
if config.llvm_use_sanitizer != "":
9+
return False
210
try:
311
sys.path.append(os.path.join(config.clang_src_dir, "bindings/python"))
412
from clang.cindex import Config
@@ -7,13 +15,22 @@ def is_libclang_loadable():
715
conf.lib
816
return True
917
except Exception as e:
10-
# Benign error modes.
18+
# Expected failure modes are considered benign when nothing can be
19+
# done about them.
20+
#
21+
# Cannot load a 32-bit libclang.so into a 64-bit python.
1122
if "wrong ELF class: ELFCLASS32" in str(e):
1223
return False
24+
# If libclang.so is missing, it must have been disabled intentionally,
25+
# e.g. by building with LLVM_ENABLE_PIC=OFF.
1326
elif "No such file or directory" in str(e):
1427
return False
15-
# Unknown error modes.
28+
# Unexpected failure modes need to be investigated to either fix an
29+
# underlying bug or accept the failure, so return True. This causes
30+
# tests to run and FAIL, drawing developer attention.
1631
else:
32+
print("warning: unhandled failure in is_libclang_loadable: "
33+
+ str(e), file=sys.stderr)
1734
return True
1835

1936
if is_libclang_loadable():

0 commit comments

Comments
 (0)