Skip to content

Commit

Permalink
[clang][python] Don't add check-clang-python to check-all if cross-co…
Browse files Browse the repository at this point in the history
…mpiling (llvm#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.
  • Loading branch information
asb authored and EricWF committed Oct 22, 2024
1 parent 0a28d69 commit 1a2f99f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions clang/bindings/python/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ 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)
Expand Down

0 comments on commit 1a2f99f

Please sign in to comment.