Skip to content

Commit 125c9ee

Browse files
Alexpuxlazka
authored andcommitted
Add dynamic loading support for MINGW
Co-authored-by: Алексей <[email protected]>
1 parent 930a5ec commit 125c9ee

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

Makefile.pre.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,12 @@ Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
12761276
-DSHLIB_EXT='"$(EXT_SUFFIX)"' \
12771277
-o $@ $(srcdir)/Python/dynload_hpux.c
12781278

1279+
Python/dynload_win.o: $(srcdir)/Python/dynload_win.c Makefile
1280+
$(CC) -c $(PY_CORE_CFLAGS) \
1281+
-DSHLIB_SUFFIX='"$(SHLIB_SUFFIX)"' \
1282+
-DEXT_SUFFIX='"$(EXT_SUFFIX)"' \
1283+
-o $@ $(srcdir)/Python/dynload_win.c
1284+
12791285
Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile $(srcdir)/Include/pydtrace.h
12801286
$(CC) -c $(PY_CORE_CFLAGS) \
12811287
-DABIFLAGS='"$(ABIFLAGS)"' \

Python/dynload_win.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
#define PYD_UNTAGGED_SUFFIX PYD_DEBUG_SUFFIX ".pyd"
3030

3131
const char *_PyImport_DynLoadFiletab[] = {
32+
#ifdef EXT_SUFFIX
33+
EXT_SUFFIX, /* include SOABI flags where is encoded debug */
34+
#endif
35+
#ifdef SHLIB_SUFFIX
36+
"-abi" PYTHON_ABI_STRING SHLIB_SUFFIX,
37+
#endif
3238
PYD_TAGGED_SUFFIX,
3339
PYD_UNTAGGED_SUFFIX,
3440
NULL
@@ -249,8 +255,7 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
249255
ensure DLLs adjacent to the PYD are preferred. */
250256
Py_BEGIN_ALLOW_THREADS
251257
hDLL = LoadLibraryExW(wpathname, NULL,
252-
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS |
253-
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
258+
LOAD_WITH_ALTERED_SEARCH_PATH);
254259
Py_END_ALLOW_THREADS
255260
#if !USE_UNICODE_WCHAR_CACHE
256261
PyMem_Free(wpathname);

configure.ac

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,6 +3215,9 @@ if test -z "$SHLIB_SUFFIX"; then
32153215
CYGWIN*) SHLIB_SUFFIX=.dll;;
32163216
*) SHLIB_SUFFIX=.so;;
32173217
esac
3218+
case $host_os in
3219+
mingw*) SHLIB_SUFFIX=.dll;;
3220+
esac
32183221
fi
32193222
AC_MSG_RESULT($SHLIB_SUFFIX)
32203223

@@ -4702,6 +4705,13 @@ then
47024705
fi
47034706
;;
47044707
esac
4708+
case $host in
4709+
*-*-mingw*)
4710+
DYNLOADFILE="dynload_win.o"
4711+
extra_machdep_objs="$extra_machdep_objs PC/dl_nt.o"
4712+
CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"$VERSION\"'"
4713+
;;
4714+
esac
47054715
fi
47064716
AC_MSG_RESULT($DYNLOADFILE)
47074717
if test "$DYNLOADFILE" != "dynload_stub.o"
@@ -6487,6 +6497,12 @@ case "$ac_cv_computed_gotos" in yes*)
64876497
AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
64886498
[Define if the C compiler supports computed gotos.])
64896499
esac
6500+
case $host_os in
6501+
mingw*)
6502+
dnl Synchronized with _PyImport_DynLoadFiletab (dynload_win.c)
6503+
dnl Do not use more then one dot on this platform !
6504+
EXT_SUFFIX=-$SOABI$SHLIB_SUFFIX;;
6505+
esac
64906506

64916507
case $ac_sys_system in
64926508
AIX*)

0 commit comments

Comments
 (0)