Browse Source

python now builds on mingw, without ctypes; set DLLWRAP env var

Signed-off-by: falkTX <falktx@falktx.com>
tags/v1.1
falkTX 4 years ago
parent
commit
1972ff0041
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
16 changed files with 73 additions and 32 deletions
  1. +15
    -6
      bootstrap-carla.sh
  2. +1
    -1
      patches/Python/win32/0150-MINGW-configure-largefile-support-for-windows-builds.patch
  3. +2
    -2
      patches/Python/win32/0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch
  4. +1
    -1
      patches/Python/win32/0200-MINGW-build-in-windows-modules-winreg.patch
  5. +3
    -3
      patches/Python/win32/0300-MINGW-configure-for-shared-build.patch
  6. +3
    -3
      patches/Python/win32/0310-MINGW-dynamic-loading-support.patch
  7. +4
    -4
      patches/Python/win32/0410-MINGW-build-extensions-with-GCC.patch
  8. +1
    -1
      patches/Python/win32/0420-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch
  9. +1
    -1
      patches/Python/win32/0460-MINGW-generalization-of-posix-build-in-sysconfig.py.patch
  10. +1
    -1
      patches/Python/win32/0670-msys-convert_path-fix-and-root-hack.patch
  11. +1
    -1
      patches/Python/win32/0820-dont-link-with-gettext.patch
  12. +21
    -0
      patches/Python/win32/9001-pawpaw-needed-changes.patch
  13. +13
    -0
      patches/Python/win32/9002-mingw-as-win32-host-platform-build.patch
  14. +3
    -8
      patches/Python/win32/PKGBUILD
  15. +1
    -0
      setup/env.sh
  16. +2
    -0
      setup/functions.sh

+ 15
- 6
bootstrap-carla.sh View File

@@ -42,7 +42,6 @@ function build_conf_python() {

if [ "${CROSS_COMPILING}" -eq 1 ]; then
extraconfrules+=" --host=${TOOLCHAIN_PREFIX} --build=x86_64-linux-gnu"
export PYTHON_FOR_BUILD=python3
fi

_prebuild "${name}" "${pkgdir}"
@@ -71,11 +70,21 @@ function build_conf_python() {
if [ ! -f "${pkgdir}/.stamp_built" ]; then
pushd "${pkgdir}"
if [ "${WIN32}" -eq 1 ]; then
# adds -Wl,-Bdynamic so we link to shared python lib
sed -i -e 's|BLDLIBRARY= -L.|BLDLIBRARY= -Wl,-Bdynamic -L.|' Makefile
# EXE suffix missing
sed -i -e 's|./Programs/_freeze_importlib zipimport|./Programs/_freeze_importlib$(EXE) zipimport|' Makefile
sed -i -e 's|\twindres|\tx86_64-w64-mingw32-windres|' Makefile
# inject exe-wrapper
if [ -n "${EXE_WRAPPER}" ]; then
sed -i -e "s|\t./Programs/_freeze_importlib|\t${EXE_WRAPPER} ./Programs/_freeze_importlib|" Makefile
fi
# use toolchain prefix on windres tool if cross-compiling
if [ "${CROSS_COMPILING}" -eq 1 ]; then
sed -i -e "s|\twindres|\t${TOOLCHAIN_PREFIX_}windres|" Makefile
fi
make regen-importlib
fi
make ${MAKE_ARGS} ${EXTRA_MAKE_ARGS}
make ${MAKE_ARGS}
touch .stamp_built
popd
fi
@@ -172,7 +181,6 @@ elif [ "${WIN32}" -eq 1 ]; then
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NODELETE=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOLOAD=no"
PYTHON_EXTRAFLAGS+=" OPT="
export MSYSTEM=MINGW
fi

download Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz"
@@ -181,9 +189,10 @@ if [ "${PYTHON_VERSION}" = "3.7.4" ]; then
fi
build_conf_python Python "${PYTHON_VERSION}" "--prefix=${PAWPAW_PREFIX} --enable-shared ${PYTHON_EXTRAFLAGS}"

# TODO: finish this
if [ "${WIN32}" -eq 1 ]; then
unset MSYSTEM
endif
exit 0
fi

# ---------------------------------------------------------------------------------------------------------------------
# sip


+ 1
- 1
patches/Python/win32/0150-MINGW-configure-largefile-support-for-windows-builds.patch View File

@@ -11,7 +11,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
+ have_largefile_support=yes
+else
+ case $host in
+ *)
+ *-*-mingw*)
+ dnl Activate on windows platforms (32&64-bit) where off_t(4) < fpos_t(8)
+ have_largefile_support=yes
+ ;;


+ 2
- 2
patches/Python/win32/0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch View File

@@ -6,7 +6,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
done
+case $host in
+ *)
+ *-*-mingw*)
+ dnl Required for windows builds as Objects/exceptions.c require
+ dnl "errmap.h" from $srcdir/PC.
+ dnl Note we cannot use BASECPPFLAGS as autogenerated pyconfig.h
@@ -18,7 +18,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
AC_SUBST(SRCDIRS)
SRCDIRS="Parser Objects Python Modules Modules/_io Programs"
+case $host in
+ *) SRCDIRS="$SRCDIRS PC";;
+ *-*-mingw*) SRCDIRS="$SRCDIRS PC";;
+esac
AC_MSG_CHECKING(for build directories)
for dir in $SRCDIRS; do


+ 1
- 1
patches/Python/win32/0200-MINGW-build-in-windows-modules-winreg.patch View File

@@ -9,7 +9,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
+AC_SUBST(USE_WIN32_MODULE)
+USE_WIN32_MODULE='#'
+case $host in
+ not_this_one) USE_WIN32_MODULE=;;
+ *-*-mingw*) USE_WIN32_MODULE=;;
+esac
+
# Templates for things AC_DEFINEd more than once.


+ 3
- 3
patches/Python/win32/0300-MINGW-configure-for-shared-build.patch View File

@@ -6,7 +6,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
esac
+ case $host in
+ *)
+ *-*-mingw*)
+ LDLIBRARY='libpython$(LDVERSION).dll.a'
+ DLLLIBRARY='libpython$(LDVERSION).dll'
+ BLDLIBRARY='-L. -lpython$(LDVERSION)'
@@ -20,7 +20,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
;;
esac
+ case $host in
+ *)
+ *-*-mingw*)
+ LDLIBRARY='libpython$(LDVERSION).a';;
+ esac
fi
@@ -31,7 +31,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
*) LDSHARED="ld";;
esac
+ case $host in
+ *)
+ *-*-mingw*)
+ LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
+ LDCXXSHARED='$(CXX) -shared -Wl,--enable-auto-image-base'
+ ;;


+ 3
- 3
patches/Python/win32/0310-MINGW-dynamic-loading-support.patch View File

@@ -6,7 +6,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
*) SHLIB_SUFFIX=.so;;
esac
+ case $host_os in
+ *) SHLIB_SUFFIX=.dll;;
+ mingw*) SHLIB_SUFFIX=.dll;;
+ esac
fi
AC_MSG_RESULT($SHLIB_SUFFIX)
@@ -16,7 +16,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
;;
esac
+ case $host in
+ *)
+ *-*-mingw*)
+ DYNLOADFILE="dynload_win.o"
+ extra_machdep_objs="$extra_machdep_objs PC/dl_nt.o"
+ ;;
@@ -29,7 +29,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
EXT_SUFFIX=${SHLIB_SUFFIX};;
esac
+case $host_os in
+ *)
+ mingw*)
+ dnl Synchronized with _PyImport_DynLoadFiletab (dynload_win.c)
+ dnl Do not use more then one dot on this platform !
+ EXT_SUFFIX=-$SOABI$SHLIB_SUFFIX;;


+ 4
- 4
patches/Python/win32/0410-MINGW-build-extensions-with-GCC.patch View File

@@ -6,7 +6,7 @@ diff -Naur Python-3.8.0-orig/Lib/distutils/command/build_ext.py Python-3.8.0/Lib
# for Release and Debug builds.
# also Python's library directory must be appended to library_dirs
- if os.name == 'nt':
+ if False:
+ if os.name == 'nt' and not self.plat_name.startswith(('mingw')):
# the 'libs' directory is for binary installs - we assume that
# must be the *native* platform. But we don't really support
# cross-compiling via a binary install anyway, so we let it go.
@@ -17,7 +17,7 @@ diff -Naur Python-3.8.0-orig/Lib/distutils/command/build_ext.py Python-3.8.0/Lib
+
+ # Use self.plat_name as it works even in case of
+ # cross-compilation (at least for mingw build).
+ if True:
+ if self.plat_name.startswith('mingw'):
+ from distutils import sysconfig
+ extra = []
+ for lib in (
@@ -38,7 +38,7 @@ diff -Naur Python-3.8.0-orig/Lib/distutils/util.py Python-3.8.0/Lib/distutils/ut
"""
if os.name == 'nt':
+ if True:
+ if 'GCC' in sys.version:
+ return 'mingw'
if 'amd64' in sys.version.lower():
return 'win-amd64'
@@ -50,7 +50,7 @@ diff -Naur Python-3.8.0-orig/Lib/sysconfig.py Python-3.8.0/Lib/sysconfig.py
"""
if os.name == 'nt':
+ if True:
+ if 'GCC' in sys.version:
+ return 'mingw'
if 'amd64' in sys.version.lower():
return 'win-amd64'


+ 1
- 1
patches/Python/win32/0420-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch View File

@@ -14,7 +14,7 @@ diff -Naur Python-3.8.0-orig/Lib/distutils/ccompiler.py Python-3.8.0/Lib/distuti
osname = os.name
if platform is None:
platform = sys.platform
+ if True:
+ if get_platform().startswith('mingw'):
+ return 'mingw32'
for pattern, compiler in _default_compilers:
if re.match(pattern, platform) is not None or \


+ 1
- 1
patches/Python/win32/0460-MINGW-generalization-of-posix-build-in-sysconfig.py.patch View File

@@ -7,7 +7,7 @@ diff -Naur Python-3.8.0-orig/Lib/sysconfig.py Python-3.8.0/Lib/sysconfig.py
+# GCC[mingw*] use posix build system
+_POSIX_BUILD = os.name == 'posix' or \
+ True
+ (os.name == "nt" and 'GCC' in sys.version)
def _safe_realpath(path):
try:


+ 1
- 1
patches/Python/win32/0670-msys-convert_path-fix-and-root-hack.patch View File

@@ -69,7 +69,7 @@ diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in
else true; \
fi
+ifeq (Msys,Msys)
+ifeq ($(shell uname -o),Msys)
+DESTDIRFINAL=$(DESTDIR)
+else
+DESTDIRFINAL=$(DESTDIR)/


+ 1
- 1
patches/Python/win32/0820-dont-link-with-gettext.patch View File

@@ -6,7 +6,7 @@ diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
# check if we need libintl for locale functions
+case $host in
+ *)
+ *-*-mingw*)
+ dnl Native windows build don't use libintl (see _localemodule.c).
+ dnl Also we don't like setup.py to add "intl" library to the list
+ dnl when build _locale module.


+ 21
- 0
patches/Python/win32/9001-pawpaw-needed-changes.patch View File

@@ -0,0 +1,21 @@
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
index dddf412..b0a18a7 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -263,6 +263,8 @@ class CygwinCCompiler(UnixCCompiler):
if not debug and not hasattr(sys, 'gettotalrefcount'):
extra_preargs.append("-s")
+ extra_preargs.append("-Wl,-Bdynamic")
+
UnixCCompiler.link(self, target_desc, objects, output_filename,
output_dir, libraries, library_dirs,
runtime_library_dirs,
@@ -413,6 +415,7 @@ def _find_exe_version(cmd):
out_string = out.read()
finally:
out.close()
+ out_string = out_string.split(b'\n',1)[0].replace(b'-win32',b'')
result = RE_VERSION.search(out_string)
if result is None:
return None

+ 13
- 0
patches/Python/win32/9002-mingw-as-win32-host-platform-build.patch View File

@@ -0,0 +1,13 @@
diff --git a/setup.py b/setup.py
index a80e6b2..3a7a2e7 100644
--- a/setup.py
+++ b/setup.py
@@ -51,7 +51,7 @@ if sys.platform == "win32" and "MSYSTEM" in os.environ:
CROSS_COMPILING = ("_PYTHON_HOST_PLATFORM" in os.environ)
HOST_PLATFORM = get_platform()
-MS_WINDOWS = (HOST_PLATFORM == 'win32')
+MS_WINDOWS = (HOST_PLATFORM in ('mingw', 'win32'))
CYGWIN = (HOST_PLATFORM == 'cygwin')
MACOS = (HOST_PLATFORM == 'darwin')
AIX = (HOST_PLATFORM.startswith('aix'))

+ 3
- 8
patches/Python/win32/PKGBUILD View File

@@ -18,7 +18,7 @@ pkgbase="mingw-w64-${_realname}"
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
_pybasever=3.8
pkgver=${_pybasever}.7
pkgrel=2
pkgrel=3
provides=("${MINGW_PACKAGE_PREFIX}-python3=${pkgver}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3"
"${MINGW_PACKAGE_PREFIX}-python2<2.7.16-7")
@@ -117,7 +117,6 @@ source=("https://www.python.org/ftp/python/${pkgver%rc?}/Python-${pkgver}.tar.xz
1650-expose-sem_unlink.patch
1700-cygpty-isatty.patch
1701-disable-broken-gdbm-module.patch
1702-default-to-console-cp-for-cygpty.patch
1800-link-win-resource-files-and-build-pythonw.patch
1810-3.7-mpdec-mingw.patch
1850-disable-readline.patch
@@ -256,13 +255,10 @@ prepare() {
1650-expose-sem_unlink.patch

# Extend some isatty calls to check for mintty when checking for
# a terminal output. And default stdout/in to the console CP for cygpty
# (once we have conpty this can be removed)
# a terminal output.
# https://github.com/Alexpux/MINGW-packages/issues/2645
# https://github.com/Alexpux/MINGW-packages/issues/2656
apply_patch_with_msg \
1700-cygpty-isatty.patch \
1702-default-to-console-cp-for-cygpty.patch
1700-cygpty-isatty.patch

# gdbm is broken and as a result breaks dbm/shelve.
# Don't include it so the dbm.dumb backend is used instead,
@@ -539,7 +535,6 @@ sha256sums=('ddcc1df16bb5b87aa42ec5d20a5b902f2d088caa269b28e01590f97a798ec50a'
'a9977459a8e6c31f1643da7ede6ac7199dee96559d74188f5c9d3799787ac4fa'
'7bab1dfb1d5b288e3270a61f9b1892c151f1dd1f8e32c07ae6adc37ef14844bb'
'551047905350e113384f99e0e929e9381dc0a4ed514ca4ebe279dcdad798edce'
'5e1ce61087a5f4acbd45cd7afca45744fa7df44b906eaf155dc519f870203360'
'1da319664d39427156488b9b39ff39e33c53ef608f66319fdf9fb9bcdb29020d'
'fc6164a90f0ca2a9341aaf4448b4334c3393459ca5cbad6d7149f8bcf70da5fe'
'181672743d9e2449064a1b18764fa400af5d3cd268098e7b7e5069d0b128caa2'


+ 1
- 0
setup/env.sh View File

@@ -121,6 +121,7 @@ fi
TARGET_AR="${TOOLCHAIN_PREFIX_}ar"
TARGET_CC="${TOOLCHAIN_PREFIX_}gcc"
TARGET_CXX="${TOOLCHAIN_PREFIX_}g++"
TARGET_DLLWRAP="${TOOLCHAIN_PREFIX_}dllwrap"
TARGET_LD="${TOOLCHAIN_PREFIX_}ld"
TARGET_STRIP="${TOOLCHAIN_PREFIX_}strip"
TARGET_PATH="${PAWPAW_PREFIX}/bin:/usr/${TOOLCHAIN_PREFIX}/bin:${PATH}"


+ 2
- 0
setup/functions.sh View File

@@ -80,6 +80,7 @@ function _prebuild() {
export AR="${TARGET_AR}"
export CC="${TARGET_CC}"
export CXX="${TARGET_CXX}"
export DLLWRAP="${TARGET_DLLWRAP}"
export LD="${TARGET_LD}"
export STRIP="${TARGET_STRIP}"
export CFLAGS="${TARGET_CFLAGS} ${EXTRA_CFLAGS}"
@@ -129,6 +130,7 @@ function _postbuild() {
unset AR
unset CC
unset CXX
unset DLLWRAP
unset LD
unset STRIP
unset CFLAGS


Loading…
Cancel
Save