From 0011b4e1160c42904852c2676eb42cebf98590c3 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 12 Jun 2026 16:32:20 -0700 Subject: [PATCH 1/3] gh-151422: Don't link libffi into _ctypes_test.so Minor build fix --- configure | 4 ++-- configure.ac | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 0cd98a193030dd..7608a0493b0ee6 100755 --- a/configure +++ b/configure @@ -35116,8 +35116,8 @@ fi if test "x$py_cv_module__ctypes_test" = xyes then : - as_fn_append MODULE_BLOCK "MODULE__CTYPES_TEST_CFLAGS=$LIBFFI_CFLAGS$as_nl" - as_fn_append MODULE_BLOCK "MODULE__CTYPES_TEST_LDFLAGS=$LIBFFI_LIBS $LIBM$as_nl" + + as_fn_append MODULE_BLOCK "MODULE__CTYPES_TEST_LDFLAGS=$LIBM$as_nl" fi if test "$py_cv_module__ctypes_test" = yes; then diff --git a/configure.ac b/configure.ac index d3320f0e45fe14..020861b4c82375 100644 --- a/configure.ac +++ b/configure.ac @@ -8447,9 +8447,11 @@ PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$ac_cv_fun PY_STDLIB_MOD([_testsinglephase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes]) PY_STDLIB_MOD([xxsubtype], [test "$TEST_MODULES" = yes]) PY_STDLIB_MOD([_xxtestfuzz], [test "$TEST_MODULES" = yes]) +dnl Check have_libffi so _ctypes_test is only built if _ctypes is built. +dnl _ctypes_test doesn't use libffi directly. PY_STDLIB_MOD([_ctypes_test], [test "$TEST_MODULES" = yes], [test "$have_libffi" = yes -a "$ac_cv_func_dlopen" = yes], - [$LIBFFI_CFLAGS], [$LIBFFI_LIBS $LIBM]) + [], [$LIBM]) dnl Limited API template modules. dnl Emscripten does not support shared libraries yet. From 4fb91c5c8b840a475065c22de25c31d371dc7034 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sat, 13 Jun 2026 08:16:25 -0700 Subject: [PATCH 2/3] Add test skips for ctypes tests that don't work on emscripten --- Lib/test/test_ctypes/test_as_parameter.py | 3 ++- Lib/test/test_ctypes/test_structures.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_ctypes/test_as_parameter.py b/Lib/test/test_ctypes/test_as_parameter.py index 2da1acfcf2989e..c9d728e9ae2f9c 100644 --- a/Lib/test/test_ctypes/test_as_parameter.py +++ b/Lib/test/test_ctypes/test_as_parameter.py @@ -5,7 +5,7 @@ c_short, c_int, c_long, c_longlong, c_byte, c_wchar, c_float, c_double, ArgumentError) -from test.support import import_helper, skip_if_sanitizer +from test.support import import_helper, skip_if_sanitizer, skip_emscripten_stack_overflow _ctypes_test = import_helper.import_module("_ctypes_test") @@ -193,6 +193,7 @@ class S8I(Structure): (9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9)) @skip_if_sanitizer('requires deep stack', thread=True) + @skip_emscripten_stack_overflow() def test_recursive_as_param(self): class A: pass diff --git a/Lib/test/test_ctypes/test_structures.py b/Lib/test/test_ctypes/test_structures.py index 92d4851d739d47..e9a1d455a2d689 100644 --- a/Lib/test/test_ctypes/test_structures.py +++ b/Lib/test/test_ctypes/test_structures.py @@ -302,6 +302,15 @@ class X(Structure): def _test_issue18060(self, Vector): # Regression tests for gh-62260 + # This test passes a struct of two doubles by value to the atan2(), + # whose actual C signature is atan2(double, double), so it only works on + # platforms where the abi of a function that takes a struct with two + # doubles matches the abi of a function that takes two doubles. The + # wasm32 ABI does not satisfy this condition and the test breaks. + if support.is_wasm32: + self.skipTest( + "wasm ABI is incompatible with test expectations") + # The call to atan2() should succeed if the # class fields were correctly cloned in the # subclasses. Otherwise, it will segfault. From b4eac7642b0f494d4e81ac2e84104fb0ae7f2d4f Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 15 Jun 2026 08:27:16 -0700 Subject: [PATCH 3/3] Use skipIf decorator --- Lib/test/test_ctypes/test_structures.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_ctypes/test_structures.py b/Lib/test/test_ctypes/test_structures.py index e9a1d455a2d689..65ccc12625f72b 100644 --- a/Lib/test/test_ctypes/test_structures.py +++ b/Lib/test/test_ctypes/test_structures.py @@ -299,17 +299,15 @@ class X(Structure): self.assertEqual(s.first, got.first) self.assertEqual(s.second, got.second) + @unittest.skipIf(support.is_wasm32, "wasm ABI is incompatible with test expectations") def _test_issue18060(self, Vector): # Regression tests for gh-62260 - # This test passes a struct of two doubles by value to the atan2(), - # whose actual C signature is atan2(double, double), so it only works on - # platforms where the abi of a function that takes a struct with two - # doubles matches the abi of a function that takes two doubles. The - # wasm32 ABI does not satisfy this condition and the test breaks. - if support.is_wasm32: - self.skipTest( - "wasm ABI is incompatible with test expectations") + # This test passes a struct of two doubles by value to atan2(), whose C + # signature is atan2(double, double), so it only works on platforms + # where the abi of a function that takes a struct with two doubles + # matches the abi of a function that takes two doubles. The wasm32 ABI + # does not satisfy this condition and the test breaks. # The call to atan2() should succeed if the # class fields were correctly cloned in the