Skip to content

Commit c1b206f

Browse files
authored
[clang][python] Don't add check-clang-python to check-all if cross-compiling (#111657)
Consistent with other cases for these tests, we opt not to add the target to check-all if they're known to fail. The tests fail when cross compiling for a different architecture because the host Python3_EXECUTABLE is used to run them, and FFI calls will of course fail against the libraries compiled for the target. Do note that CMAKE_CROSSCOMPILING is set to true whenever CMAKE_SYSTEM_NAME was set manually <https://cmake.org/cmake/help/latest/variable/CMAKE_CROSSCOMPILING.html> so in some circumstances it may be set even when not cross-compiling. However, it's the best way of checking that CMake has right now, and we use it elsewhere in LLVM's build system.
1 parent 8e010ac commit c1b206f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

clang/bindings/python/tests/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
4747
set(RUN_PYTHON_TESTS FALSE)
4848
endif()
4949

50+
# Tests will fail if cross-compiling for a different target, as tests will try
51+
# to use the host Python3_EXECUTABLE and make FFI calls to functions in target
52+
# libraries.
53+
if(CMAKE_CROSSCOMPILING)
54+
# FIXME: Consider a solution that allows better control over these tests in
55+
# a crosscompiling scenario. e.g. registering them with lit to allow them to
56+
# be explicitly skipped via appropriate LIT_ARGS, or adding a mechanism to
57+
# allow specifying a python interpreter compiled for the target that could
58+
# be executed using qemu-user.
59+
message(WARNING "check-clang-python not added to check-all as these tests fail in a cross-build setup")
60+
set(RUN_PYTHON_TESTS FALSE)
61+
endif()
62+
5063
if(RUN_PYTHON_TESTS)
5164
set_property(GLOBAL APPEND PROPERTY
5265
LLVM_ALL_ADDITIONAL_TEST_TARGETS check-clang-python)

0 commit comments

Comments
 (0)