From 5ce8098c25e2135ba47718f46f48f6005ddde426 Mon Sep 17 00:00:00 2001 From: Robert Kirkman Date: Mon, 28 Apr 2025 01:37:03 -0500 Subject: [PATCH] bump(main/pypy3): 7.3.19 - Large amount of changes, see GitHub PR description for details - Also touches `python2` --- ...d-wait3-function-for-resource-module.patch | 10 +- packages/pypy3/0004-fix-loaded-libs.patch | 62 +-- .../0005-fix-unavailable-functions.patch | 114 ++--- ...o-not-try-to-get-L2-cache-on-aarch64.patch | 11 + packages/pypy3/0006-package-zip.patch | 10 - ...-do-not-use-wno-discarded-qualifiers.patch | 10 + packages/pypy3/0007-termux-build.patch | 64 --- ...t-cffi-dlopen-when-compiling-sqlite3.patch | 10 - .../pypy3/0008-fix-ctypes-find_library.patch | 37 ++ packages/pypy3/0010-dummy-cpu_count.patch | 14 - ...0-set-_FILE_OFFSET_BITS-to-64-on-arm.patch | 17 + packages/pypy3/build.sh | 457 +++++++----------- packages/pypy3/cc.sh | 7 - packages/pypy3/pypy3-tests.subpackage.sh | 10 +- packages/pypy3/pypy3-tkinter.subpackage.sh | 6 +- packages/pypy3/termux.py.in | 146 ------ packages/python2/build.sh | 6 +- packages/python2/fix-ctypes-find_library.diff | 40 ++ 18 files changed, 411 insertions(+), 620 deletions(-) create mode 100644 packages/pypy3/0006-do-not-try-to-get-L2-cache-on-aarch64.patch delete mode 100644 packages/pypy3/0006-package-zip.patch create mode 100644 packages/pypy3/0007-do-not-use-wno-discarded-qualifiers.patch delete mode 100644 packages/pypy3/0007-termux-build.patch delete mode 100644 packages/pypy3/0008-do-not-cffi-dlopen-when-compiling-sqlite3.patch create mode 100644 packages/pypy3/0008-fix-ctypes-find_library.patch delete mode 100644 packages/pypy3/0010-dummy-cpu_count.patch create mode 100644 packages/pypy3/0010-set-_FILE_OFFSET_BITS-to-64-on-arm.patch delete mode 100644 packages/pypy3/cc.sh delete mode 100644 packages/pypy3/termux.py.in create mode 100644 packages/python2/fix-ctypes-find_library.diff diff --git a/packages/pypy3/0001-add-wait3-function-for-resource-module.patch b/packages/pypy3/0001-add-wait3-function-for-resource-module.patch index 44bc824d4091fe..c0f75afb70e79e 100644 --- a/packages/pypy3/0001-add-wait3-function-for-resource-module.patch +++ b/packages/pypy3/0001-add-wait3-function-for-resource-module.patch @@ -1,7 +1,11 @@ --- a/lib_pypy/_resource_build.py +++ b/lib_pypy/_resource_build.py -@@ -75,2 +75,4 @@ - +@@ -73,6 +73,8 @@ static int my_setrlimit(int resource, long long cur, long long max) + rl.rlim_max = max & RLIM_INFINITY; + return setrlimit(resource, &rl); + } +/* Termux addition: Add wait3() declaration used by busybox. Available in libc for 32-bit only. */ +static pid_t wait3(int* status, int options, struct rusage* rusage) { return wait4(-1, status, options, rusage); } - """.replace('$RLIMIT_CONSTS', ''.join(rlimit_consts))) + """.replace('$RLIMIT_CONSTS', ''.join(rlimit_consts)) + + diff --git a/packages/pypy3/0004-fix-loaded-libs.patch b/packages/pypy3/0004-fix-loaded-libs.patch index 5eecd0f9bd839c..3a990f855c2731 100644 --- a/packages/pypy3/0004-fix-loaded-libs.patch +++ b/packages/pypy3/0004-fix-loaded-libs.patch @@ -1,26 +1,34 @@ +diff --git a/lib_pypy/_audioop_build.py b/lib_pypy/_audioop_build.py +index 64d32f4e9e..3c19353671 100644 --- a/lib_pypy/_audioop_build.py +++ b/lib_pypy/_audioop_build.py -@@ -629,3 +629,3 @@ - +@@ -665,7 +665,7 @@ void adcpm2lin(unsigned char* ncp, unsigned char* cp, size_t len, + } + """ + -ffi.set_source("_audioop_cffi", C_SOURCE) +ffi.set_source("_audioop_cffi", C_SOURCE, libraries=["m"]) - + + if __name__ == "__main__": + import sys +diff --git a/lib_pypy/_syslog_build.py b/lib_pypy/_syslog_build.py +index 86c9533240..1cf5ac9e3e 100644 --- a/lib_pypy/_syslog_build.py +++ b/lib_pypy/_syslog_build.py -@@ -23,7 +23,7 @@ +@@ -23,7 +23,7 @@ ffi.set_source("_syslog_cffi", """ #ifndef LOG_NEWS #define LOG_NEWS LOG_MAIL #endif -""") +""", libraries=['log']) - + ffi.cdef(""" /* mandatory constants */ - - +diff --git a/lib_pypy/_dbm.py b/lib_pypy/_dbm.py +index 3c8f64317d..d94714cc9a 100644 --- a/lib_pypy/_dbm.py +++ b/lib_pypy/_dbm.py -@@ -123,7 +123,9 @@ +@@ -145,7 +145,9 @@ def _init_func(name, argtypes=None, restype=None): func.restype = restype if sys.platform != 'darwin': @@ -31,23 +39,24 @@ if not libpath: # XXX this is hopeless... for c in ['5.3', '5.2', '5.1', '5.0', '4.9', '4.8', '4.7', '4.6', '4.5']: - - +diff --git a/pypy/module/_multiprocessing/interp_semaphore.py b/pypy/module/_multiprocessing/interp_semaphore.py +index 769aea073b..dce52ae983 100644 --- a/pypy/module/_multiprocessing/interp_semaphore.py +++ b/pypy/module/_multiprocessing/interp_semaphore.py -@@ -43,7 +43,7 @@ +@@ -43,7 +43,7 @@ else: if sys.platform == 'darwin': libraries = [] else: - libraries = ['rt'] + libraries = ['android-posix-semaphore'] - + eci = ExternalCompilationInfo( includes = ['sys/time.h', - +diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py +index e96571e342..e3d68c7056 100644 --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py -@@ -212,7 +212,7 @@ +@@ -212,7 +212,7 @@ else: includes.append('sys/sysmacros.h') if sys.platform.startswith('freebsd') or sys.platform.startswith('openbsd'): includes.append('sys/ttycom.h') @@ -56,31 +65,31 @@ eci = ExternalCompilationInfo( includes=includes, - -@@ -2094,6 +2094,8 @@ - locals()['HAVE_%s' % _name.upper()] = rffi_platform.Has(_name) - cConfig = rffi_platform.configure(CConfig) +@@ -2179,6 +2179,8 @@ if _LINUX: + # always returns an error. + cConfig["HAVE_LCHMOD"] = False globals().update(cConfig) +# Remove faccessat, linkat +HAVE_FACCESSAT = HAVE_LINKAT = False if not _WIN32: class CConfig: - +diff --git a/rpython/rlib/rtime.py b/rpython/rlib/rtime.py +index 2cc070daef..4fcc1a311c 100644 --- a/rpython/rlib/rtime.py +++ b/rpython/rlib/rtime.py -@@ -29,10 +29,6 @@ +@@ -29,10 +29,6 @@ else: 'sys/types.h', 'unistd.h', 'sys/time.h', 'sys/resource.h'] - + - if not sys.platform.startswith("openbsd") and \ - not sys.platform.startswith("freebsd"): - includes.append('sys/timeb.h') - need_rusage = True - - -@@ -51,7 +47,7 @@ + + +@@ -58,7 +54,7 @@ class CConfig: if sys.platform.startswith('freebsd') or sys.platform.startswith('netbsd'): libraries = ['compat'] elif sys.platform == 'linux2': @@ -88,8 +97,8 @@ + libraries = ['c'] else: libraries = [] - -@@ -198,7 +194,7 @@ + +@@ -209,7 +205,7 @@ if HAS_CLOCK_GETTIME_RUNTIME: # do we need to add -lrt? eciclock = CConfigForClockGetTime._compilation_info_ if not _NO_MISSING_RT: @@ -98,4 +107,3 @@ # the functions: c_clock_getres = external("clock_getres", [lltype.Signed, lltype.Ptr(TIMESPEC)], - diff --git a/packages/pypy3/0005-fix-unavailable-functions.patch b/packages/pypy3/0005-fix-unavailable-functions.patch index 3b252a85431049..63d05a533749af 100644 --- a/packages/pypy3/0005-fix-unavailable-functions.patch +++ b/packages/pypy3/0005-fix-unavailable-functions.patch @@ -1,6 +1,8 @@ +diff --git a/lib-python/3/http/server.py b/lib-python/3/http/server.py +index da07f110f1..f87045d8c9 100644 --- a/lib-python/3/http/server.py +++ b/lib-python/3/http/server.py -@@ -1161,10 +1161,6 @@ +@@ -1182,10 +1182,6 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler): return # Child try: @@ -11,58 +13,58 @@ os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) os.execve(scriptfile, args, env) - +diff --git a/lib_pypy/_pwdgrp_build.py b/lib_pypy/_pwdgrp_build.py +index ddd32f3956..a70106ddae 100644 --- a/lib_pypy/_pwdgrp_build.py +++ b/lib_pypy/_pwdgrp_build.py -@@ -35,9 +35,9 @@ +@@ -35,10 +35,6 @@ struct group { struct passwd *getpwuid(uid_t uid); struct passwd *getpwnam(const char *name); - + -struct passwd *getpwent(void); -void setpwent(void); -void endpwent(void); -+// struct passwd *getpwent(void); -+// void setpwent(void); -+// void endpwent(void); - +- struct group *getgrgid(gid_t gid); struct group *getgrnam(const char *name); - + +diff --git a/lib-python/3/smtpd.py b/lib-python/3/smtpd.py +index b23579f120..dcf8c502dd 100755 --- a/lib-python/3/smtpd.py +++ b/lib-python/3/smtpd.py -@@ -9,7 +9,8 @@ +@@ -9,7 +9,8 @@ Options: -n This program generally tries to setuid `nobody', unless this flag is set. The setuid call will fail if this program is not run as root (in - which case, use this flag). + which case, use this flag). Ignored in Termux as no setuid done on this + platform. - + --version -V -@@ -861,7 +862,7 @@ - - +@@ -781,7 +782,7 @@ class PureProxy(SMTPServer): + + class Options: - setuid = True + setuid = False classname = 'PureProxy' size_limit = None enable_SMTPUTF8 = False - - +diff --git a/pypy/module/pwd/interp_pwd.py b/pypy/module/pwd/interp_pwd.py +index 413aa41056..3d07f5459f 100644 --- a/pypy/module/pwd/interp_pwd.py +++ b/pypy/module/pwd/interp_pwd.py -@@ -19,18 +19,25 @@ +@@ -19,18 +19,25 @@ config = rffi_platform.configure(CConfig) uid_t = config['uid_t'] gid_t = config['gid_t'] - + -class CConfig: - _compilation_info_ = eci +# Android bionic libc has a different define for passwd. +# On LP32, it defines pw_gecos to pw_passwd since they're both NULL. +DEFINED__LP64__ = rffi_platform.getdefined('__LP64__', '') - + - passwd = rffi_platform.Struct( - 'struct passwd', - [('pw_name', rffi.CCHARP), @@ -82,11 +84,11 @@ + _compilation_info_ = eci + + passwd = rffi_platform.Struct('struct passwd', fields) - + config = rffi_platform.configure(CConfig) - -@@ -42,9 +49,10 @@ - + +@@ -42,9 +49,10 @@ def external(name, args, result, **kwargs): + c_getpwuid = external("getpwuid", [uid_t], passwd_p) c_getpwnam = external("getpwnam", [rffi.CCHARP], passwd_p) -c_setpwent = external("setpwent", [], lltype.Void) @@ -96,10 +98,10 @@ +# c_setpwent = external("setpwent", [], lltype.Void) +# c_getpwent = external("getpwent", [], passwd_p) +# c_endpwent = external("endpwent", [], lltype.Void) - - + + def uid_converter(space, w_uid): -@@ -80,7 +88,7 @@ +@@ -80,7 +88,7 @@ def make_struct_passwd(space, pw): space.newtext(rffi.charp2str(pw.c_pw_passwd)), space.int(space.newint(pw.c_pw_uid)), space.int(space.newint(pw.c_pw_gid)), @@ -108,10 +110,10 @@ space.newtext(rffi.charp2str(pw.c_pw_dir)), space.newtext(rffi.charp2str(pw.c_pw_shell)), ]) -@@ -120,15 +128,15 @@ +@@ -120,15 +128,3 @@ def getpwnam(space, name): raise oefmt(space.w_KeyError, "getpwnam(): name not found: %s", name) return make_struct_passwd(space, pw) - + -def getpwall(space): - users_w = [] - c_setpwent() @@ -124,63 +126,51 @@ - finally: - c_endpwent() - return space.newlist(users_w) -+# def getpwall(space): -+# users_w = [] -+# c_setpwent() -+# try: -+# while True: -+# pw = c_getpwent() -+# if not pw: -+# break -+# users_w.append(make_struct_passwd(space, pw)) -+# finally: -+# c_endpwent() -+# return space.newlist(users_w) - +diff --git a/pypy/module/pwd/moduledef.py b/pypy/module/pwd/moduledef.py +index b9c3f7114a..d7dc42847c 100644 --- a/pypy/module/pwd/moduledef.py +++ b/pypy/module/pwd/moduledef.py -@@ -15,11 +15,11 @@ +@@ -15,11 +15,9 @@ class Module(MixedModule): interpleveldefs = { 'getpwuid': 'interp_pwd.getpwuid', 'getpwnam': 'interp_pwd.getpwnam', - 'getpwall': 'interp_pwd.getpwall', -+ # 'getpwall': 'interp_pwd.getpwall', } - + appleveldefs = { 'struct_passwd': 'app_pwd.struct_passwd', - 'struct_pwent': 'app_pwd.struct_passwd', -+ # 'struct_pwent': 'app_pwd.struct_passwd', } - + +diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py +index 4486fd0196..a2b1385710 100644 --- a/rpython/rlib/rvmprof/cintf.py +++ b/rpython/rlib/rvmprof/cintf.py -@@ -16,14 +16,14 @@ +@@ -18,18 +18,9 @@ from rpython.jit.backend import detect_cpu class VMProfPlatformUnsupported(Exception): pass - + -# vmprof works only on x86 for now +# vmprof cannot compile on termux due to no dlinfo on Bionic Libc IS_SUPPORTED = False + NATIVE_PROFILING_SUPPORTED = False -if sys.platform in ('darwin', 'linux', 'linux2') or sys.platform.startswith('freebsd'): - try: - proc = detect_cpu.autodetect() -- IS_SUPPORTED = proc.startswith('x86') or proc == 'aarch64' +- IS_SUPPORTED = (proc.startswith('x86') +- or proc == 'aarch64' +- or proc == 'riscv64') +- NATIVE_PROFILING_SUPPORTED = proc.startswith('x86') - except detect_cpu.ProcessorAutodetectError: - print("PROCESSOR NOT DETECTED, SKIPPING VMPROF") -+# if sys.platform in ('darwin', 'linux', 'linux2') or sys.platform.startswith('freebsd'): -+# try: -+# proc = detect_cpu.autodetect() -+# IS_SUPPORTED = proc.startswith('x86') or proc == 'aarch64' -+# except detect_cpu.ProcessorAutodetectError: -+# print("PROCESSOR NOT DETECTED, SKIPPING VMPROF") - + ROOT = py.path.local(rpythonroot).join('rpython', 'rlib', 'rvmprof') SRC = ROOT.join('src') - +diff --git a/pypy/module/posix/moduledef.py b/pypy/module/posix/moduledef.py +index 6e92b3199d..7b5b81559f 100644 --- a/pypy/module/posix/moduledef.py +++ b/pypy/module/posix/moduledef.py -@@ -140,12 +140,12 @@ +@@ -142,12 +142,12 @@ corresponding Unix manual entries for more information on calls.""" interpleveldefs['pathconf_names'] = 'space.wrap(interp_posix.pathconf_names())' if hasattr(os, 'pathconf'): interpleveldefs['pathconf'] = 'interp_posix.pathconf' @@ -195,14 +185,16 @@ interpleveldefs['getloadavg'] = 'interp_posix.getloadavg' if hasattr(os, 'makedev'): interpleveldefs['makedev'] = 'interp_posix.makedev' +diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py +index e96571e342..1dd8055a12 100644 --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py -@@ -3049,7 +3049,7 @@ +@@ -3096,7 +3098,7 @@ elif not _WIN32: # ____________________________________________________________ # Support for *xattr functions - + -if sys.platform.startswith('linux'): +if False: - + class CConfig: _compilation_info_ = ExternalCompilationInfo( diff --git a/packages/pypy3/0006-do-not-try-to-get-L2-cache-on-aarch64.patch b/packages/pypy3/0006-do-not-try-to-get-L2-cache-on-aarch64.patch new file mode 100644 index 00000000000000..3359b4ea142126 --- /dev/null +++ b/packages/pypy3/0006-do-not-try-to-get-L2-cache-on-aarch64.patch @@ -0,0 +1,11 @@ +--- a/rpython/memory/gc/env.py ++++ b/rpython/memory/gc/env.py +@@ -140,7 +140,7 @@ + return get_L2cache_linux2_cpuinfo(label='L2 cache') + #if arch == 's390x': untested + # return get_L2cache_linux2_cpuinfo_s390x() +- if arch in ('ia64', 'aarch64'): ++ if arch in ('ia64'): + return get_L2cache_linux2_system_cpu_index() + if arch in ('parisc', 'parisc64'): + return get_L2cache_linux2_cpuinfo(label='D-cache') diff --git a/packages/pypy3/0006-package-zip.patch b/packages/pypy3/0006-package-zip.patch deleted file mode 100644 index 2c2a1bd462f0e8..00000000000000 --- a/packages/pypy3/0006-package-zip.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/pypy/tool/release/package.py -+++ b/pypy/tool/release/package.py -@@ -35,7 +35,7 @@ - ARCH = get_arch() - - --USE_ZIPFILE_MODULE = ARCH == 'win32' -+USE_ZIPFILE_MODULE = True - - STDLIB_VER = "3" diff --git a/packages/pypy3/0007-do-not-use-wno-discarded-qualifiers.patch b/packages/pypy3/0007-do-not-use-wno-discarded-qualifiers.patch new file mode 100644 index 00000000000000..8038accbc34488 --- /dev/null +++ b/packages/pypy3/0007-do-not-use-wno-discarded-qualifiers.patch @@ -0,0 +1,10 @@ +--- a/rpython/translator/platform/linux.py ++++ b/rpython/translator/platform/linux.py +@@ -15,7 +15,6 @@ class Linux(BasePosix): + cflags = tuple( + ['-O3', '-pthread', '-fomit-frame-pointer', + '-Wall', '-Wno-unused', '-Wno-address', +- '-Wno-discarded-qualifiers', # RPyField does not know about const + # The parser turns 'const char *const *includes' into 'const const char **includes' + '-Wno-duplicate-decl-specifier', + # These make older gcc behave like gcc-14 diff --git a/packages/pypy3/0007-termux-build.patch b/packages/pypy3/0007-termux-build.patch deleted file mode 100644 index 3ab6907ad4164a..00000000000000 --- a/packages/pypy3/0007-termux-build.patch +++ /dev/null @@ -1,64 +0,0 @@ ---- a/rpython/config/translationoption.py -+++ b/rpython/config/translationoption.py -@@ -40,6 +40,10 @@ - PLATFORMS = [ - 'host', - 'arm', -+ 'termux-aarch64', -+ 'termux-arm', -+ 'termux-x86_64', -+ 'termux-i686', - ] - - translation_optiondescription = OptionDescription( -@@ -285,8 +289,17 @@ - ChoiceOption("platform", - "target platform", ['host'] + PLATFORMS, default='host', - cmdline='--platform', -- suggests={"arm": [("translation.gcrootfinder", "shadowstack"), -- ("translation.jit_backend", "arm")]}), -+ suggests={ "arm": [("translation.gcrootfinder", "shadowstack"), -+ ("translation.jit_backend", "arm")], -+ "termux-aarch64": [("translation.gcrootfinder", "shadowstack"), -+ ("translation.jit_backend", "auto")], -+ "termux-arm": [("translation.gcrootfinder", "shadowstack"), -+ ("translation.jit_backend", "arm")], -+ "termux-x86_64": [("translation.gcrootfinder", "shadowstack"), -+ ("translation.jit_backend", "auto")], -+ "termux-i686": [("translation.gcrootfinder", "shadowstack"), -+ ("translation.jit_backend", "auto")], -+ }), - - BoolOption("split_gc_address_space", - "Ensure full separation of GC and non-GC pointers", default=False), - ---- a/rpython/translator/platform/__init__.py -+++ b/rpython/translator/platform/__init__.py -@@ -332,6 +332,8 @@ - else: - raise ValueError('unknown sys.platform "%s"', sys.platform) - -+# Android always requires compiling with -fPIC -+host_factory = Linux - platform = host = host_factory() - - def pick_platform(new_platform, cc): -@@ -340,6 +342,18 @@ - elif new_platform == 'arm': - from rpython.translator.platform.arm import ARM - return ARM(cc) -+ elif new_platform == 'termux-aarch64': -+ from rpython.translator.platform.termux import Termux_AArch64 -+ return Termux_AArch64(cc) -+ elif new_platform == 'termux-arm': -+ from rpython.translator.platform.termux import Termux_ARM -+ return Termux_ARM(cc) -+ elif new_platform == 'termux-x86_64': -+ from rpython.translator.platform.termux import Termux_AMD64 -+ return Termux_AMD64(cc) -+ elif new_platform == 'termux-i686': -+ from rpython.translator.platform.termux import Termux_IA32 -+ return Termux_IA32(cc) - else: - raise ValueError("platform = %s" % (new_platform,)) - diff --git a/packages/pypy3/0008-do-not-cffi-dlopen-when-compiling-sqlite3.patch b/packages/pypy3/0008-do-not-cffi-dlopen-when-compiling-sqlite3.patch deleted file mode 100644 index 67154c306108e5..00000000000000 --- a/packages/pypy3/0008-do-not-cffi-dlopen-when-compiling-sqlite3.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/lib_pypy/_sqlite3_build.py -+++ b/lib_pypy/_sqlite3_build.py -@@ -229,6 +229,7 @@ - - def _has_load_extension(): - """Only available since 3.3.6""" -+ return True - unverified_ffi = _FFI() - unverified_ffi.cdef(""" - typedef ... sqlite3; diff --git a/packages/pypy3/0008-fix-ctypes-find_library.patch b/packages/pypy3/0008-fix-ctypes-find_library.patch new file mode 100644 index 00000000000000..724e934981fee4 --- /dev/null +++ b/packages/pypy3/0008-fix-ctypes-find_library.patch @@ -0,0 +1,37 @@ +$PREFIX/lib/libsqlite3.so, and some other libs that could hypothetically also be searched for, +do not have a SONAME entry inside them that objdump can detect, +so use the filename instead of calling objdump to get the SONAME for it. +(also Android does not have an ldconfig command, so this avoids calling /sbin/ldconfig +and getting unwanted references to libc.so.6 or libraries linked to it) + +Fixes: +OSError: ctypes.util.find_library() did not manage to locate a library called 'sqlite3' + +--- a/lib-python/3/ctypes/util.py ++++ b/lib-python/3/ctypes/util.py +@@ -304,7 +304,7 @@ elif os.name == "posix": + # See issue #9998 for why this is needed + expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) + cmd = ['ld', '-t'] +- libpath = os.environ.get('LD_LIBRARY_PATH') ++ libpath = os.environ.get('PREFIX') + '/lib' + if libpath: + for d in libpath.split(':'): + cmd.extend(['-L', d]) +@@ -328,9 +328,13 @@ elif os.name == "posix": + return result + + def find_library(name): +- # See issue #9998 +- return _findSoname_ldconfig(name) or \ +- _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name)) ++ try: ++ return os.path.basename(_findLib_gcc(name)) ++ except: ++ try: ++ return os.path.basename(_findLib_ld(name)) ++ except: ++ return None + + ################################################################ + # test code diff --git a/packages/pypy3/0010-dummy-cpu_count.patch b/packages/pypy3/0010-dummy-cpu_count.patch deleted file mode 100644 index 3fd76ac8d9fb6e..00000000000000 --- a/packages/pypy3/0010-dummy-cpu_count.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/lib_pypy/pypy_tools/build_cffi_imports.py -+++ b/lib_pypy/pypy_tools/build_cffi_imports.py -@@ -39,6 +39,11 @@ - ("xx", None), # for testing: 'None' should be completely ignored - ] - -+def fake_cpu_count(): -+ return 1 -+ -+multiprocessing.cpu_count = fake_cpu_count -+ - # for distribution, we may want to fetch dependencies not provided by - # the OS, such as a recent openssl/libressl. - curdir = os.path.abspath(os.path.dirname(__file__)) diff --git a/packages/pypy3/0010-set-_FILE_OFFSET_BITS-to-64-on-arm.patch b/packages/pypy3/0010-set-_FILE_OFFSET_BITS-to-64-on-arm.patch new file mode 100644 index 00000000000000..3aec6c4255471b --- /dev/null +++ b/packages/pypy3/0010-set-_FILE_OFFSET_BITS-to-64-on-arm.patch @@ -0,0 +1,17 @@ +Originated historically at the earliest in +https://github.com/termux/termux-packages/pull/23474#issuecomment-2683389623, +but is character for character convergently identical to the independently written +upstream commit, +https://github.com/stefanor/pypy/commit/7509998bdec6c5dd39cfdf069d06b46b157f47df + +--- a/rpython/translator/c/src/precommondefs.h ++++ b/rpython/translator/c/src/precommondefs.h +@@ -11,7 +11,7 @@ + /* Define on Darwin to activate all library features */ + #define _DARWIN_C_SOURCE 1 + /* These must be set to 64 to enable large file support on 32-bit systems. */ +-#if defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86) ++#if defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(__arm__) + #define _FILE_OFFSET_BITS 64 + #define _LARGEFILE_SOURCE 1 + #endif diff --git a/packages/pypy3/build.sh b/packages/pypy3/build.sh index f7fadc5a3efb84..4602527a7af425 100644 --- a/packages/pypy3/build.sh +++ b/packages/pypy3/build.sh @@ -2,16 +2,108 @@ TERMUX_PKG_HOMEPAGE=https://pypy.org TERMUX_PKG_DESCRIPTION="A fast, compliant alternative implementation of Python 3" TERMUX_PKG_LICENSE="MIT" TERMUX_PKG_MAINTAINER="@licy183" -_MAJOR_VERSION=3.9 -TERMUX_PKG_VERSION=7.3.15 -TERMUX_PKG_REVISION=4 +_MAJOR_VERSION=3.11 +TERMUX_PKG_VERSION="7.3.19" TERMUX_PKG_SRCURL=https://downloads.python.org/pypy/pypy$_MAJOR_VERSION-v$TERMUX_PKG_VERSION-src.tar.bz2 -TERMUX_PKG_SHA256=6bb9537d85aa7ad13c0aad2e41ff7fd55080bc9b4d1361b8f502df51db816e18 +TERMUX_PKG_SHA256=4817c044bb469a3274e60aa3645770f81eb4f9166ea7fdc4e6c351345554c8d8 +TERMUX_PKG_AUTO_UPDATE=true TERMUX_PKG_DEPENDS="gdbm, libandroid-posix-semaphore, libandroid-support, libbz2, libcrypt, libexpat, libffi, liblzma, libsqlite, ncurses, ncurses-ui-libs, openssl, zlib" -TERMUX_PKG_BUILD_DEPENDS="aosp-libs, coreutils, clang, make, pkg-config, python2, tk, xorgproto" +TERMUX_PKG_BUILD_DEPENDS="aosp-libs, python2, tk, xorgproto" TERMUX_PKG_RECOMMENDS="clang, make, pkg-config" TERMUX_PKG_SUGGESTS="pypy3-tkinter" TERMUX_PKG_BUILD_IN_SRC=true +# remove files generated as a result of running python2 inside proot +TERMUX_PKG_RM_AFTER_INSTALL=" +bin/easy_install-2* +bin/pip2* +lib/python2* +" + +install_package_from_root_repo() { + # based on the implementations of read_package_lists and pull_package in + # https://github.com/termux/termux-packages/blob/7a95ee9c2d0ee05e370d1cf951d9f75b4aef8677/scripts/generate-bootstraps.sh + + local package_to_download_name=$1 + local ROOTFS=$2 + declare -A PACKAGE_METADATA + declare -A PACKAGE_URLS + declare -A REPO_BASE_URLS=( + ["root"]="https://packages-cf.termux.dev/apt/termux-root/dists/root/stable" + ) + local PKGDIR="${TERMUX_PKG_CACHEDIR}/packages-${TERMUX_ARCH}" + local package_tmpdir="${PKGDIR}/${package_to_download_name}" + mkdir -p "$package_tmpdir" + + local architecture + for architecture in all "$TERMUX_ARCH"; do + for repository in "${!REPO_BASE_URLS[@]}"; do + REPO_BASE_URL="${REPO_BASE_URLS[${repository}]}" + if [ ! -e "${TERMUX_PKG_TMPDIR}/${repository}-packages.${architecture}" ]; then + echo "[*] Downloading ${repository} package list for architecture '${architecture}'..." + if ! curl --fail --location \ + --output "${TERMUX_PKG_TMPDIR}/${repository}-packages.${architecture}" \ + "${REPO_BASE_URL}/binary-${architecture}/Packages"; then + if [ "$architecture" = "all" ]; then + echo "[!] Skipping architecture-independent package list as not available..." + continue + fi + fi + echo >> "${TERMUX_PKG_TMPDIR}/${repository}-packages.${architecture}" + fi + + echo "[*] Reading ${repository} package list for '${architecture}'..." + while read -r -d $'\xFF' package; do + if [ -n "$package" ]; then + local package_name + package_name=$(echo "$package" | grep -i "^Package:" | awk '{ print $2 }') + package_url="$(dirname "$(dirname "$(dirname "${REPO_BASE_URL}")")")"/"$(echo "${package}" | \ + grep -i "^Filename:" | awk '{ print $2 }')" + + if [ -z "${PACKAGE_METADATA["$package_name"]-}" ]; then + PACKAGE_METADATA["$package_name"]="$package" + PACKAGE_URLS["$package_name"]="$package_url" + else + local prev_package_ver cur_package_ver + cur_package_ver=$(echo "$package" | grep -i "^Version:" | awk '{ print $2 }') + prev_package_ver=$(echo "${PACKAGE_METADATA["$package_name"]}" | grep -i "^Version:" | awk '{ print $2 }') + + # If package has multiple versions, make sure that our metadata + # contains the latest one. + if [ "$(echo -e "${prev_package_ver}\n${cur_package_ver}" | sort -rV | head -n1)" = "${cur_package_ver}" ]; then + PACKAGE_METADATA["$package_name"]="$package" + PACKAGE_URLS["$package_name"]="$package_url" + fi + fi + fi + done < <(sed -e "s/^$/\xFF/g" "${TERMUX_PKG_TMPDIR}/${repository}-packages.${architecture}") + done + done + local package_to_download_url="${PACKAGE_URLS[${package_to_download_name}]}" + + # (dependencies skipped in this case because dnsmasq has no dependencies) + + echo "[*] Downloading '$package_to_download_name'..." + termux_download "$package_to_download_url" "$package_tmpdir/package.deb" SKIP_CHECKSUM + + echo "[*] Extracting '$package_to_download_name'..." + ( + cd "$package_tmpdir" + ar x package.deb + + # data.tar may have extension different from .xz + if [ -f "./data.tar.xz" ]; then + data_archive="data.tar.xz" + elif [ -f "./data.tar.gz" ]; then + data_archive="data.tar.gz" + else + termux_error_exit "No data.tar.* found in '$package_to_download_name'." + fi + + # Extract files + # (in this case stripping all 6 leading components /data/data/com.termux/files/usr) + tar xf "$data_archive" --strip-components=6 -C "$ROOTFS" + ) +} termux_step_post_get_source() { local p="$TERMUX_PKG_BUILDER_DIR/9998-link-against-pypy3-on-testcapi.diff" @@ -23,310 +115,137 @@ termux_step_post_get_source() { echo "Applying $(basename "${p}")" sed 's|@TERMUX_PKG_API_LEVEL@|'"${TERMUX_PKG_API_LEVEL}"'|g' "${p}" \ | patch --silent -p1 - - sed -e "s|@TERMUX_PREFIX@|${TERMUX_PREFIX}|g" \ - "$TERMUX_PKG_BUILDER_DIR"/termux.py.in > \ - "$TERMUX_PKG_SRCDIR"/rpython/translator/platform/termux.py } -termux_step_pre_configure() { - if $TERMUX_ON_DEVICE_BUILD; then - termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds." +__setup_termux_envs() { + __pypy3_run_on_target_from_builder="" + # translation step only reads CFLAGS from environment, + # not CPPFLAGS, so combine them + export CFLAGS+=" $CPPFLAGS" + export CFLAGS+=" -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD=1" + export MAKEFLAGS="-j$TERMUX_PKG_MAKE_PROCESSES" + export PYPY_MULTIARCH="$TERMUX_HOST_PLATFORM" + export PYPY_USESSION_DIR="$TERMUX_PKG_SRCDIR/usession-dir" + + if [[ "$TERMUX_ON_DEVICE_BUILD" == "true" ]]; then + return fi -} -__setup_proot() { - mkdir -p "$TERMUX_PKG_CACHEDIR"/proot-bin - termux_download \ - https://github.com/proot-me/proot/releases/download/v5.3.0/proot-v5.3.0-x86_64-static \ - "$TERMUX_PKG_CACHEDIR"/proot-bin/proot \ - d1eb20cb201e6df08d707023efb000623ff7c10d6574839d7bb42d0adba6b4da - chmod +x "$TERMUX_PKG_CACHEDIR"/proot-bin/proot - mkdir -p "$TERMUX_PKG_TMPDIR"/proot-tmp-dir - export PATH="$TERMUX_PKG_CACHEDIR/proot-bin:$PATH" -} + __pypy3_run_on_target_from_builder="__pypy3_termux_proot_run" + + mkdir -p "$PYPY_USESSION_DIR" + + if [[ ! -d "$TERMUX_PKG_CACHEDIR/proot-additions" ]]; then + mkdir -p "$TERMUX_PKG_CACHEDIR/proot-additions/bin" + ln -sf $(command -v llvm-strip) "$TERMUX_PKG_CACHEDIR/proot-additions/bin/strip" + # dnsmasq cannot be in TERMUX_PKG_BUILD_DEPENDS because it is in the root-packages folder, + # so it would cause the test-buildorder-random CI check to fail if there. + install_package_from_root_repo dnsmasq "$TERMUX_PKG_CACHEDIR/proot-additions" + fi -__setup_qemu_static_binaries() { - mkdir -p "$TERMUX_PKG_CACHEDIR"/qemu-static-bin - termux_download \ - https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-aarch64-static \ - "$TERMUX_PKG_CACHEDIR"/qemu-static-bin/qemu-aarch64-static \ - dce64b2dc6b005485c7aa735a7ea39cb0006bf7e5badc28b324b2cd0c73d883f - termux_download \ - https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-arm-static \ - "$TERMUX_PKG_CACHEDIR"/qemu-static-bin/qemu-arm-static \ - 9f07762a3cd0f8a199cb5471a92402a4765f8e2fcb7fe91a87ee75da9616a806 - chmod +x "$TERMUX_PKG_CACHEDIR"/qemu-static-bin/qemu-aarch64-static - chmod +x "$TERMUX_PKG_CACHEDIR"/qemu-static-bin/qemu-arm-static - export PATH="$TERMUX_PKG_CACHEDIR/qemu-static-bin:$PATH" + export PATH="$TERMUX_PKG_CACHEDIR/proot-additions/bin:$PATH" + + termux_setup_proot } -__setup_docker_utils() { - mkdir -p "$TERMUX_PKG_CACHEDIR"/docker-utils - termux_download \ - https://raw.githubusercontent.com/NotGlop/docker-drag/5413165a2453aa0bc275d7dc14aeb64e814d5cc0/docker_pull.py \ - "$TERMUX_PKG_CACHEDIR"/docker-utils/docker_pull.py \ - 04e52b70c862884e75874b2fd229083fdf09a4bac35fc16fd7a0874ba20bd075 - termux_download \ - https://raw.githubusercontent.com/larsks/undocker/649f3fdeb0a9cf8aa794d90d6cc6a7c7698a25e6/undocker.py \ - "$TERMUX_PKG_CACHEDIR"/docker-utils/undocker.py \ - 32bc122c53153abeb27491e6d45122eb8cef4f047522835bedf9b4b87877a907 +__pypy3_termux_proot_run() { + termux-proot-run env \ + LD_PRELOAD= \ + LD_LIBRARY_PATH="${LD_LIBRARY_PATH-}" \ + PREFIX="$TERMUX_PREFIX" \ + CC="$CC" \ + CFLAGS="$CFLAGS" \ + LDFLAGS="$LDFLAGS" \ + MAKEFLAGS="$MAKEFLAGS" \ + PYTHONPATH="${PYTHONPATH-}" \ + PYPY_MULTIARCH="$PYPY_MULTIARCH" \ + PYPY_USESSION_DIR="$PYPY_USESSION_DIR" \ + "$@" } -__setup_termux_docker_rootfs() { - __setup_docker_utils +termux_step_configure() { + __setup_termux_envs - # Pick up host platform arch - local __pypy3_host_arch="" - if [ "$TERMUX_ARCH_BITS" = "32" ]; then - __pypy3_host_arch="i686" - else - __pypy3_host_arch="x86_64" + if [[ "$TERMUX_ON_DEVICE_BUILD" == "false" ]]; then + # spin up dnsmasq to use for downloading cffi + $__pypy3_run_on_target_from_builder \ + dnsmasq --pid-file="$TERMUX_PKG_TMPDIR/dnsmasq.pid" & + $__pypy3_run_on_target_from_builder \ + python2 -m ensurepip --upgrade --no-default-pip fi - # Get host platform rootfs tar if needed - if [ ! -f "$TERMUX_PKG_CACHEDIR/termux_termux-docker_$__pypy3_host_arch.tar" ]; then - ( - cd "$TERMUX_PKG_CACHEDIR" - python docker-utils/docker_pull.py termux/termux-docker:$__pypy3_host_arch - mv termux_termux-docker.tar termux_termux-docker_$__pypy3_host_arch.tar - ) - fi + $__pypy3_run_on_target_from_builder \ + pip2 install cffi - # Download update-static-dns and static-dns-hosts.txt from older termux-docker commit - mkdir -p "$TERMUX_PKG_CACHEDIR"/termux-docker-utils - termux_download \ - https://github.com/termux/termux-docker/raw/98af62205f4da832b71bb4de09cb8d6b17ceeaca/static-dns-hosts.txt \ - "$TERMUX_PKG_CACHEDIR"/termux-docker-utils/static-dns-hosts.txt \ - f5e28c8d37dc69e4876372cc05dcfd07aadc8499f5fa05bb6af1cfbff7cd656a - termux_download \ - https://github.com/termux/termux-docker/raw/98af62205f4da832b71bb4de09cb8d6b17ceeaca/system/arm/bin/update-static-dns \ - "$TERMUX_PKG_CACHEDIR"/termux-docker-utils/update-static-dns \ - 14b6ba13506dd90b691e5dbb84bf79ca155837dd43eb05c0e68fbe991c05ee5e - - # Extract host platform rootfs tar - __pypy3_host_rootfs="$TERMUX_PKG_CACHEDIR/host-termux-rootfs-$__pypy3_host_arch" - if [ ! -d "$__pypy3_host_rootfs" ]; then - rm -rf "$__pypy3_host_rootfs".tmp - mkdir -p "$__pypy3_host_rootfs".tmp - cat "$TERMUX_PKG_CACHEDIR"/termux_termux-docker_$__pypy3_host_arch.tar | \ - python "$TERMUX_PKG_CACHEDIR"/docker-utils/undocker.py -o "$__pypy3_host_rootfs".tmp - mkdir -p "$__pypy3_host_rootfs".tmp/"$TERMUX_PREFIX"/bin - mkdir -p "$__pypy3_host_rootfs".tmp/"$TERMUX_ANDROID_HOME" - cp "$TERMUX_PKG_CACHEDIR"/termux-docker-utils/static-dns-hosts.txt \ - "$__pypy3_host_rootfs".tmp/system/etc/ - cp "$TERMUX_PKG_CACHEDIR"/termux-docker-utils/update-static-dns \ - "$__pypy3_host_rootfs".tmp/"$TERMUX_PREFIX"/bin/ - cp "$TERMUX_PKG_CACHEDIR"/proot-bin/proot \ - "$__pypy3_host_rootfs".tmp/"$TERMUX_PREFIX"/bin/ - chmod +x "$__pypy3_host_rootfs".tmp/"$TERMUX_PREFIX"/bin/update-static-dns - rm -f "$__pypy3_host_rootfs".tmp/bin - rm -f "$__pypy3_host_rootfs".tmp/usr - rm -f "$__pypy3_host_rootfs".tmp/tmp - mv "$__pypy3_host_rootfs".tmp "$__pypy3_host_rootfs" + if [[ "$TERMUX_ON_DEVICE_BUILD" == "false" ]]; then + kill -9 $(cat "$TERMUX_PKG_TMPDIR/dnsmasq.pid") fi -} -__setup_termux_envs() { - __pypy3_termux_envs=" -ANDROID_DATA=/data -ANDROID_ROOT=/system -HOME=$TERMUX_ANDROID_HOME -LANG=en_US.UTF-8 -PATH=$TERMUX_PREFIX/bin -PREFIX=$TERMUX_PREFIX -TMPDIR=$TERMUX_PREFIX/tmp -TERM=$TERM -TZ=UTC" - - __pypy3_run_on_host=" -env -i -PROOT_NO_SECCOMP=1 -PROOT_TMP_DIR=/tmp -$__pypy3_termux_envs -$TERMUX_PKG_CACHEDIR/proot-bin/proot --b /proc -b /dev -b /sys --b $HOME --b /tmp --b /data/:/target-termux-rootfs/data/ --b /system/:/target-termux-rootfs/system/ --w $TERMUX_PKG_TMPDIR --r $__pypy3_host_rootfs/ -" - - __pypy3_run_on_target_from_builder=" -env -i -PROOT_NO_SECCOMP=1 -PROOT_TMP_DIR=/tmp -$__pypy3_termux_envs -$TERMUX_PKG_CACHEDIR/proot-bin/proot --b /data/:/target-termux-rootfs/data/ --b /system/:/target-termux-rootfs/system/ --w $TERMUX_PKG_TMPDIR --R / -/usr/bin/env -i -PROOT_NO_SECCOMP=1 -PROOT_TMP_DIR=/tmp -$__pypy3_termux_envs -$TERMUX_PKG_CACHEDIR/proot-bin/proot --b /proc -b /dev -b /sys --b /bin/bash --b /lib -b /lib64 --b $HOME --b /tmp --w $TERMUX_PKG_TMPDIR --r /target-termux-rootfs/ -" - - __pypy3_run_on_target_from_host=" -env -i -PROOT_NO_SECCOMP=1 -PROOT_TMP_DIR=/tmp -$__pypy3_termux_envs -$TERMUX_PKG_CACHEDIR/proot-bin/proot --b /proc -b /dev -b /sys --b $HOME --b /tmp --b $TERMUX_ANDROID_HOME:$TERMUX_ANDROID_HOME --w $TERMUX_PKG_TMPDIR --r /target-termux-rootfs/ -" - - # Set qemu-user-static if needed - case "$TERMUX_ARCH" in - "aarch64" | "arm") - __pypy3_run_on_target_from_host+=" -q $TERMUX_PKG_CACHEDIR/qemu-static-bin/qemu-$TERMUX_ARCH-static" - __pypy3_run_on_target_from_builder+=" -q $TERMUX_PKG_CACHEDIR/qemu-static-bin/qemu-$TERMUX_ARCH-static" - ;; - *) - ;; - esac + find "$TERMUX_PKG_SRCDIR" -type f -print0 | xargs -0 sed -i \ + -e "s|'gcc'|'${CC}'|g" -e "s|\"gcc\"|\"${CC}\"|g" } -__run_on_host_docker_rootfs() { - $__pypy3_run_on_host "$@" -} +termux_step_make() { + pushd "$TERMUX_PKG_SRCDIR/pypy/goal" -termux_step_configure() { - __setup_proot - __setup_qemu_static_binaries - __setup_docker_utils - __setup_termux_docker_rootfs - __setup_termux_envs + $__pypy3_run_on_target_from_builder \ + python2 -u "$TERMUX_PKG_SRCDIR/rpython/bin/rpython" --opt=jit - # Install deps on host termux rootfs if needed - __run_on_host_docker_rootfs update-static-dns - __run_on_host_docker_rootfs apt update - __run_on_host_docker_rootfs apt upgrade -yq -o Dpkg::Options::=--force-confnew - __run_on_host_docker_rootfs apt update - __run_on_host_docker_rootfs apt install binutils clang ndk-sysroot ndk-multilib python2 make -y - __run_on_host_docker_rootfs python2 -m pip install cffi pycparser - - CFLAGS+=" -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD=1" - # error: incompatible function pointer types passing 'Signed (*)(void *, const char *, XML_Encoding *)' (aka 'long (*)(void *, const char *, XML_Encoding *)') to parameter of type 'XML_UnknownEncodingHandler' (aka 'int (*)(void *, const char *, XML_Encoding *)') [-Wincompatible-function-pointer-types] - CFLAGS+=" -Wno-incompatible-function-pointer-types" -} + export PYTHONPATH="$TERMUX_PKG_SRCDIR" + # prevents ImportError: dlopen failed: library "libpypy3.11-c.so" not found + # (goes with 9998-link-against-pypy3-on-testcapi.diff) + export LD_LIBRARY_PATH="$TERMUX_PKG_SRCDIR/pypy/goal" + export LDFLAGS+=" -L$TERMUX_PKG_SRCDIR/pypy/goal" -termux_step_make() { - mkdir -p "$TERMUX_PKG_SRCDIR"/usession-dir - - __run_on_host_docker_rootfs uname -a - __run_on_host_docker_rootfs $__pypy3_run_on_target_from_host uname -a - - # (Cross) Translation - __run_on_host_docker_rootfs \ - env \ - -C "$TERMUX_PKG_SRCDIR"/pypy/goal \ - PYPY_USESSION_DIR="$TERMUX_PKG_SRCDIR/usession-dir" \ - PROOT_TARGET="$__pypy3_run_on_target_from_host" \ - TARGET_CFLAGS="$CFLAGS $CPPFLAGS" \ - TARGET_LDFLAGS="$LDFLAGS" \ - python2 -u ../../rpython/bin/rpython \ - --platform=termux-"$TERMUX_ARCH" \ - --source --no-compile -Ojit \ - targetpypystandalone.py - - # Build - cd "$TERMUX_PKG_SRCDIR"/usession-dir - cd "$(ls -C | awk '{print $1}')"/testing_1 - local srcdir="$(pwd)" - __run_on_host_docker_rootfs \ - env -C "$srcdir" make clean - __run_on_host_docker_rootfs \ - env -C "$srcdir" make -j$TERMUX_PKG_MAKE_PROCESSES - - # Copy the built files - cp ./pypy$_MAJOR_VERSION-c "$TERMUX_PKG_SRCDIR"/pypy/goal/pypy$_MAJOR_VERSION-c - cp ./libpypy$_MAJOR_VERSION-c.so "$TERMUX_PKG_SRCDIR"/pypy/goal/libpypy$_MAJOR_VERSION-c.so - cp ./libpypy$_MAJOR_VERSION-c.so "$TERMUX_PREFIX"/lib/libpypy$_MAJOR_VERSION-c.so - - echo $__pypy3_run_on_host - echo $__pypy3_run_on_target_from_host - echo $__pypy3_run_on_target_from_builder - - # Dummy cc and strip - rm -rf "$TERMUX_PKG_TMPDIR"/dummy-bin - mkdir -p "$TERMUX_PKG_TMPDIR"/dummy-bin - cp "$TERMUX_PKG_BUILDER_DIR"/cc.sh "$TERMUX_PKG_TMPDIR"/dummy-bin/cc - chmod +x "$TERMUX_PKG_TMPDIR"/dummy-bin/cc - ln -sf $(command -v llvm-strip) "$TERMUX_PKG_TMPDIR"/dummy-bin/strip - - # Set host-rootfs if needed - local HOST_ROOTFS="" - case "$TERMUX_ARCH" in - "aarch64" | "arm") - HOST_ROOTFS="/host-rootfs" - ;; - *) - ;; - esac - - # Build cffi imports (Cross exec) $__pypy3_run_on_target_from_builder \ - env -i \ - PATH="$TERMUX_PKG_TMPDIR/dummy-bin:$TERMUX_PREFIX/bin" \ - HOST_ROOTFS="$HOST_ROOTFS" \ - TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_STANDALONE_TOOLCHAIN" \ - CC="$TERMUX_PKG_TMPDIR/dummy-bin/cc" \ - LDSHARED="$TERMUX_PKG_TMPDIR/dummy-bin/cc -pthread -shared" \ - CCTERMUX_HOST_PLATFORM="$CCTERMUX_HOST_PLATFORM" \ - CFLAGS="$CFLAGS $CPPFLAGS" \ - LDFLAGS="$LDFLAGS" \ - "$TERMUX_PKG_SRCDIR"/pypy/goal/pypy$_MAJOR_VERSION-c \ - $TERMUX_PKG_SRCDIR/pypy/tool/release/package.py \ - --archive-name=pypy$_MAJOR_VERSION-v$TERMUX_PKG_VERSION \ - --targetdir=$TERMUX_PKG_SRCDIR \ + "$(pwd)/pypy$_MAJOR_VERSION-c" \ + "$TERMUX_PKG_SRCDIR/pypy/tool/release/package.py" \ + --archive-name="pypy$_MAJOR_VERSION-v$TERMUX_PKG_VERSION" \ + --targetdir="$TERMUX_PKG_SRCDIR" \ --no-embedded-dependencies \ - --no-keep-debug || bash - - rm -f "$TERMUX_PREFIX"/lib/libpypy$_MAJOR_VERSION-c.so + --no-keep-debug + popd } termux_step_make_install() { - rm -rf $TERMUX_PREFIX/opt/pypy3 - unzip -d $TERMUX_PREFIX/opt/ pypy$_MAJOR_VERSION-v$TERMUX_PKG_VERSION.zip - mv $TERMUX_PREFIX/opt/pypy$_MAJOR_VERSION-v$TERMUX_PKG_VERSION $TERMUX_PREFIX/opt/pypy3 - ln -sfr $TERMUX_PREFIX/opt/pypy3/bin/pypy3 $TERMUX_PREFIX/bin/ - ln -sfr $TERMUX_PREFIX/opt/pypy3/bin/libpypy3-c.so $TERMUX_PREFIX/lib/ + local installdir="$TERMUX_PREFIX/opt/$TERMUX_PKG_NAME" + rm -rf "$installdir" + mkdir -p "$installdir" + tar xf "pypy$_MAJOR_VERSION-v$TERMUX_PKG_VERSION.tar.bz2" --strip-components=1 -C "$installdir" + ln -sfr "$installdir/bin/$TERMUX_PKG_NAME" "$TERMUX_PREFIX/bin/" + ln -sfr "$installdir/bin/lib$TERMUX_PKG_NAME-c.so" "$TERMUX_PREFIX/lib/" } termux_step_create_debscripts() { + # postinst script to clean up runtime-generated files of previous pypy3 versions that + # do not match the current $_MAJOR_VERSION + # (this one needs to have bash in the shebang, not sh, because of the use of a special + # wildcard feature that does not work if the shebang is sh [which, in Termux, is bash in sh mode]) + cat <<- POSTINST_EOF > ./postinst + #!$TERMUX_PREFIX/bin/bash + + echo "Deleting files from other versions of $TERMUX_PKG_NAME..." + rm -Rf $TERMUX_PREFIX/opt/$TERMUX_PKG_NAME/lib/pypy*[^$_MAJOR_VERSION] + + exit 0 + POSTINST_EOF + # Pre-rm script to cleanup runtime-generated files. cat <<- PRERM_EOF > ./prerm #!$TERMUX_PREFIX/bin/sh - if [ "$TERMUX_PACKAGE_FORMAT" != "pacman" ] && [ "\$1" != "remove" ]; then + if [ "$TERMUX_PACKAGE_FORMAT" = "debian" ] && [ "\$1" != "remove" ]; then exit 0 fi echo "Deleting files from site-packages..." - rm -Rf $TERMUX_PREFIX/opt/pypy3/lib/pypy$_MAJOR_VERSION/site-packages/* + rm -Rf $TERMUX_PREFIX/opt/$TERMUX_PKG_NAME/lib/pypy$_MAJOR_VERSION/site-packages/* echo "Deleting *.pyc..." - find $TERMUX_PREFIX/opt/pypy3/lib/ | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf + find $TERMUX_PREFIX/opt/$TERMUX_PKG_NAME/lib/ | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf exit 0 PRERM_EOF - chmod 0755 prerm + chmod 0755 postinst prerm } diff --git a/packages/pypy3/cc.sh b/packages/pypy3/cc.sh deleted file mode 100644 index 5dcc3a99c81fd4..00000000000000 --- a/packages/pypy3/cc.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -if [ "$1" != "-cc1" ]; then - $HOST_ROOTFS/$TERMUX_STANDALONE_TOOLCHAIN/bin/clang --target=$CCTERMUX_HOST_PLATFORM "$@" -else - # Target is already an argument. - $HOST_ROOTFS/$TERMUX_STANDALONE_TOOLCHAIN/bin/clang "$@" -fi diff --git a/packages/pypy3/pypy3-tests.subpackage.sh b/packages/pypy3/pypy3-tests.subpackage.sh index 3e3f43ac548eaa..2b23c13b020699 100644 --- a/packages/pypy3/pypy3-tests.subpackage.sh +++ b/packages/pypy3/pypy3-tests.subpackage.sh @@ -1,8 +1,8 @@ TERMUX_SUBPKG_DESCRIPTION="Test files for PyPy 3" TERMUX_SUBPKG_INCLUDE=" -opt/pypy3/lib/pypy$_MAJOR_VERSION/test -opt/pypy3/lib/pypy$_MAJOR_VERSION/*/test -opt/pypy3/lib/pypy$_MAJOR_VERSION/*/tests +opt/$TERMUX_PKG_NAME/lib/pypy$_MAJOR_VERSION/test +opt/$TERMUX_PKG_NAME/lib/pypy$_MAJOR_VERSION/*/test +opt/$TERMUX_PKG_NAME/lib/pypy$_MAJOR_VERSION/*/tests " termux_step_create_subpkg_debscripts() { @@ -10,12 +10,12 @@ termux_step_create_subpkg_debscripts() { cat <<- PRERM_EOF > ./prerm #!$TERMUX_PREFIX/bin/sh - if [ "$TERMUX_PACKAGE_FORMAT" != "pacman" ] && [ "\$1" != "remove" ]; then + if [ "$TERMUX_PACKAGE_FORMAT" = "debian" ] && [ "\$1" != "remove" ]; then exit 0 fi echo "Deleting *.pyc..." - find $TERMUX_PREFIX/opt/pypy3/lib-python | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf + find $TERMUX_PREFIX/opt/$TERMUX_PKG_NAME/lib-python | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf exit 0 PRERM_EOF diff --git a/packages/pypy3/pypy3-tkinter.subpackage.sh b/packages/pypy3/pypy3-tkinter.subpackage.sh index 0677c7cc65773c..7bd468010ecd67 100644 --- a/packages/pypy3/pypy3-tkinter.subpackage.sh +++ b/packages/pypy3/pypy3-tkinter.subpackage.sh @@ -1,7 +1,7 @@ TERMUX_SUBPKG_DESCRIPTION="Tkinter support for PyPy 3" TERMUX_SUBPKG_DEPENDS="tk" TERMUX_SUBPKG_INCLUDE=" -opt/pypy3/lib/pypy$_MAJOR_VERSION/_tkinter/* +opt/$TERMUX_PKG_NAME/lib/pypy$_MAJOR_VERSION/_tkinter/* " termux_step_create_subpkg_debscripts() { @@ -9,12 +9,12 @@ termux_step_create_subpkg_debscripts() { cat <<- PRERM_EOF > ./prerm #!$TERMUX_PREFIX/bin/sh - if [ "$TERMUX_PACKAGE_FORMAT" != "pacman" ] && [ "\$1" != "remove" ]; then + if [ "$TERMUX_PACKAGE_FORMAT" = "debian" ] && [ "\$1" != "remove" ]; then exit 0 fi echo "Deleting *.pyc..." - find $TERMUX_PREFIX/opt/pypy3/lib/pypy$_MAJOR_VERSION/_tkinter/ | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf + find $TERMUX_PREFIX/opt/$TERMUX_PKG_NAME/lib/pypy$_MAJOR_VERSION/_tkinter/ | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf exit 0 PRERM_EOF diff --git a/packages/pypy3/termux.py.in b/packages/pypy3/termux.py.in deleted file mode 100644 index 5bf9a282f889fe..00000000000000 --- a/packages/pypy3/termux.py.in +++ /dev/null @@ -1,146 +0,0 @@ -from rpython.translator.platform.linux import Linux -from rpython.translator.platform.posix import _run_subprocess, GnuMakefile -from rpython.translator.platform import ExecutionResult, log -import os - -PROOT_TARGET = os.getenv("PROOT_TARGET") -if PROOT_TARGET == None: - log.Error("PROOT_TARGET: Must provide PROOT_TARGET.") - assert 0 - -PROOT_TARGET_ARGS = PROOT_TARGET.split() - -def _update_target_rootfs_path(flag): - if ("-isystem@TERMUX_PREFIX@" in flag) or ("-L@TERMUX_PREFIX@" in flag): - return flag.replace("@TERMUX_PREFIX@", "/target-termux-rootfs/@TERMUX_PREFIX@") - return flag - -def _update_cflags_for_termux(cflags): - assert isinstance(cflags, tuple) - target_cflags = os.getenv("TARGET_CFLAGS").split() - cflags += tuple(map(_update_target_rootfs_path, target_cflags)) - return cflags - -def _update_link_flags_for_termux(ldflags): - assert isinstance(ldflags, tuple) - target_ldflags = tuple(os.getenv("TARGET_LDFLAGS").split()) - ldflags += tuple(map(_update_target_rootfs_path, target_ldflags)) - ldflags += ("-fno-termux-rpath",) - return ldflags - -def _update_rpath_flags(rpath_flags): - assert isinstance(rpath_flags, list) - return ["-Wl,-rpath=@TERMUX_PREFIX@/lib"] + rpath_flags - -class BaseTermux(Linux): - cflags = _update_cflags_for_termux(Linux.cflags) - extra_libs = () - link_flags = _update_link_flags_for_termux(Linux.link_flags) - rpath_flags = _update_rpath_flags(Linux.rpath_flags) - available_includedirs = [] - available_librarydirs = [] - - @property - def cc(self): - return self._get_cross_compiler() - - @cc.setter - def cc(self, *args): - pass - - def _execute_c_compiler(self, cc, args, outname, cwd=None): - # 'cc' can also contain some options for the C compiler; - # e.g. it can be "gcc -m32". We handle it by splitting on ' '. - cclist = cc.split() - cc = cclist[0] - args = cclist[1:] + args - log.execute('Compiler Exec: ' + cc + ' ' + ' '.join(args)) - returncode, stdout, stderr = _run_subprocess( - cc, args, self.c_environ, cwd) - self._handle_error(returncode, bytes(stdout), bytes(stderr), outname) - - def execute(self, executable, args=[], env=None, compilation_info=None): - if self._is_same_platform_type(): - log.execute('Exec (' + self.name + '): ' + - str(executable) + ' ' + ' '.join(args)) - return super(BaseTermux, self).execute(executable, args, env, compilation_info) - if isinstance(args, str): - args = ' ' + str(executable) + ' ' + args - log.execute('Cross Exec (' + self.name + '): ' + args) - else: - args = [str(executable)] + args - log.execute('Cross Exec (' + self.name + '): ' + ' '.join(args)) - proot_exec = PROOT_TARGET_ARGS[0] - args = PROOT_TARGET_ARGS[1:] + args - returncode, stdout, stderr = _run_subprocess(proot_exec, args, env) - stdout = "" if stdout == None else stdout - stderr = "" if stderr == None else stderr - return ExecutionResult(returncode, stdout, stderr) - - def include_dirs_for_libffi(self): - return self.available_includedirs - - def library_dirs_for_libffi(self): - return self.available_librarydirs - - def _preprocess_include_dirs(self, include_dirs): - return list(include_dirs) + self.available_includedirs - - def _preprocess_library_dirs(self, library_dirs): - return list(library_dirs) + self.available_librarydirs - - def execute_makefile(self, path_to_makefile, extra_opts=[]): - raise NotImplementedError() - - def get_multiarch(self): - raise NotImplementedError("Needs to be overwritten") - - def _get_cross_compiler(self): - return "clang" if self._is_same_platform_type() else ("clang --target=" + self.get_multiarch()) - - def _get_build_platform_type(self): - return "x86" - - def _get_target_platform_type(self): - raise NotImplementedError("Needs to be overwritten") - - def _is_same_platform_type(self): - return self._get_build_platform_type() == self._get_target_platform_type() - - -class Termux_AArch64(BaseTermux): - name = "termux-aarch64" - - def get_multiarch(self): - return "aarch64-linux-android" - - def _get_target_platform_type(self): - return "arm" - - -class Termux_ARM(BaseTermux): - name = "termux-arm" - - def get_multiarch(self): - return "arm-linux-androideabi" - - def _get_target_platform_type(self): - return "arm" - -class Termux_AMD64(BaseTermux): - name = "termux-x86_64" - - def get_multiarch(self): - return "x86_64-linux-android" - - def _get_target_platform_type(self): - return "x86" - -class Termux_IA32(BaseTermux): - name = "termux-i686" - - def get_multiarch(self): - return "i686-linux-android" - - def _get_target_platform_type(self): - return "x86" diff --git a/packages/python2/build.sh b/packages/python2/build.sh index d800e05bf324b8..7a2207b7df6460 100644 --- a/packages/python2/build.sh +++ b/packages/python2/build.sh @@ -4,7 +4,7 @@ TERMUX_PKG_LICENSE="PythonPL" TERMUX_PKG_MAINTAINER="@termux" _MAJOR_VERSION=2.7 TERMUX_PKG_VERSION=${_MAJOR_VERSION}.18 -TERMUX_PKG_REVISION=14 +TERMUX_PKG_REVISION=15 TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz TERMUX_PKG_SHA256=b62c0e7937551d0cc02b8fd5cb0f544f9405bafc9a54d3808ed4594812edef43 TERMUX_PKG_DEPENDS="gdbm, libandroid-posix-semaphore, libandroid-support, libbz2, libcrypt, libffi, libsqlite, ncurses, ncurses-ui-libs, openssl, readline, zlib" @@ -56,6 +56,10 @@ termux_step_post_configure() { } termux_step_pre_configure() { + local p="$TERMUX_PKG_BUILDER_DIR/fix-ctypes-find_library.diff" + echo "Applying $(basename "${p}")" + sed "s|@CC@|${CC}|g" "${p}" | patch --silent -p1 + # Put the host-built python in path: export TERMUX_ORIG_PATH=$PATH export PATH=$TERMUX_PKG_HOSTBUILD_DIR:$PATH diff --git a/packages/python2/fix-ctypes-find_library.diff b/packages/python2/fix-ctypes-find_library.diff new file mode 100644 index 00000000000000..a6ecb642bed7c6 --- /dev/null +++ b/packages/python2/fix-ctypes-find_library.diff @@ -0,0 +1,40 @@ +Android does not have an ldconfig command, so this avoids calling /sbin/ldconfig +or /usr/bin/gcc and getting unwanted references to libc.so.6 or libraries linked to it +when this python2 is being run inside of termux-proot-run. + +see pypy3/0008-fix-ctypes-find_library.patch for the pypy3 version of this. +(pypy has a similar but slightly different implementation of ctypes) + +Important: unlike the implementation of a similar patch for pypy, this only adds in support for: + +- libraries in the internal builtin search paths of the C compiler, which in the case + of the official NDK's cross-compiler are limited to, for example, subdirs of + ~/.termux-build/_cache/android-r27c-api-24-v1/sysroot/usr/lib, + not libraries in LDFLAGS or LD_LIBRARY_PATH, so not, for example, + /data/data/com.termux/files/usr/lib +- libraries that have a SONAME detectable through the 'objdump -p' command, so not + any libraries that for some reason don't have a SONAME detectable using 'objdump -p' + +however, for the purpose of building pypy3, these more conservative changes are +currently sufficient. + +--- a/Lib/ctypes/util.py ++++ b/Lib/ctypes/util.py +@@ -93,7 +93,7 @@ elif os.name == "posix": + # haven't supplied a proper program with main(), but that does not + # matter. + expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) +- cmd = 'if type gcc >/dev/null 2>&1; then CC=gcc; elif type cc >/dev/null 2>&1; then CC=cc;else exit; fi;' \ ++ cmd = 'CC=@CC@;' \ + 'LANG=C LC_ALL=C $CC -Wl,-t -o "$2" 2>&1 -l"$1"' + + temp = tempfile.NamedTemporaryFile() +@@ -271,7 +271,7 @@ elif os.name == "posix": + return res.group(1) + + def find_library(name): +- return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name)) ++ return _get_soname(_findLib_gcc(name)) + + ################################################################ + # test code