Skip to content

Commit

Permalink
python3: fix ctypes module build. Fixes msys2#4572
Browse files Browse the repository at this point in the history
python/cpython#9258 changed callproc to
use functions from the internal libffi which we don't use.
Just copy the functions into callproc directly instead.
  • Loading branch information
lazka committed Oct 21, 2018
1 parent 5d5eb4b commit 022cfb5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
23 changes: 23 additions & 0 deletions mingw-w64-python3/1900-ctypes-dont-depend-on-internal-libffi.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
See https:/python/cpython/pull/9258
--- Python-3.7.1/Modules/_ctypes/callproc.c.orig 2018-10-20 08:04:19.000000000 +0200
+++ Python-3.7.1/Modules/_ctypes/callproc.c 2018-10-21 20:15:23.737316400 +0200
@@ -701,6 +701,19 @@
}
}

+/*
+Per: https://msdn.microsoft.com/en-us/library/7572ztz4.aspx
+To be returned by value in RAX, user-defined types must have a length
+of 1, 2, 4, 8, 16, 32, or 64 bits
+*/
+static int can_return_struct_as_int(size_t s)
+{
+ return s == 1 || s == 2 || s == 4;
+}
+static int can_return_struct_as_sint64(size_t s)
+{
+ return s == 8;
+}

ffi_type *_ctypes_get_ffi_type(PyObject *obj)
{
7 changes: 6 additions & 1 deletion mingw-w64-python3/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_pybasever=3.7
pkgver=${_pybasever}.1
pkgrel=1
pkgrel=2
pkgdesc="A high-level scripting language (mingw-w64)"
arch=('any')
license=('PSF')
Expand Down Expand Up @@ -125,6 +125,7 @@ source=("https://www.python.org/ftp/python/${pkgver%rc?}/Python-${pkgver}.tar.xz
1850-disable-readline.patch
1860-fix-isselectable.patch
2000-warnings-fixes.patch
1900-ctypes-dont-depend-on-internal-libffi.patch
smoketests.py)

# Helper macros to help make tasks easier #
Expand Down Expand Up @@ -281,6 +282,9 @@ prepare() {

apply_patch_with_msg 2000-warnings-fixes.patch

# https:/python/cpython/pull/9258
apply_patch_with_msg 1900-ctypes-dont-depend-on-internal-libffi.patch

autoreconf -vfi

# Temporary workaround for FS#22322
Expand Down Expand Up @@ -525,4 +529,5 @@ sha256sums=('fa7e2b8e8c9402f192ad56dc4f814089d1c4466c97d780f5e5acc02c04243d6d'
'3262ce24714dc6cfea5b18d528d7f1a333128eadf5aa9c3a026131c34f082e1f'
'bd9b934e8c1f92573115efaef6b6b04966e3222ba769511e006366d1217d34d6'
'e91f897e43063e0c4e52d971f5de4b5e193d9eb6a35fc3acfca1dc057a2fcd65'
'82ed4056649149cdfd7d76693864b07857b87ba36f628af321ee7d8ede8ed1a9'
'ea41f389324bf56277ef27a02f3510d22e5c88becbdb465468bdad9c15e0d229')

0 comments on commit 022cfb5

Please sign in to comment.