From a5d9803f307d10371b93417304b557bec472eca8 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sat, 29 Sep 2018 18:55:20 +0200 Subject: [PATCH] sigrok-cross-mingw: Fix broken Windows 64bit decoding (bug #1195). --- cross-compile/mingw/pyconfig.patch | 37 ++++++++++++++++++++++++++ cross-compile/mingw/sigrok-cross-mingw | 5 ++++ 2 files changed, 42 insertions(+) create mode 100644 cross-compile/mingw/pyconfig.patch diff --git a/cross-compile/mingw/pyconfig.patch b/cross-compile/mingw/pyconfig.patch new file mode 100644 index 0000000..a5ffb1c --- /dev/null +++ b/cross-compile/mingw/pyconfig.patch @@ -0,0 +1,37 @@ +Fix for bug #1195. + +Patch taken from the MSYS2 MINGW-packages repo, filename +0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch, +but applied to pyconfig.h instead of pyport.h. + +Without this, Py_ssize_t ends up being 4 on 64bit Windows (where it +should be 8) and all kinds of weird issues happen as a result, +including 4GB allocations for no apparent reason, and none of the +protocol decoders working (at all). + +The respective Py_ssize_t related code is in pyport.h. + +--- pyconfig.h.orig 2018-09-29 18:06:33.625204450 +0200 ++++ pyconfig.h 2018-09-29 18:34:09.165488139 +0200 +@@ -1,6 +1,21 @@ + #ifndef Py_CONFIG_H + #define Py_CONFIG_H + ++#ifdef __MINGW32__ ++/* Translate GCC[mingw*] platform specific defines to those ++ * used in python code. ++ */ ++#if !defined(MS_WIN64) && defined(_WIN64) ++# define MS_WIN64 ++#endif ++#if !defined(MS_WIN32) && defined(_WIN32) ++# define MS_WIN32 ++#endif ++#if !defined(MS_WINDOWS) && defined(MS_WIN32) ++# define MS_WINDOWS ++#endif ++#endif /* __MINGW32__*/ ++ + /* pyconfig.h. NOT Generated automatically by configure. + + This is a manually maintained version used for the Watcom, diff --git a/cross-compile/mingw/sigrok-cross-mingw b/cross-compile/mingw/sigrok-cross-mingw index 8330406..81b03e6 100755 --- a/cross-compile/mingw/sigrok-cross-mingw +++ b/cross-compile/mingw/sigrok-cross-mingw @@ -106,6 +106,11 @@ mkdir -p $PREFIX $WGET http://www.sigrok.org/tmp/Python34_$TARGET.tar.gz -O $PREFIX/Python34.tar.gz tar xzf $PREFIX/Python34.tar.gz -C $PREFIX +# Fix for bug #1195. +if [ $TARGET = "x86_64" ]; then + patch -p1 $PREFIX/Python34/include/pyconfig.h < ../pyconfig.patch +fi + # Create a dummy python3.pc file so that pkg-config finds Python 3. mkdir -p $PREFIX/lib/pkgconfig cat >$PREFIX/lib/pkgconfig/python3.pc <