Skip to content

Commit b8d8a28

Browse files
Roumen PetrovFaraz Shahbazker
authored andcommitted
Issue python#18486: MINGW: dynamic loading support
1 parent 7f90a47 commit b8d8a28

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Makefile.pre.in

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

810+
Python/dynload_win.o: $(srcdir)/Python/dynload_win.c Makefile
811+
$(CC) -c $(PY_CORE_CFLAGS) \
812+
-DSHLIB_SUFFIX='"$(SHLIB_SUFFIX)"' \
813+
-DEXT_SUFFIX='"$(EXT_SUFFIX)"' \
814+
-o $@ $(srcdir)/Python/dynload_win.c
815+
810816
Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
811817
$(CC) -c $(PY_CORE_CFLAGS) \
812818
-DABIFLAGS='"$(ABIFLAGS)"' \

Python/dynload_win.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,20 @@ void _Py_DeactivateActCtx(ULONG_PTR cookie);
3535
const char *_PyImport_DynLoadFiletab[] = {
3636
PYD_TAGGED_SUFFIX,
3737
PYD_UNTAGGED_SUFFIX,
38+
#ifdef EXT_SUFFIX
39+
EXT_SUFFIX, /* include SOABI flags where is encoded debug */
40+
#endif
41+
#ifdef SHLIB_SUFFIX
42+
"-abi" PYTHON_ABI_STRING SHLIB_SUFFIX,
43+
#endif
3844
NULL
3945
};
4046

47+
48+
#if defined(__MINGW32__)
49+
/* avoid compile error: conflicting types for 'strcasecmp' */
50+
# define strcasecmp fake_strcasecmp
51+
#endif
4152
/* Case insensitive string compare, to avoid any dependencies on particular
4253
C RTL implementations */
4354

configure.ac

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,6 +2641,9 @@ if test -z "$SHLIB_SUFFIX"; then
26412641
CYGWIN*) SHLIB_SUFFIX=.dll;;
26422642
*) SHLIB_SUFFIX=.so;;
26432643
esac
2644+
case $host_os in
2645+
mingw*) SHLIB_SUFFIX=.dll;;
2646+
esac
26442647
fi
26452648
AC_MSG_RESULT($SHLIB_SUFFIX)
26462649

@@ -3679,6 +3682,12 @@ then
36793682
fi
36803683
;;
36813684
esac
3685+
case $host in
3686+
*-*-mingw*)
3687+
DYNLOADFILE="dynload_win.o"
3688+
extra_machdep_objs="$extra_machdep_objs PC/dl_nt.o"
3689+
;;
3690+
esac
36823691
fi
36833692
AC_MSG_RESULT($DYNLOADFILE)
36843693
if test "$DYNLOADFILE" != "dynload_stub.o"
@@ -4920,6 +4929,13 @@ case $ac_sys_system in
49204929
EXT_SUFFIX=${SHLIB_SUFFIX};;
49214930
esac
49224931

4932+
case $host_os in
4933+
mingw*)
4934+
dnl Synchronized with _PyImport_DynLoadFiletab (dynload_win.c)
4935+
dnl Do not use more then one dot on this platform !
4936+
EXT_SUFFIX=-$SOABI$SHLIB_SUFFIX;;
4937+
esac
4938+
49234939
AC_MSG_CHECKING(LDVERSION)
49244940
LDVERSION='$(VERSION)$(ABIFLAGS)'
49254941
AC_MSG_RESULT($LDVERSION)

0 commit comments

Comments
 (0)