diff --git a/packages/pypy3/0003-fix-hardcoded-paths.patch b/packages/pypy3/0003-fix-hardcoded-paths.patch index bf4a91b2f6c236..0ba7a384a7fff3 100644 --- a/packages/pypy3/0003-fix-hardcoded-paths.patch +++ b/packages/pypy3/0003-fix-hardcoded-paths.patch @@ -1,6 +1,5 @@ -diff -uNr pypy3.7-v7.3.7-src/lib-python/3/aifc.py pypy3.7-v7.3.7-src.mod/lib-python/3/aifc.py ---- pypy3.7-v7.3.7-src/lib-python/3/aifc.py 2021-10-24 22:07:11.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/lib-python/3/aifc.py 2022-01-17 23:55:55.258202300 +0800 +--- a/lib-python/3/aifc.py ++++ b/lib-python/3/aifc.py @@ -928,7 +928,7 @@ if __name__ == '__main__': import sys @@ -11,9 +10,8 @@ diff -uNr pypy3.7-v7.3.7-src/lib-python/3/aifc.py pypy3.7-v7.3.7-src.mod/lib-pyt with open(fn, 'r') as f: print("Reading", fn) -diff -uNr pypy3.7-v7.3.7-src/lib-python/3/mailcap.py pypy3.7-v7.3.7-src.mod/lib-python/3/mailcap.py ---- pypy3.7-v7.3.7-src/lib-python/3/mailcap.py 2021-10-24 22:07:11.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/lib-python/3/mailcap.py 2022-01-17 23:59:02.757448900 +0800 +--- a/lib-python/3/mailcap.py ++++ b/lib-python/3/mailcap.py @@ -55,7 +55,8 @@ # Don't bother with getpwuid() home = '.' # Last resort @@ -25,9 +23,8 @@ diff -uNr pypy3.7-v7.3.7-src/lib-python/3/mailcap.py pypy3.7-v7.3.7-src.mod/lib- -diff -uNr pypy3.7-v7.3.7-src/lib-python/3/mimetypes.py pypy3.7-v7.3.7-src.mod/lib-python/3/mimetypes.py ---- pypy3.7-v7.3.7-src/lib-python/3/mimetypes.py 2021-10-24 22:07:11.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/lib-python/3/mimetypes.py 2022-01-18 00:02:08.526252600 +0800 +--- a/lib-python/3/mimetypes.py ++++ b/lib-python/3/mimetypes.py @@ -49,6 +49,7 @@ "/usr/local/lib/netscape/mime.types", "/usr/local/etc/httpd/conf/mime.types", # Apache 1.2 @@ -37,9 +34,8 @@ diff -uNr pypy3.7-v7.3.7-src/lib-python/3/mimetypes.py pypy3.7-v7.3.7-src.mod/li inited = False -diff -uNr pypy3.7-v7.3.7-src/lib-python/3/subprocess.py pypy3.7-v7.3.7-src.mod/lib-python/3/subprocess.py ---- pypy3.7-v7.3.7-src/lib-python/3/subprocess.py 2021-10-24 22:07:11.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/lib-python/3/subprocess.py 2022-01-17 22:27:32.546765900 +0800 +--- a/lib-python/3/subprocess.py ++++ b/lib-python/3/subprocess.py @@ -1452,9 +1452,7 @@ args = list(args) @@ -52,9 +48,8 @@ diff -uNr pypy3.7-v7.3.7-src/lib-python/3/subprocess.py pypy3.7-v7.3.7-src.mod/l if executable: args[0] = executable -diff -uNr pypy3.7-v7.3.7-src/lib-python/3/tempfile.py pypy3.7-v7.3.7-src.mod/lib-python/3/tempfile.py ---- pypy3.7-v7.3.7-src/lib-python/3/tempfile.py 2021-10-24 22:07:11.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/lib-python/3/tempfile.py 2022-01-17 22:43:01.156251700 +0800 +--- a/lib-python/3/tempfile.py ++++ b/lib-python/3/tempfile.py @@ -173,7 +173,7 @@ _os.path.expandvars(r'%SYSTEMROOT%\Temp'), r'c:\temp', r'c:\tmp', r'\temp', r'\tmp' ]) @@ -65,7 +60,6 @@ diff -uNr pypy3.7-v7.3.7-src/lib-python/3/tempfile.py pypy3.7-v7.3.7-src.mod/lib # As a last resort, the current directory. try: -diff -uNr a/lib-python/3/uuid.py b/lib-python/3/uuid.py --- a/lib-python/3/uuid.py +++ b/lib-python/3/uuid.py @@ -361,7 +361,7 @@ @@ -78,9 +72,8 @@ diff -uNr a/lib-python/3/uuid.py b/lib-python/3/uuid.py if executable is None: return None -diff -uNr pypy3.7-v7.3.7-src/lib-python/3/posixpath.py pypy3.7-v7.3.7-src.mod/lib-python/3/posixpath.py ---- pypy3.7-v7.3.7-src/lib-python/3/posixpath.py 2021-10-24 22:07:11.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/lib-python/3/posixpath.py 2022-01-18 00:05:03.938325200 +0800 +--- a/lib-python/3/posixpath.py ++++ b/lib-python/3/posixpath.py @@ -18,7 +18,7 @@ extsep = '.' sep = '/' @@ -90,15 +83,27 @@ diff -uNr pypy3.7-v7.3.7-src/lib-python/3/posixpath.py pypy3.7-v7.3.7-src.mod/li altsep = None devnull = '/dev/null' -diff -uNr pypy3.8-v7.3.8-src/lib-python/3/multiprocessing/heap.py pypy3.8-v7.3.8-src.mod/lib-python/3/multiprocessing/heap.py ---- pypy3.8-v7.3.8-src/lib-python/3/multiprocessing/heap.py 2022-03-17 19:52:44.711182400 +0800 -+++ pypy3.8-v7.3.8-src.mod/lib-python/3/multiprocessing/heap.py 2022-03-20 11:42:23.287141000 +0800 +--- a/lib-python/3/multiprocessing/heap.py ++++ b/lib-python/3/multiprocessing/heap.py @@ -70,7 +70,7 @@ """ if sys.platform == 'linux': - _dir_candidates = ['/dev/shm'] -+ _dir_candidates = [] ++ _dir_candidates = ['/dev/shm'] else: _dir_candidates = [] +--- a/lib_pypy/_tkinter/tklib_build.py ++++ b/lib_pypy/_tkinter/tklib_build.py +@@ -26,6 +26,10 @@ + if homebrew: + incdirs.append(homebrew + '/include') + libdirs.append(homebrew + '/opt/tcl-tk/lib') ++elif os.path.exists("@TERMUX_PREFIX@"): ++ incdirs = ["@TERMUX_PREFIX@/include"] ++ libdirs = ["@TERMUX_PREFIX@/lib"] ++ linklibs = ['tcl8.6', 'tk8.6'] + else: + # On some Linux distributions, the tcl and tk libraries are + # stored in /usr/include, so we must check this case also diff --git a/packages/pypy3/0004-fix-loaded-libs.patch b/packages/pypy3/0004-fix-loaded-libs.patch index f13497d4a2911b..5eecd0f9bd839c 100644 --- a/packages/pypy3/0004-fix-loaded-libs.patch +++ b/packages/pypy3/0004-fix-loaded-libs.patch @@ -1,14 +1,12 @@ -diff -U 1 -Nr pypy2.7-v7.3.6-src/lib_pypy/_audioop_build.py pypy2.7-v7.3.6-src.mod/lib_pypy/_audioop_build.py ---- pypy2.7-v7.3.6-src/lib_pypy/_audioop_build.py 2021-10-03 14:36:11.000000000 +0800 -+++ pypy2.7-v7.3.6-src.mod/lib_pypy/_audioop_build.py 2022-01-16 19:42:48.828092300 +0800 +--- a/lib_pypy/_audioop_build.py ++++ b/lib_pypy/_audioop_build.py @@ -629,3 +629,3 @@ -ffi.set_source("_audioop_cffi", C_SOURCE) +ffi.set_source("_audioop_cffi", C_SOURCE, libraries=["m"]) -diff -U 1 -Nr pypy2.7-v7.3.6-src/lib_pypy/_syslog_build.py pypy2.7-v7.3.6-src.mod/lib_pypy/_syslog_build.py ---- pypy3.7-v7.3.7-src/lib_pypy/_syslog_build.py 2021-10-24 22:07:11.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/lib_pypy/_syslog_build.py 2022-01-18 13:15:23.250151600 +0800 +--- a/lib_pypy/_syslog_build.py ++++ b/lib_pypy/_syslog_build.py @@ -23,7 +23,7 @@ #ifndef LOG_NEWS #define LOG_NEWS LOG_MAIL @@ -20,9 +18,8 @@ diff -U 1 -Nr pypy2.7-v7.3.6-src/lib_pypy/_syslog_build.py pypy2.7-v7.3.6-src.mo /* mandatory constants */ -diff -uNr pypy2.7-v7.3.6-src/lib_pypy/_dbm.py pypy2.7-v7.3.6-src.mod/lib_pypy/_dbm.py ---- pypy2.7-v7.3.6-src/lib_pypy/_dbm.py 2021-10-03 14:36:11.000000000 +0800 -+++ pypy2.7-v7.3.6-src.mod/lib_pypy/_dbm.py 2022-02-09 09:35:04.548269800 +0800 +--- a/lib_pypy/_dbm.py ++++ b/lib_pypy/_dbm.py @@ -123,7 +123,9 @@ func.restype = restype @@ -36,9 +33,8 @@ diff -uNr pypy2.7-v7.3.6-src/lib_pypy/_dbm.py pypy2.7-v7.3.6-src.mod/lib_pypy/_d for c in ['5.3', '5.2', '5.1', '5.0', '4.9', '4.8', '4.7', '4.6', '4.5']: -diff -uNr pypy3.6-v7.3.2-src/pypy/module/_multiprocessing/interp_semaphore.py pypy3.6-v7.3.2-src.mod/pypy/module/_multiprocessing/interp_semaphore.py ---- pypy3.6-v7.3.2-src/pypy/module/_multiprocessing/interp_semaphore.py 2020-09-23 15:02:22.000000000 +0800 -+++ pypy3.6-v7.3.2-src.mod/pypy/module/_multiprocessing/interp_semaphore.py 2021-11-08 05:33:39.436884700 +0800 +--- a/pypy/module/_multiprocessing/interp_semaphore.py ++++ b/pypy/module/_multiprocessing/interp_semaphore.py @@ -43,7 +43,7 @@ if sys.platform == 'darwin': libraries = [] @@ -49,9 +45,8 @@ diff -uNr pypy3.6-v7.3.2-src/pypy/module/_multiprocessing/interp_semaphore.py py eci = ExternalCompilationInfo( includes = ['sys/time.h', -diff -uNr pypy3.7-v7.3.7-src/rpython/rlib/rposix.py pypy3.7-v7.3.7-src.mod/rpython/rlib/rposix.py ---- pypy3.7-v7.3.7-src/rpython/rlib/rposix.py 2021-10-24 22:07:11.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/rpython/rlib/rposix.py 2022-02-12 18:32:05.555262500 +0800 +--- a/rpython/rlib/rposix.py ++++ b/rpython/rlib/rposix.py @@ -212,7 +212,7 @@ includes.append('sys/sysmacros.h') if sys.platform.startswith('freebsd') or sys.platform.startswith('openbsd'): @@ -72,9 +67,8 @@ diff -uNr pypy3.7-v7.3.7-src/rpython/rlib/rposix.py pypy3.7-v7.3.7-src.mod/rpyth if not _WIN32: class CConfig: -diff -uNr pypy3.6-v7.3.2-src/rpython/rlib/rtime.py pypy3.6-v7.3.2-src.mod/rpython/rlib/rtime.py ---- pypy3.6-v7.3.2-src/rpython/rlib/rtime.py 2020-09-23 15:02:22.000000000 +0800 -+++ pypy3.6-v7.3.2-src.mod/rpython/rlib/rtime.py 2021-11-08 05:33:04.074015000 +0800 +--- a/rpython/rlib/rtime.py ++++ b/rpython/rlib/rtime.py @@ -29,10 +29,6 @@ 'sys/types.h', 'unistd.h', 'sys/time.h', 'sys/resource.h'] diff --git a/packages/pypy3/0005-fix-unavailable-functions.patch b/packages/pypy3/0005-fix-unavailable-functions.patch index fdee5afe757030..3b252a85431049 100644 --- a/packages/pypy3/0005-fix-unavailable-functions.patch +++ b/packages/pypy3/0005-fix-unavailable-functions.patch @@ -1,6 +1,5 @@ -diff -uNr pypy3.7-v7.3.7-src/lib-python/3/http/server.py pypy3.7-v7.3.7-src.mod/lib-python/3/http/server.py ---- pypy3.7-v7.3.7-src/lib-python/3/http/server.py 2021-10-24 22:07:11.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/lib-python/3/http/server.py 2022-01-18 00:16:44.328899400 +0800 +--- a/lib-python/3/http/server.py ++++ b/lib-python/3/http/server.py @@ -1161,10 +1161,6 @@ return # Child @@ -13,9 +12,8 @@ diff -uNr pypy3.7-v7.3.7-src/lib-python/3/http/server.py pypy3.7-v7.3.7-src.mod/ os.dup2(self.wfile.fileno(), 1) os.execve(scriptfile, args, env) -diff -uNr pypy3.6-v7.3.2-src/lib_pypy/_pwdgrp_build.py pypy3.6-v7.3.2-src.mod/lib_pypy/_pwdgrp_build.py ---- pypy3.6-v7.3.2-src/lib_pypy/_pwdgrp_build.py 2020-09-23 15:02:22.000000000 +0800 -+++ pypy3.6-v7.3.2-src.mod/lib_pypy/_pwdgrp_build.py 2021-11-09 18:32:36.933096400 +0800 +--- a/lib_pypy/_pwdgrp_build.py ++++ b/lib_pypy/_pwdgrp_build.py @@ -35,9 +35,9 @@ struct passwd *getpwuid(uid_t uid); struct passwd *getpwnam(const char *name); @@ -30,9 +28,8 @@ diff -uNr pypy3.6-v7.3.2-src/lib_pypy/_pwdgrp_build.py pypy3.6-v7.3.2-src.mod/li struct group *getgrgid(gid_t gid); struct group *getgrnam(const char *name); -diff -uNr pypy3.7-v7.3.7-src/lib-python/3/smtpd.py pypy3.7-v7.3.7-src.mod/lib-python/3/smtpd.py ---- pypy3.7-v7.3.7-src/lib-python/3/smtpd.py 2021-10-24 22:07:11.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/lib-python/3/smtpd.py 2022-01-18 00:18:09.630517000 +0800 +--- a/lib-python/3/smtpd.py ++++ b/lib-python/3/smtpd.py @@ -9,7 +9,8 @@ -n This program generally tries to setuid `nobody', unless this flag is @@ -54,9 +51,8 @@ diff -uNr pypy3.7-v7.3.7-src/lib-python/3/smtpd.py pypy3.7-v7.3.7-src.mod/lib-py enable_SMTPUTF8 = False -diff -uNr pypy3.6-v7.3.2-src/pypy/module/pwd/interp_pwd.py pypy3.6-v7.3.2-src.mod/pypy/module/pwd/interp_pwd.py ---- pypy3.6-v7.3.2-src/pypy/module/pwd/interp_pwd.py 2020-09-23 15:02:22.000000000 +0800 -+++ pypy3.6-v7.3.2-src.mod/pypy/module/pwd/interp_pwd.py 2022-01-09 05:13:04.669185900 +0800 +--- a/pypy/module/pwd/interp_pwd.py ++++ b/pypy/module/pwd/interp_pwd.py @@ -19,18 +19,25 @@ uid_t = config['uid_t'] gid_t = config['gid_t'] @@ -141,9 +137,8 @@ diff -uNr pypy3.6-v7.3.2-src/pypy/module/pwd/interp_pwd.py pypy3.6-v7.3.2-src.mo +# c_endpwent() +# return space.newlist(users_w) -diff -uNr pypy3.6-v7.3.2-src/pypy/module/pwd/moduledef.py pypy3.6-v7.3.2-src.mod/pypy/module/pwd/moduledef.py ---- pypy3.6-v7.3.2-src/pypy/module/pwd/moduledef.py 2020-09-23 15:02:22.000000000 +0800 -+++ pypy3.6-v7.3.2-src.mod/pypy/module/pwd/moduledef.py 2021-11-09 18:31:05.132729100 +0800 +--- a/pypy/module/pwd/moduledef.py ++++ b/pypy/module/pwd/moduledef.py @@ -15,11 +15,11 @@ interpleveldefs = { 'getpwuid': 'interp_pwd.getpwuid', @@ -158,9 +153,8 @@ diff -uNr pypy3.6-v7.3.2-src/pypy/module/pwd/moduledef.py pypy3.6-v7.3.2-src.mod + # 'struct_pwent': 'app_pwd.struct_passwd', } -diff -uNr pypy3.7-v7.3.7-src/rpython/rlib/rvmprof/cintf.py pypy3.7-v7.3.7-src.mod/rpython/rlib/rvmprof/cintf.py ---- pypy3.7-v7.3.7-src/rpython/rlib/rvmprof/cintf.py 2022-01-02 01:09:08.909941000 +0800 -+++ pypy3.7-v7.3.7-src.mod/rpython/rlib/rvmprof/cintf.py 2022-01-02 01:10:11.909941000 +0800 +--- a/rpython/rlib/rvmprof/cintf.py ++++ b/rpython/rlib/rvmprof/cintf.py @@ -16,14 +16,14 @@ class VMProfPlatformUnsupported(Exception): pass @@ -184,3 +178,31 @@ diff -uNr pypy3.7-v7.3.7-src/rpython/rlib/rvmprof/cintf.py pypy3.7-v7.3.7-src.mo ROOT = py.path.local(rpythonroot).join('rpython', 'rlib', 'rvmprof') SRC = ROOT.join('src') +--- a/pypy/module/posix/moduledef.py ++++ b/pypy/module/posix/moduledef.py +@@ -140,12 +140,12 @@ + interpleveldefs['pathconf_names'] = 'space.wrap(interp_posix.pathconf_names())' + if hasattr(os, 'pathconf'): + interpleveldefs['pathconf'] = 'interp_posix.pathconf' +- if hasattr(os, 'confstr'): ++ if False: + interpleveldefs['confstr'] = 'interp_posix.confstr' + interpleveldefs['confstr_names'] = 'space.wrap(interp_posix.confstr_names())' + if hasattr(os, 'ttyname'): + interpleveldefs['ttyname'] = 'interp_posix.ttyname' +- if hasattr(os, 'getloadavg'): ++ if False: + interpleveldefs['getloadavg'] = 'interp_posix.getloadavg' + if hasattr(os, 'makedev'): + interpleveldefs['makedev'] = 'interp_posix.makedev' +--- a/rpython/rlib/rposix.py ++++ b/rpython/rlib/rposix.py +@@ -3049,7 +3049,7 @@ + # ____________________________________________________________ + # Support for *xattr functions + +-if sys.platform.startswith('linux'): ++if False: + + class CConfig: + _compilation_info_ = ExternalCompilationInfo( diff --git a/packages/pypy3/0006-package-zip.patch b/packages/pypy3/0006-package-zip.patch index 812844f49a8208..2c2a1bd462f0e8 100644 --- a/packages/pypy3/0006-package-zip.patch +++ b/packages/pypy3/0006-package-zip.patch @@ -1,6 +1,5 @@ -diff -uNr pypy3.6-v7.3.2-src/pypy/tool/release/package.py pypy3.6-v7.3.2-src.mod/pypy/tool/release/package.py ---- pypy3.6-v7.3.2-src/pypy/tool/release/package.py 2020-09-23 15:02:22.000000000 +0800 -+++ pypy3.6-v7.3.2-src.mod/pypy/tool/release/package.py 2021-12-30 23:25:59.068175100 +0800 +--- a/pypy/tool/release/package.py ++++ b/pypy/tool/release/package.py @@ -35,7 +35,7 @@ ARCH = get_arch() diff --git a/packages/pypy3/0007-termux-build.patch b/packages/pypy3/0007-termux-build.patch index 6622daad233c29..3ab6907ad4164a 100644 --- a/packages/pypy3/0007-termux-build.patch +++ b/packages/pypy3/0007-termux-build.patch @@ -1,6 +1,5 @@ -diff -uNr pypy2.7-v7.3.6-src/rpython/config/translationoption.py pypy2.7-v7.3.6-src.mod/rpython/config/translationoption.py ---- pypy2.7-v7.3.6-src/rpython/config/translationoption.py 2021-10-03 14:36:11.000000000 +0800 -+++ pypy2.7-v7.3.6-src.mod/rpython/config/translationoption.py 2022-02-02 22:03:09.677990900 +0800 +--- a/rpython/config/translationoption.py ++++ b/rpython/config/translationoption.py @@ -40,6 +40,10 @@ PLATFORMS = [ 'host', @@ -33,9 +32,8 @@ diff -uNr pypy2.7-v7.3.6-src/rpython/config/translationoption.py pypy2.7-v7.3.6- BoolOption("split_gc_address_space", "Ensure full separation of GC and non-GC pointers", default=False), -diff -uNr pypy2.7-v7.3.6-src/rpython/translator/platform/__init__.py pypy2.7-v7.3.6-src.mod/rpython/translator/platform/__init__.py ---- pypy2.7-v7.3.6-src/rpython/translator/platform/__init__.py 2021-10-03 14:36:11.000000000 +0800 -+++ pypy2.7-v7.3.6-src.mod/rpython/translator/platform/__init__.py 2022-02-06 11:18:42.527715600 +0800 +--- 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) @@ -64,189 +62,3 @@ diff -uNr pypy2.7-v7.3.6-src/rpython/translator/platform/__init__.py pypy2.7-v7. else: raise ValueError("platform = %s" % (new_platform,)) - - ---- pypy3.7-v7.3.7-src/rpython/translator/platform/termux.py 1970-01-01 08:00:00.000000000 +0800 -+++ pypy3.7-v7.3.7-src.mod/rpython/translator/platform/termux.py 2022-03-10 16:49:35.071701000 +0800 -@@ -0,0 +1,181 @@ -+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() -+ -+TARGET_ROOTFS_BASE = os.getenv("TARGET_ROOTFS_BASE") -+if TARGET_ROOTFS_BASE == None: -+ log.Error("TARGET_ROOTFS_BASE: Must provide TARGET_ROOTFS_BASE.") -+ assert 0 -+ -+def _update_cflags_for_termux(cflags): -+ assert isinstance(cflags, tuple) -+ cflags += ("-fstack-protector-strong", "-fopenmp", -+ "-DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD", ) -+ return cflags -+ -+def _update_link_flags_for_termux(ldflags): -+ assert isinstance(ldflags, tuple) -+ ldflags += ("-fopenmp", "-static-openmp", "-fno-termux-rpath", -+ "-Wl,--enable-new-dtags", "-Wl,--as-needed", -+ "-Wl,-z,relro,-z,now", "-Wl,-rpath=@TERMUX_PREFIX@/lib", ) -+ 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('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() -+ -+def _update_cflags_for_termux_aarch64(cflags): -+ return ('-I' + TARGET_ROOTFS_BASE + '@TERMUX_PREFIX@/include', ) + cflags -+ -+def _update_link_flags_for_termux_aarch64(ldflags): -+ return ('-L' + TARGET_ROOTFS_BASE + '@TERMUX_PREFIX@/lib', ) + ldflags -+ -+class Termux_AArch64(BaseTermux): -+ name = "termux-aarch64" -+ cflags = _update_cflags_for_termux_aarch64(BaseTermux.cflags) -+ link_flags = _update_link_flags_for_termux_aarch64(BaseTermux.link_flags) -+ -+ def get_multiarch(self): -+ return "aarch64-linux-android" -+ -+ def _get_target_platform_type(self): -+ return "arm" -+ -+def _update_cflags_for_termux_arm(cflags): -+ return ('-I' + TARGET_ROOTFS_BASE + '@TERMUX_PREFIX@/include', -+ "-march=armv7-a", "-mfpu=neon", -+ "-mfloat-abi=softfp", "-mthumb", -+ "-Wno-incompatible-function-pointer-types", ) + cflags -+ -+def _update_link_flags_for_termux_arm(ldflags): -+ return ("-march=armv7-a", '-L' + TARGET_ROOTFS_BASE + '@TERMUX_PREFIX@/lib', ) + ldflags -+ -+class Termux_ARM(BaseTermux): -+ name = "termux-arm" -+ cflags = _update_cflags_for_termux_arm(BaseTermux.cflags) -+ link_flags = _update_link_flags_for_termux_arm(BaseTermux.link_flags) -+ -+ def get_multiarch(self): -+ return "arm-linux-androideabi" -+ -+ def _get_target_platform_type(self): -+ return "arm" -+ -+def _update_cflags_for_termux_x86_64(ldflags): -+ return ('-I@TERMUX_PREFIX@/include', ) + ldflags -+ -+def _update_link_flags_for_termux_x86_64(ldflags): -+ return ('-L@TERMUX_PREFIX@/lib', ) + ldflags -+ -+class Termux_AMD64(BaseTermux): -+ name = "termux-x86_64" -+ cflags = _update_cflags_for_termux_x86_64(BaseTermux.cflags) -+ link_flags = _update_link_flags_for_termux_x86_64(BaseTermux.link_flags) -+ -+ def get_multiarch(self): -+ return "x86_64-linux-android" -+ -+ def _get_target_platform_type(self): -+ return "x86" -+ -+def _update_cflags_for_termux_i686(cflags): -+ return ('-I@TERMUX_PREFIX@/include', "-march=i686", "-msse3", -+ "-mstackrealign", "-mfpmath=sse", "-fPIC", -+ "-Wno-incompatible-function-pointer-types", ) + cflags -+ -+def _update_link_flags_for_termux_i686(ldflags): -+ return ('-L@TERMUX_PREFIX@/lib', "-fPIC", ) + ldflags -+ -+class Termux_IA32(BaseTermux): -+ name = "termux-i686" -+ cflags = _update_cflags_for_termux_i686(BaseTermux.cflags) -+ link_flags = _update_link_flags_for_termux_i686(BaseTermux.link_flags) -+ -+ def get_multiarch(self): -+ return "i686-linux-android" -+ -+ def _get_target_platform_type(self): -+ return "x86" diff --git a/packages/pypy3/0010-dummy-cpu_count.patch b/packages/pypy3/0010-dummy-cpu_count.patch new file mode 100644 index 00000000000000..3fd76ac8d9fb6e --- /dev/null +++ b/packages/pypy3/0010-dummy-cpu_count.patch @@ -0,0 +1,14 @@ +--- 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/build.sh b/packages/pypy3/build.sh index 874dea04a0c247..28950b3855f205 100644 --- a/packages/pypy3/build.sh +++ b/packages/pypy3/build.sh @@ -3,279 +3,306 @@ 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.13 +TERMUX_PKG_VERSION=7.3.15 TERMUX_PKG_SRCURL=https://downloads.python.org/pypy/pypy$_MAJOR_VERSION-v$TERMUX_PKG_VERSION-src.tar.bz2 -TERMUX_PKG_SHA256=bc6147268105e7cb3bd57b401e6d97f66aa4ede269104b2712a7cdd9f02f68cd +TERMUX_PKG_SHA256=6bb9537d85aa7ad13c0aad2e41ff7fd55080bc9b4d1361b8f502df51db816e18 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="binutils, clang, dash, make, ndk-multilib, pkg-config, python2, tk, xorgproto" +TERMUX_PKG_BUILD_DEPENDS="bionic-host, clang, make, pkg-config, python2, tk, xorgproto" TERMUX_PKG_RECOMMENDS="clang, make, pkg-config" TERMUX_PKG_SUGGESTS="pypy3-tkinter" TERMUX_PKG_BUILD_IN_SRC=true -TERMUX_PKG_RM_AFTER_INSTALL=" -opt/pypy3/lib/pypy$_MAJOR_VERSION/test -opt/pypy3/lib/pypy$_MAJOR_VERSION/*/test -opt/pypy3/lib/pypy$_MAJOR_VERSION/*/tests -" - -_docker_pull_url=https://raw.githubusercontent.com/NotGlop/docker-drag/5413165a2453aa0bc275d7dc14aeb64e814d5cc0/docker_pull.py -_docker_pull_checksums=04e52b70c862884e75874b2fd229083fdf09a4bac35fc16fd7a0874ba20bd075 -_undocker_url=https://raw.githubusercontent.com/larsks/undocker/649f3fdeb0a9cf8aa794d90d6cc6a7c7698a25e6/undocker.py -_undocker_checksums=32bc122c53153abeb27491e6d45122eb8cef4f047522835bedf9b4b87877a907 -_proot_url=https://github.com/proot-me/proot/releases/download/v5.3.0/proot-v5.3.0-x86_64-static -_proot_checksums=d1eb20cb201e6df08d707023efb000623ff7c10d6574839d7bb42d0adba6b4da -_qemu_aarch64_static_url=https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-aarch64-static -_qemu_aarch64_static_checksums=dce64b2dc6b005485c7aa735a7ea39cb0006bf7e5badc28b324b2cd0c73d883f -_qemu_arm_static_url=https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-arm-static -_qemu_arm_static_checksums=9f07762a3cd0f8a199cb5471a92402a4765f8e2fcb7fe91a87ee75da9616a806 - -# Skip due to we use proot to get dependencies -termux_step_get_dependencies() { - echo "Skip due to we use proot to get dependencies" -} - -termux_step_override_config_scripts() { - : -} - -termux_step_pre_configure() { - if $TERMUX_ON_DEVICE_BUILD; then - termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds." - fi +termux_step_post_get_source() { local p="$TERMUX_PKG_BUILDER_DIR/9998-link-against-pypy3-on-testcapi.diff" echo "Applying $(basename "${p}")" sed 's|@TERMUX_PYPY_MAJOR_VERSION@|'"${_MAJOR_VERSION}"'|g' "${p}" \ | patch --silent -p1 - local p="$TERMUX_PKG_BUILDER_DIR/9999-add-ANDROID_API_LEVEL-for-sysconfigdata.diff" + p="$TERMUX_PKG_BUILDER_DIR/9999-add-ANDROID_API_LEVEL-for-sysconfigdata.diff" echo "Applying $(basename "${p}")" sed 's|@TERMUX_PKG_API_LEVEL@|'"${TERMUX_PKG_API_LEVEL}"'|g' "${p}" \ | patch --silent -p1 - DOCKER_PULL="python $TERMUX_PKG_CACHEDIR/docker_pull.py" - UNDOCKER="python $TERMUX_PKG_CACHEDIR/undocker.py" - PROOT="$TERMUX_PKG_CACHEDIR/proot" + sed -e "s|@TERMUX_PREFIX@|${TERMUX_PREFIX}|g" \ + "$TERMUX_PKG_BUILDER_DIR"/termux.py.in > \ + "$TERMUX_PKG_SRCDIR"/rpython/translator/platform/termux.py +} - # Get docker_pull.py - termux_download \ - $_docker_pull_url \ - $TERMUX_PKG_CACHEDIR/docker_pull.py \ - $_docker_pull_checksums +termux_step_pre_configure() { + if $TERMUX_ON_DEVICE_BUILD; then + termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds." + fi +} - # Get undocker.py +__setup_proot() { + mkdir -p "$TERMUX_PKG_CACHEDIR"/proot-bin termux_download \ - $_undocker_url \ - $TERMUX_PKG_CACHEDIR/undocker.py \ - $_undocker_checksums + 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" +} - # Get proot +__setup_qemu_static_binaries() { + mkdir -p "$TERMUX_PKG_CACHEDIR"/qemu-static-bin termux_download \ - $_proot_url \ - $PROOT \ - $_proot_checksums - - chmod +x $PROOT + 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" +} - # Get qemu-aarch64-static +__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 \ - $_qemu_aarch64_static_url \ - $TERMUX_PKG_CACHEDIR/qemu-aarch64-static \ - $_qemu_aarch64_static_checksums + https://raw.githubusercontent.com/larsks/undocker/649f3fdeb0a9cf8aa794d90d6cc6a7c7698a25e6/undocker.py \ + "$TERMUX_PKG_CACHEDIR"/docker-utils/undocker.py \ + 32bc122c53153abeb27491e6d45122eb8cef4f047522835bedf9b4b87877a907 +} - chmod +x $TERMUX_PKG_CACHEDIR/qemu-aarch64-static +__setup_termux_docker_rootfs() { + __setup_docker_utils - # Get qemu-arm-static - termux_download \ - $_qemu_arm_static_url \ - $TERMUX_PKG_CACHEDIR/qemu-arm-static \ - $_qemu_arm_static_checksums - - chmod +x $TERMUX_PKG_CACHEDIR/qemu-arm-static - - # Pick up host platform arch. - HOST_ARCH=$TERMUX_ARCH - if [ $TERMUX_ARCH = "arm" ]; then - HOST_ARCH="i686" - elif [ $TERMUX_ARCH = "aarch64" ]; then - HOST_ARCH="x86_64" + # 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" fi - # Get host platform rootfs tar if needed. - if [ ! -f "$TERMUX_PKG_CACHEDIR/termux_termux-docker_$HOST_ARCH.tar" ]; then + # Get host platform rootfs tar if needed + if [ ! -f "$TERMUX_PKG_CACHEDIR/termux_termux-docker_$__pypy3_host_arch.tar" ]; then ( - cd $TERMUX_PKG_CACHEDIR - $DOCKER_PULL ghcr.io/termux-user-repository/termux-docker:$HOST_ARCH - mv termux-user-repository_termux-docker.tar termux_termux-docker_$HOST_ARCH.tar + 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 - # Get target platform rootfs tar if needed. - if [ $HOST_ARCH != $TERMUX_ARCH ]; then - # Check qemu version, must greater than 6.0.0, since qemu 4/5 cannot run python - # inside the termux rootfs and will cause a segmentation fault, and qemu 6 hangs - # on clang++ - QEMU_VERSION=$($TERMUX_PKG_CACHEDIR/qemu-$TERMUX_ARCH-static --version | grep "version" | sed -E "s/.*?version (.*?)/\1/g") - QEMU_MAJOR_VERSION=${QEMU_VERSION%%.*} - if [ $QEMU_MAJOR_VERSION -lt '7' ]; then - termux_error_exit "qemu-user-static's version must be greater than 7.0.0" - fi - if [ ! -f "$TERMUX_PKG_CACHEDIR/termux_termux-docker_$TERMUX_ARCH.tar" ]; then - ( - cd $TERMUX_PKG_CACHEDIR - $DOCKER_PULL ghcr.io/termux-user-repository/termux-docker:$TERMUX_ARCH - mv termux-user-repository_termux-docker.tar termux_termux-docker_$TERMUX_ARCH.tar - ) - fi + # 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" + 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" 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 +https_proxy=$https_proxy +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 +} + +__run_on_host_docker_rootfs() { + $__pypy3_run_on_host "$@" +} + termux_step_configure() { - PYPY_USESSION_DIR=$TERMUX_ANDROID_HOME/tmp - PYPY_SRC_DIR=$TERMUX_ANDROID_HOME/src - - # Bootstrap a proot rootfs for the host platform - HOST_ROOTFS_BASE=$TERMUX_PKG_TMPDIR/host-rootfs - cat "$TERMUX_PKG_CACHEDIR/termux_termux-docker_$HOST_ARCH.tar" | $UNDOCKER -o $HOST_ROOTFS_BASE - - # Add build dependicies for pypy on the host platform rootfs - # Build essential - BUILD_DEP="binutils binutils-gold clang file patch pkg-config " - # Build dependencies for pypy - BUILD_DEP+=${TERMUX_PKG_DEPENDS//,/} - BUILD_DEP+=" " - BUILD_DEP+=${TERMUX_PKG_BUILD_DEPENDS//,/} - - # Environment variables for termux - TERMUX_RUNTIME_ENV_VARS="ANDROID_DATA=/data - ANDROID_ROOT=/system - HOME=$TERMUX_ANDROID_HOME - LANG=en_US.UTF-8 - PATH=$TERMUX_PREFIX/bin:/usr/bin - PREFIX=$TERMUX_PREFIX - TMPDIR=$TERMUX_PREFIX/tmp - TZ=UTC" - ln -s $HOST_ROOTFS_BASE/$TERMUX_ANDROID_HOME/ $TERMUX_ANDROID_HOME - ln -s $TERMUX_PKG_SRCDIR $PYPY_SRC_DIR - PROOT_HOST="env -i PROOT_NO_SECCOMP=1 - $TERMUX_RUNTIME_ENV_VARS - $PROOT - -b /proc -b /dev -b /sys - -b $HOME - -b $TERMUX_ANDROID_HOME - -w $TERMUX_ANDROID_HOME - -r $HOST_ROOTFS_BASE/" - # Get dependencies - $PROOT_HOST update-static-dns - sed -i "s/deb/deb [trusted=yes]/g" $HOST_ROOTFS_BASE/$TERMUX_PREFIX/etc/apt/sources.list - $PROOT_HOST apt update - $PROOT_HOST apt upgrade -yq -o Dpkg::Options::=--force-confnew - sed -i "s/deb/deb [trusted=yes]/g" $HOST_ROOTFS_BASE/$TERMUX_PREFIX/etc/apt/sources.list - $PROOT_HOST apt update - $PROOT_HOST apt install -o Dpkg::Options::=--force-confnew -yq $BUILD_DEP - $PROOT_HOST python2 -m pip install cffi pycparser - - # Copy the statically-built proot - cp $PROOT $HOST_ROOTFS_BASE/$TERMUX_PREFIX/bin/ - - # Extract the target platform rootfs to the host platform rootfs if needed. - PROOT_TARGET="$PROOT_HOST" - TARGET_ROOTFS_BASE="" - if [ $HOST_ARCH != $TERMUX_ARCH ]; then - TARGET_ROOTFS_BASE=$TERMUX_ANDROID_HOME/target-rootfs - mkdir -p $HOST_ROOTFS_BASE/$TARGET_ROOTFS_BASE - cat "$TERMUX_PKG_CACHEDIR/termux_termux-docker_$TERMUX_ARCH.tar" | $UNDOCKER -o $HOST_ROOTFS_BASE/$TARGET_ROOTFS_BASE - PROOT_TARGET="env -i PROOT_NO_SECCOMP=1 - $TERMUX_RUNTIME_ENV_VARS - $PROOT - -q $TERMUX_PKG_CACHEDIR/qemu-$TERMUX_ARCH-static - -b $HOME - -b $TERMUX_ANDROID_HOME - -b /proc -b /dev -b /sys - -w $TERMUX_ANDROID_HOME - -r $TARGET_ROOTFS_BASE" - # Check if it can be run with or without $PROOT_HOST - $PROOT_HOST $PROOT_TARGET uname -a - $PROOT_TARGET uname -a - # update-static-dns will use the arm busybox binary. - ${PROOT_TARGET/qemu-$TERMUX_ARCH-static/qemu-arm-static} update-static-dns - # FIXME: If we don't add `[trusted=yes]`, apt-key will generate an error. - # FIXME: The key(s) in the keyring XXX.gpg are ignored as the file is not readable by user '' executing apt-key. - sed -i "s/deb/deb [trusted=yes]/g" $HOST_ROOTFS_BASE/$TARGET_ROOTFS_BASE/$TERMUX_PREFIX/etc/apt/sources.list - $PROOT_TARGET apt update - $PROOT_TARGET apt install -o Dpkg::Options::=--force-confnew -yq dash - # Use dash to provide /system/bin/sh, since /system/bin/sh is a symbolic link - # to /system/bin/busybox which is a 32-bit binary. If we are using an aarch64 - # qemu, proot cannot execute it. - rm -f $HOST_ROOTFS_BASE/$TARGET_ROOTFS_BASE/system/bin/sh - $PROOT_TARGET ln -sf $TERMUX_PREFIX/bin/dash /system/bin/sh - # Get dependencies - $PROOT_TARGET apt update - $PROOT_TARGET apt upgrade -yq -o Dpkg::Options::=--force-confnew - sed -i "s/deb/deb [trusted=yes]/g" $HOST_ROOTFS_BASE/$TARGET_ROOTFS_BASE/$TERMUX_PREFIX/etc/apt/sources.list - $PROOT_TARGET apt update - $PROOT_TARGET apt install -o Dpkg::Options::=--force-confnew -yq $BUILD_DEP - # `pip2` is set up in the postinst script of `python2`, but it will segfault on aarch64. Install it manually. - $PROOT_TARGET python2 -m ensurepip - # Use the target rootfs providing $TERMUX_PREFIX - if [ ! -L $TERMUX_PREFIX ]; then - if [ -d $TERMUX_PREFIX.backup ]; then - rm -rf $TERMUX_PREFIX.backup - fi - mv $TERMUX_PREFIX $TERMUX_PREFIX.backup - ln -s $HOST_ROOTFS_BASE/$TARGET_ROOTFS_BASE/$TERMUX_PREFIX $TERMUX_PREFIX - fi - # Install cffi and pycparser - $PROOT_TARGET python2 -m pip install cffi pycparser - fi + __setup_proot + __setup_qemu_static_binaries + __setup_docker_utils + __setup_termux_docker_rootfs + __setup_termux_envs + + # 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" } termux_step_make() { - mkdir -p $HOST_ROOTFS_BASE/$PYPY_USESSION_DIR - - # Translation - $PROOT_HOST env -i \ - -C $PYPY_SRC_DIR/pypy/goal \ - $TERMUX_RUNTIME_ENV_VARS \ - PYPY_USESSION_DIR=$PYPY_USESSION_DIR \ - TARGET_ROOTFS_BASE=$TARGET_ROOTFS_BASE \ - PROOT_TARGET="$PROOT_TARGET" \ - $TERMUX_PREFIX/bin/python2 -u ../../rpython/bin/rpython \ - --platform=termux-$TERMUX_ARCH \ - --source --no-compile -Ojit \ - targetpypystandalone.py + 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 $PYPY_USESSION_DIR - cd $(ls -C | awk '{print $1}')/testing_1 - $PROOT_HOST env -C $(pwd) make clean - $PROOT_HOST env -C $(pwd) make -j$TERMUX_PKG_MAKE_PROCESSES + 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 $PYPY_SRC_DIR/pypy/goal/pypy$_MAJOR_VERSION-c || bash - cp ./libpypy$_MAJOR_VERSION-c.so $PYPY_SRC_DIR/pypy/goal/libpypy$_MAJOR_VERSION-c.so || bash - cp ./libpypy$_MAJOR_VERSION-c.so $HOST_ROOTFS_BASE/$TARGET_ROOTFS_BASE/$TERMUX_PREFIX/lib/libpypy$_MAJOR_VERSION-c.so || bash - - # Build cffi imports - TARGET_CFLAGS="-I$TERMUX_PREFIX/include -Wno-incompatible-function-pointer-types -Wno-implicit-function-declaration" - TARGET_LDFLAGS="-L$TERMUX_PREFIX/lib -fno-termux-rpath -Wl,-rpath=$TERMUX_PREFIX/lib" - $PROOT_TARGET env \ - CC=cc \ - TERMUX_STANDALONE_TOOLCHAIN=$TERMUX_STANDALONE_TOOLCHAIN \ - CFLAGS="$TARGET_CFLAGS" \ - LDFLAGS="$TARGET_LDFLAGS" \ - python2 $PYPY_SRC_DIR/pypy/tool/release/package.py \ - --archive-name=pypy$_MAJOR_VERSION-v$TERMUX_PKG_VERSION \ - --targetdir=$PYPY_SRC_DIR \ - --no-keep-debug - rm -f $TERMUX_PREFIX/lib/libpypy$_MAJOR_VERSION-c.so + 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 \ + --no-embedded-dependencies \ + --no-keep-debug || bash + + rm -f "$TERMUX_PREFIX"/lib/libpypy$_MAJOR_VERSION-c.so } termux_step_make_install() { - # Recover $TERMUX_PREFIX - if [ $HOST_ARCH != $TERMUX_ARCH ]; then - rm -rf $TERMUX_PREFIX - mv $TERMUX_PREFIX.backup $TERMUX_PREFIX - fi 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 @@ -303,7 +330,3 @@ termux_step_create_debscripts() { chmod 0755 prerm } - -termux_step_post_make_install() { - rm -rf $TERMUX_ANDROID_HOME -} diff --git a/packages/pypy3/cc.sh b/packages/pypy3/cc.sh new file mode 100644 index 00000000000000..5dcc3a99c81fd4 --- /dev/null +++ b/packages/pypy3/cc.sh @@ -0,0 +1,7 @@ +#!/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 new file mode 100644 index 00000000000000..3e3f43ac548eaa --- /dev/null +++ b/packages/pypy3/pypy3-tests.subpackage.sh @@ -0,0 +1,24 @@ +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 +" + +termux_step_create_subpkg_debscripts() { + # Pre-rm script to cleanup runtime-generated files. + cat <<- PRERM_EOF > ./prerm + #!$TERMUX_PREFIX/bin/sh + + if [ "$TERMUX_PACKAGE_FORMAT" != "pacman" ] && [ "\$1" != "remove" ]; then + exit 0 + fi + + echo "Deleting *.pyc..." + find $TERMUX_PREFIX/opt/pypy3/lib-python | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf + + exit 0 + PRERM_EOF + + chmod 0755 prerm +} diff --git a/packages/pypy3/termux.py.in b/packages/pypy3/termux.py.in new file mode 100644 index 00000000000000..be5014b4189fa5 --- /dev/null +++ b/packages/pypy3/termux.py.in @@ -0,0 +1,146 @@ +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 ("-I@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"