summarylogtreecommitdiffstats
path: root/0025-MINGW-support-stdcall-without-underscore.patch
diff options
context:
space:
mode:
authoratomlong2021-10-23 17:55:22 +0800
committeratomlong2021-10-23 18:06:15 +0800
commit80096c8de4b34ec1ed8f30bb428918cd592b2424 (patch)
treeb48dd1e73de9ea35a4709fb6b93deb16331ec514 /0025-MINGW-support-stdcall-without-underscore.patch
parent89a67c05174951d172252b1db96ff93cc4ec4bcd (diff)
downloadaur-mingw-w64-python.tar.gz
update to 3.9.7
Diffstat (limited to '0025-MINGW-support-stdcall-without-underscore.patch')
-rw-r--r--0025-MINGW-support-stdcall-without-underscore.patch54
1 files changed, 54 insertions, 0 deletions
diff --git a/0025-MINGW-support-stdcall-without-underscore.patch b/0025-MINGW-support-stdcall-without-underscore.patch
new file mode 100644
index 000000000000..25bb46c8b124
--- /dev/null
+++ b/0025-MINGW-support-stdcall-without-underscore.patch
@@ -0,0 +1,54 @@
+From 15b977a7de9a992afdb0af75ae3c3d84a524d7df Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?=
+ <alexey.pawlow@gmail.com>
+Date: Thu, 17 Jun 2021 18:51:39 +0530
+Subject: [PATCH 025/N] MINGW support stdcall without underscore
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Co-authored-by: Алексей <alexey.pawlow@gmail.com>
+---
+ Modules/_ctypes/_ctypes.c | 19 +++++++++++++++++++
+ 1 file changed, 19 insertions(+)
+
+diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
+index ceae67e..b9cf96b 100644
+--- a/Modules/_ctypes/_ctypes.c
++++ b/Modules/_ctypes/_ctypes.c
+@@ -3406,6 +3406,18 @@ static PPROC FindAddress(void *handle, const char *name, PyObject *type)
+ mangled_name = alloca(strlen(name) + 1 + 1 + 1 + 3); /* \0 _ @ %d */
+ if (!mangled_name)
+ return NULL;
++ /* Issue: for stdcall decorated export functions MSVC compiler adds
++ * underscore, but GCC compiler create them without. This is
++ * visible by example for _ctypes_test.pyd module.
++ * As well functions from system libraries are without underscore.
++ * Solutions:
++ * - If a python module is build with gcc option --add-stdcall-alias
++ * the module will contain XXX as alias for function XXX@ as result
++ * first search in this method will succeed.
++ * - Distutil may use compiler to create def-file, to modify it as
++ * add underscore alias and with new def file to create module.
++ * - Or may be just to search for function without underscore.
++ */
+ for (i = 0; i < 32; ++i) {
+ sprintf(mangled_name, "_%s@%d", name, i*4);
+ Py_BEGIN_ALLOW_THREADS
+@@ -3413,6 +3425,13 @@ static PPROC FindAddress(void *handle, const char *name, PyObject *type)
+ Py_END_ALLOW_THREADS
+ if (address)
+ return address;
++ /* search for function without underscore as weel */
++ sprintf(mangled_name, "%s@%d", name, i*4);
++ Py_BEGIN_ALLOW_THREADS
++ address = (PPROC)GetProcAddress(handle, mangled_name);
++ Py_END_ALLOW_THREADS
++ if (address)
++ return address;
+ }
+ return NULL;
+ #endif
+--
+2.33.0
+