[clang] [clang][python] Don't add check-clang-python to check-all if cross-compiling (PR #111657)

Alex Bradbury via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 13 07:10:33 PDT 2024


https://github.com/asb updated https://github.com/llvm/llvm-project/pull/111657

>From afd9488eb0b69c5375f7259a02581389c5003917 Mon Sep 17 00:00:00 2001
From: Alex Bradbury <asb at igalia.com>
Date: Wed, 9 Oct 2024 11:09:44 +0100
Subject: [PATCH 1/4] [clang][python] Don't add check-clang-python to check-all
 if cross-compiling

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.

This is an alternate take on
<https://github.com/llvm/llvm-project/pull/111367>.
---
 clang/bindings/python/tests/CMakeLists.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/clang/bindings/python/tests/CMakeLists.txt b/clang/bindings/python/tests/CMakeLists.txt
index 2543cf739463d9..de75d303aca7bb 100644
--- a/clang/bindings/python/tests/CMakeLists.txt
+++ b/clang/bindings/python/tests/CMakeLists.txt
@@ -47,6 +47,14 @@ 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_CROSS_COMPILING)
+  message(WARNING "check-clang-python-tests not added to check-all as they 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)

>From 8ca43d1c13bfe106a412ad229735045fa24c7c6a Mon Sep 17 00:00:00 2001
From: Alex Bradbury <asb at igalia.com>
Date: Sun, 13 Oct 2024 15:04:46 +0100
Subject: [PATCH 2/4] Fix typo of CMAKE_CROSSCOMPILING

---
 clang/bindings/python/tests/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/bindings/python/tests/CMakeLists.txt b/clang/bindings/python/tests/CMakeLists.txt
index de75d303aca7bb..77688009c9b3e2 100644
--- a/clang/bindings/python/tests/CMakeLists.txt
+++ b/clang/bindings/python/tests/CMakeLists.txt
@@ -50,7 +50,7 @@ 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_CROSS_COMPILING)
+if(CMAKE_CROSSCOMPILING)
   message(WARNING "check-clang-python-tests not added to check-all as they fail in a cross-build setup")
   set(RUN_PYTHON_TESTS FALSE)
 endif()

>From 3653541312edc27a705ba1649e0eec12466e239b Mon Sep 17 00:00:00 2001
From: Alex Bradbury <asb at igalia.com>
Date: Sun, 13 Oct 2024 15:06:37 +0100
Subject: [PATCH 3/4] Fix typo and refine wording when check-clang-python not
 added to check-all

---
 clang/bindings/python/tests/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/bindings/python/tests/CMakeLists.txt b/clang/bindings/python/tests/CMakeLists.txt
index 77688009c9b3e2..a44ff8d49e3409 100644
--- a/clang/bindings/python/tests/CMakeLists.txt
+++ b/clang/bindings/python/tests/CMakeLists.txt
@@ -51,7 +51,7 @@ endif()
 # to use the host Python3_EXECUTABLE and make FFI calls to functions in target
 # libraries.
 if(CMAKE_CROSSCOMPILING)
-  message(WARNING "check-clang-python-tests not added to check-all as they fail in a cross-build setup")
+  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()
 

>From 3f210405d221e6b4583e26e14671a704987310f5 Mon Sep 17 00:00:00 2001
From: Alex Bradbury <asb at igalia.com>
Date: Sun, 13 Oct 2024 15:10:15 +0100
Subject: [PATCH 4/4] Add FIXME based on review discussion

---
 clang/bindings/python/tests/CMakeLists.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/clang/bindings/python/tests/CMakeLists.txt b/clang/bindings/python/tests/CMakeLists.txt
index a44ff8d49e3409..a0ddabc21bb411 100644
--- a/clang/bindings/python/tests/CMakeLists.txt
+++ b/clang/bindings/python/tests/CMakeLists.txt
@@ -51,6 +51,11 @@ endif()
 # 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()



More information about the cfe-commits mailing list