[clang] c1b206f - [clang][python] Don't add check-clang-python to check-all if cross-compiling (#111657)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 13 08:51:40 PDT 2024
Author: Alex Bradbury
Date: 2024-10-13T16:51:37+01:00
New Revision: c1b206f347f633c84ac32f691241460196cd6226
URL: https://github.com/llvm/llvm-project/commit/c1b206f347f633c84ac32f691241460196cd6226
DIFF: https://github.com/llvm/llvm-project/commit/c1b206f347f633c84ac32f691241460196cd6226.diff
LOG: [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.
Added:
Modified:
clang/bindings/python/tests/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/bindings/python/tests/CMakeLists.txt b/clang/bindings/python/tests/CMakeLists.txt
index 2543cf739463d9..a0ddabc21bb411 100644
--- a/clang/bindings/python/tests/CMakeLists.txt
+++ b/clang/bindings/python/tests/CMakeLists.txt
@@ -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
diff erent 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)
More information about the cfe-commits
mailing list