summaryrefslogtreecommitdiff
path: root/repo/python
diff options
context:
space:
mode:
Diffstat (limited to 'repo/python')
-rw-r--r--repo/python/arm-alignment.patch17
-rw-r--r--repo/python/custom-bluetooth-h-path.patch63
-rw-r--r--repo/python/fix-xattrs-glibc.patch15
-rw-r--r--repo/python/musl-find_library.patch45
-rw-r--r--repo/python/python.xibuild11
5 files changed, 149 insertions, 2 deletions
diff --git a/repo/python/arm-alignment.patch b/repo/python/arm-alignment.patch
new file mode 100644
index 0000000..a7a4b39
--- /dev/null
+++ b/repo/python/arm-alignment.patch
@@ -0,0 +1,17 @@
+Author: Dave Jones <dave.jones@canonical.com>
+Description: Use aligned access for _sha3 module on ARM.
+--- a/Modules/_sha3/sha3module.c
++++ b/Modules/_sha3/sha3module.c
+@@ -64,6 +64,12 @@
+ #define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
+ #endif
+
++/* Bus error on 32-bit ARM due to un-aligned memory accesses; 64-bit ARM
++ * doesn't complain but un-aligned memory accesses are sub-optimal */
++#if defined(__arm__) || defined(__aarch64__)
++#define NO_MISALIGNED_ACCESSES
++#endif
++
+ /* mangle names */
+ #define KeccakF1600_FastLoop_Absorb _PySHA3_KeccakF1600_FastLoop_Absorb
+ #define Keccak_HashFinal _PySHA3_Keccak_HashFinal
diff --git a/repo/python/custom-bluetooth-h-path.patch b/repo/python/custom-bluetooth-h-path.patch
new file mode 100644
index 0000000..3d836e3
--- /dev/null
+++ b/repo/python/custom-bluetooth-h-path.patch
@@ -0,0 +1,63 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -2223,17 +2223,28 @@
+ sys/param.h sys/random.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \
+ sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \
+ sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
+-libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
++libutil.h sys/resource.h netpacket/packet.h sysexits.h \
+ linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \
+ sys/endian.h sys/sysmacros.h linux/auxvec.h sys/auxv.h linux/memfd.h linux/wait.h sys/memfd.h \
+ sys/mman.h sys/eventfd.h)
+ AC_HEADER_DIRENT
+ AC_HEADER_MAJOR
+
++AC_ARG_WITH([bluetoothdir],
++ [AS_HELP_STRING([--with-bluetoothdir=DIR], [Path to bluetooth/bluetooth.h header])],
++ [bluetoothdir=$withval],
++ [bluetoothdir=""])
++
++if test "$bluetoothdir" != ""
++then
++ BLUETOOTH_CFLAGS="-I$bluetoothdir"
++ AC_SUBST([BLUETOOTH_CFLAGS], [$BLUETOOTH_CFLAGS])
++fi
++
+ # bluetooth/bluetooth.h has been known to not compile with -std=c99.
+ # http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
+ SAVE_CFLAGS=$CFLAGS
+-CFLAGS="-std=c99 $CFLAGS"
++CFLAGS="-std=c99 $CFLAGS $BLUETOOTH_CFLAGS"
+ AC_CHECK_HEADERS(bluetooth/bluetooth.h)
+ CFLAGS=$SAVE_CFLAGS
+
+diff --git a/setup.py b/setup.py
+index bd5f736..9381135 100644
+--- a/setup.py
++++ b/setup.py
+@@ -1221,13 +1221,16 @@ class PyBuildExt(build_ext):
+ self.add(Extension('_crypt', ['_cryptmodule.c'], libraries=libs))
+
+ def detect_socket(self):
++ bluetooth_includes = [@bluetoothdir@]
+ # socket(2)
+ kwargs = {'depends': ['socketmodule.h']}
+ if MACOS:
+ # Issue #35569: Expose RFC 3542 socket options.
+ kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542']
+
+- self.add(Extension('_socket', ['socketmodule.c'], **kwargs))
++ self.add(Extension('_socket', ['socketmodule.c'],
++ include_dirs=bluetooth_includes,
++ **kwargs))
+
+ def detect_dbm_gdbm(self):
+ # Modules that provide persistent dictionary-like semantics. You will
+@@ -2435,6 +2438,7 @@ class PyBuildExt(build_ext):
+ return [v.strip() for v in value.split(sep) if v.strip()]
+
+ openssl_includes = split_var('OPENSSL_INCLUDES', '-I')
++ openssl_includes = openssl_includes + (@bluetoothdir@,)
+ openssl_libdirs = split_var('OPENSSL_LDFLAGS', '-L')
+ openssl_libs = split_var('OPENSSL_LIBS', '-l')
+ openssl_rpath = config_vars.get('OPENSSL_RPATH')
diff --git a/repo/python/fix-xattrs-glibc.patch b/repo/python/fix-xattrs-glibc.patch
new file mode 100644
index 0000000..871236f
--- /dev/null
+++ b/repo/python/fix-xattrs-glibc.patch
@@ -0,0 +1,15 @@
+diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
+index 12f72f5..d54d085 100644
+--- a/Modules/posixmodule.c
++++ b/Modules/posixmodule.c
+@@ -234,8 +234,9 @@ corresponding Unix manual entries for more information on calls.");
+ # undef HAVE_SCHED_SETAFFINITY
+ #endif
+
+-#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
++#if defined(HAVE_SYS_XATTR_H) && defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
+ # define USE_XATTRS
++# include <linux/limits.h>
+ #endif
+
+ #ifdef USE_XATTRS
diff --git a/repo/python/musl-find_library.patch b/repo/python/musl-find_library.patch
new file mode 100644
index 0000000..7899abb
--- /dev/null
+++ b/repo/python/musl-find_library.patch
@@ -0,0 +1,45 @@
+diff -ru Python-2.7.12.orig/Lib/ctypes/util.py Python-2.7.12/Lib/ctypes/util.py
+--- Python-2.7.12.orig/Lib/ctypes/util.py 2016-06-26 00:49:30.000000000 +0300
++++ Python-2.7.12/Lib/ctypes/util.py 2016-11-03 16:05:46.954665040 +0200
+@@ -204,6 +204,41 @@
+ def find_library(name, is64 = False):
+ return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
+
++ elif True:
++
++ # Patched for Alpine Linux / musl - search manually system paths
++ def _is_elf(filepath):
++ try:
++ with open(filepath, 'rb') as fh:
++ return fh.read(4) == b'\x7fELF'
++ except:
++ return False
++
++ def find_library(name):
++ from glob import glob
++ # absolute name?
++ if os.path.isabs(name):
++ return name
++ # special case for libm, libcrypt and libpthread and musl
++ if name in ['m', 'crypt', 'pthread']:
++ name = 'c'
++ elif name in ['libm.so', 'libcrypt.so', 'libpthread.so']:
++ name = 'libc.so'
++ # search in standard locations (musl order)
++ paths = ['/lib', '/usr/local/lib', '/usr/lib']
++ if 'LD_LIBRARY_PATH' in os.environ:
++ paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
++ for d in paths:
++ f = os.path.join(d, name)
++ if _is_elf(f):
++ return os.path.basename(f)
++
++ prefix = os.path.join(d, 'lib'+name)
++ for suffix in ['.so', '.so.*']:
++ for f in glob('{0}{1}'.format(prefix, suffix)):
++ if _is_elf(f):
++ return os.path.basename(f)
++
+ else:
+
+ def _findSoname_ldconfig(name):
diff --git a/repo/python/python.xibuild b/repo/python/python.xibuild
index d01fe00..039167d 100644
--- a/repo/python/python.xibuild
+++ b/repo/python/python.xibuild
@@ -5,16 +5,23 @@ MAKEDEPS="make autoconf automake autoconf-archive sqlite3 expat bzip2 gdbm libff
PKG_VER=3.10.7
SOURCE=https://www.python.org/ftp/python/$PKG_VER/Python-$PKG_VER.tgz
DESC="The Python development environment"
+ADDITIONAL="
+fix-xattrs-glibc.patch
+musl-find_library.patch
+"
prepare () {
+ apply_patches
rm -r Modules/expat
rm -r Modules/_ctypes/darwin*
rm -r Modules/_ctypes/libffi*
+ sed -i -e "s|-flto |-flto=4 |g" configure configure.ac
+
+ GREP="/usr/bin/grep" autoreconf -fi
}
build () {
- autoreconf -i
- GREP="/usr/bin/ggrep" ./configure --prefix=/usr \
+ GREP="/usr/bin/grep" ./configure --prefix=/usr \
--enable-shared \
--with-system-expat \
--with-system-ffi \