Files
MINGW-packages/mingw-w64-python3/0462-MINGW-support-stdcall-without-underscore.patch
Алексей edc01d04d6 Update python to 3.7.0 (#4047)
* Initial python-3.7 port

* python3: Add setup.config.in to remove before patching

* python3: Implement setenv for mingw. Fix building with NT threads. Build
with unicode

* Fix typos

* Fix linking core modules

* Mingw build have exec_prefix

* Remove deprecated patch

* Fix building python and modules. Failing to build readline module and
install not working yet

* More getpath changes and more aggressive path separator conversion

* Fix readline module compilation and linking errors

* python3: By default building with posix threads, NT threads are broken.
Some patches optimization. First buildable commit

* Py_DecodeLocale handle char, not wchar

* Fix building multiprocessing module with posix threads
2018-07-06 09:57:52 +03:00

33 lines
1.5 KiB
Diff

diff -Naur Python-3.7.0-orig/Modules/_ctypes/_ctypes.c Python-3.7.0/Modules/_ctypes/_ctypes.c
--- Python-3.7.0-orig/Modules/_ctypes/_ctypes.c 2018-06-27 06:07:35.000000000 +0300
+++ Python-3.7.0/Modules/_ctypes/_ctypes.c 2018-06-30 11:16:37.402259700 +0300
@@ -3187,11 +3187,28 @@
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);
address = (PPROC)GetProcAddress(handle, mangled_name);
if (address)
return address;
+ /* search for function without underscore as weel */
+ sprintf(mangled_name, "%s@%d", name, i*4);
+ address = (PPROC)GetProcAddress(handle, mangled_name);
+ if (address)
+ return address;
}
return NULL;
#endif