aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2021-06-13 01:37:05 +0200
committerJakub Jirutka <jakub@jirutka.cz>2021-06-13 03:13:33 +0200
commitc12fb28e6d794fa1cb9ceda035d06edbff432c29 (patch)
tree6a35c1fa1d1668308718495c25ac3c78ca36c364
parent6a1dbebf445a9d8f27e2f5b28492834e20d034b8 (diff)
downloadaports-c12fb28e6d794fa1cb9ceda035d06edbff432c29.tar.gz
aports-c12fb28e6d794fa1cb9ceda035d06edbff432c29.tar.bz2
aports-c12fb28e6d794fa1cb9ceda035d06edbff432c29.tar.xz
main/luajit: switch to OpenResty's maintained branch
The MoonJIT fork is unmaintained since September 2020 [1]: > This code base does not have an active maintainer anymore, please > read this [Twitter thread][2] to know more. If you are an existing > contributor (or otherwise have an interest in maintaining this > project actively) then please email me using the email address in > my Twitter profile. Moreover, the transition from original LuaJIT to MoonJIT caused multiple compatibility and stability issues, mainly with Lua NGINX module (#12410, #10478), but also with some Lua packages written in C (segfaults). I wanted to switch back to the original (Mike's) LuaJIT, the latest revision from the v2.1 branch. The problem is that it doesn't support ppc64le and s390x. The existing patches don't apply anymore and I really don't have enough knowledge and insanity in blood to update them. Dropping these architectures would require updating many dependent aports which is not a good idea at this moment (v3.14 will be released very soon). OpenResty's "fork" seems to be the only active LuaJIT fork that regularly synchronize changes from the upstream LuaJIT project and provides support for all architectures we need. > This is the official OpenResty branch of LuaJIT. It is not to be > considered a fork, since we still regularly synchronize changes from the > upstream LuaJIT project Patches CVE-2020-15890 and 20-src-lib_string are already included in the OpenResty's branch. [1]: https://github.com/moonjit/moonjit/commit/a2a39ea7184f3c8cab9474c6e41f6541265fb362: [2]: https://twitter.com/siddhesh_p/status/1308594269502885889 Resolves #12410 #10478
-rw-r--r--main/luajit/20-src-lib_string.patch30
-rw-r--r--main/luajit/APKBUILD82
-rw-r--r--main/luajit/CVE-2020-15890.patch22
-rw-r--r--main/luajit/fix-compilation-error-on-ppc.patch26
-rw-r--r--main/luajit/fix-lual_newstate-returns-null-on-ppc64le.patch24
-rw-r--r--main/luajit/fix-tests-alpine.patch88
-rw-r--r--main/luajit/module-paths.patch (renamed from main/luajit/10-module-paths.patch)0
7 files changed, 190 insertions, 82 deletions
diff --git a/main/luajit/20-src-lib_string.patch b/main/luajit/20-src-lib_string.patch
deleted file mode 100644
index f04d83b417..0000000000
--- a/main/luajit/20-src-lib_string.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-see https://github.com/moonjit/moonjit/issues/86
-
-Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
----
- src/lib_string.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/lib_string.c b/src/lib_string.c
-index 5e2891a9e..a90e189ba 100644
---- a/src/lib_string.c
-+++ b/src/lib_string.c
-@@ -621,7 +621,7 @@ LJLIB_CF(string_gsub)
- const char *p = luaL_checklstring(L, 2, &lp);
- int tr = lua_type(L, 3);
- int max_s = luaL_optint(L, 4, (int)(srcl+1));
-- int anchor = (*p == '^') ? (p++, 1) : 0;
-+ int anchor = (*p == '^');
- int n = 0;
- MatchState ms;
- luaL_Buffer b;
-@@ -629,6 +629,9 @@ LJLIB_CF(string_gsub)
- tr == LUA_TFUNCTION || tr == LUA_TTABLE))
- lj_err_arg(L, 3, LJ_ERR_NOSFT);
- luaL_buffinit(L, &b);
-+ if (anchor) {
-+ p++; lp--; /* skip anchor character */
-+ }
- ms.L = L;
- ms.src_init = src;
- ms.src_end = src+srcl;
diff --git a/main/luajit/APKBUILD b/main/luajit/APKBUILD
index 12daa72e7c..5e846e8d25 100644
--- a/main/luajit/APKBUILD
+++ b/main/luajit/APKBUILD
@@ -1,41 +1,61 @@
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
# Contributor: Bartłomiej Piotrowski <nospam@bpiotrowski.pl>
pkgname=luajit
-_pkgname=moonjit
-pkgver=2.2.0
-pkgrel=3
-pkgdesc="Integration fork of the original LuaJIT"
-url="https://github.com/moonjit/moonjit"
+_pkgname=luajit2
+pkgver=2.1_p20210510
+_pkgver=${pkgver/_p/-}
+pkgrel=0
+_gitrev_tests=485311ff265763c2aecce155ad697a974838857c
+pkgdesc="OpenResty's branch of LuaJIT"
+url="https://github.com/openresty/luajit2"
arch="all !riscv64"
license="MIT"
+checkdepends="
+ perl
+ perl-parallel-forkmanager
+ sqlite-dev
+ zlib-dev
+ "
provides="lua"
subpackages="$pkgname-dev $pkgname-doc"
-source="$_pkgname-$pkgver.tar.gz::https://github.com/moonjit/moonjit/archive/$pkgver.tar.gz
- 10-module-paths.patch
- 20-src-lib_string.patch
- CVE-2020-15890.patch
+source="https://github.com/openresty/luajit2/archive/v$_pkgver/$_pkgname-$_pkgver.tar.gz
+ https://github.com/openresty/luajit2-test-suite/archive/$_gitrev_tests/luajit2-test-suite-$_gitrev_tests.tar.gz
+ fix-lual_newstate-returns-null-on-ppc64le.patch
+ fix-compilation-error-on-ppc.patch
+ fix-tests-alpine.patch
+ module-paths.patch
"
-builddir="$srcdir/$_pkgname-$pkgver"
+builddir="$srcdir/$_pkgname-$_pkgver"
+
+prepare() {
+ cp -Rl ../luajit2-test-suite-$_gitrev_tests test-suite
+
+ default_prepare
-# secfixes:
-# 2.2.0-r3:
-# - CVE-2020-15890
+ case "$CARCH" in
+ # bit.tobit test failed (got 280328, expected 277312)
+ arm*) rm test-suite/test/misc/bit_op.lua;;
+ # 35: declaration specifier expected near '_Alignas' at line 882
+ x86) rm test-suite/test/sysdep/ffi_include_std.lua;;
+ esac
+}
build() {
- make amalg PREFIX=/usr
+ # These flags are recommended by OpenResty.
+ local xcflags="-DLUAJIT_ENABLE_LUA52COMPAT -DLUAJIT_NUMMODE=2"
+ [ "$CARCH" = x86_64 ] && xcflags="$xcflags -msse4.2"
+
+ make amalg PREFIX=/usr XCFLAGS="$xcflags"
}
check() {
- # tests fail
- sed -i -e '/redir.lua/d' test/lib/ffi/index
- case $CARCH in
- ppc64le|s390x) sed -i -e '/math_special.lua/d' test/unportable/index;;
- armv7|armhf)
- sed -i -e '/math_special.lua/d' test/unportable/index
- sed -i -e '/bit.lua/d' test/lib/index
- ;;
- esac
- make check
+ local prefix="$builddir/test-suite/target"
+ mkdir -p "$prefix"
+
+ make install PREFIX="$prefix"
+
+ cd test-suite
+ LUA52=1 ./run-tests "$prefix"
}
package() {
@@ -43,11 +63,13 @@ package() {
install -Dm644 COPYRIGHT \
"$pkgdir"/usr/share/licenses/$pkgname/COPYRIGHT
-
- cd "$pkgdir"/usr/include && ln -s moonjit-2.2 luajit
}
-sha512sums="a940dd9973801f7067e376d62ec70ab5fbf635f59c648dcb45072f55290a6752abb3b1fa307bdd81d4bf05c719338e8fbda143f62861c61cb66b34cc9e8e7d54 moonjit-2.2.0.tar.gz
-9c6c410e142838c5128c70570e66beb53cc5422df5ecfb8ab0b5f362637b21ab5978c00f19bc1759165df162fd6438a2ed43e25020400011b7bb14014d87c62e 10-module-paths.patch
-9d87e944580fe7a3c24e043012dbdacf5141bafb5ea83dc141c42f6641b8df117d1779c3c50ee9fccc58e625a0bc04c64dd75ab0c1815bbbf2a2e645ec0ff85e 20-src-lib_string.patch
-d227f22f1b7776f36b8a1e1471e6fcb3a2442037e09fcd0f4d489c3853a5cb2916b02cd6ab0194105989502b76bcb03e97ea1825d21212a534344afe96e3448c CVE-2020-15890.patch"
+sha512sums="
+c94b2c000f923f53bab88f5f90da74b3ac813fcf153d989a03b816654a26c5d50b7e5a2a70a86a0e8784431377d48f9be1635399e030d4882a0609ed786c87fb luajit2-2.1-20210510.tar.gz
+87995ffd648ca57049dadda12fa563a8c47c7735c0a34471372eeedaf4023361cf20824118e478e4466e3063ef864aa6b5ab0bbca1a5e0a3a5ef7ff044151deb luajit2-test-suite-485311ff265763c2aecce155ad697a974838857c.tar.gz
+57a60839c4416227bb0995ad0ae98f973b6bd82155fda2e6a1c8369d662d470b733582d4aeff6181771ea496d4d8af6aa684c0b45734abc5b1fd0d91d54f20bb fix-lual_newstate-returns-null-on-ppc64le.patch
+7eaf1c9f73127c7bd321cc0d4f4d9c1db87cc9ff672936a98e2f9f247aca7bdc570fc54120e90cf9bc1dc74f48d65f340f600a2bb93fd22fe1904d957a8172ec fix-compilation-error-on-ppc.patch
+9702eb7f51d52ef97be0fb5c7369bde9ce229444ae05e5387e3d1144acc03391f225ede07a7fd3799ca749a916c1d934dbac383c36720ba2e13b1bc19d8df1a5 fix-tests-alpine.patch
+9c6c410e142838c5128c70570e66beb53cc5422df5ecfb8ab0b5f362637b21ab5978c00f19bc1759165df162fd6438a2ed43e25020400011b7bb14014d87c62e module-paths.patch
+"
diff --git a/main/luajit/CVE-2020-15890.patch b/main/luajit/CVE-2020-15890.patch
deleted file mode 100644
index 751726571a..0000000000
--- a/main/luajit/CVE-2020-15890.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 53f82e6e2e858a0a62fd1a2ff47e9866693382e6 Mon Sep 17 00:00:00 2001
-From: Mike Pall <mike>
-Date: Sun, 12 Jul 2020 14:30:34 +0200
-Subject: [PATCH] Fix frame traversal for __gc handler frames.
-
-Reported by Changochen.
----
- src/lj_err.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/lj_err.c b/src/lj_err.c
-index caa7487f2..e3e0c2eb7 100644
---- a/src/lj_err.c
-+++ b/src/lj_err.c
-@@ -529,6 +529,7 @@ static ptrdiff_t finderrfunc(lua_State *L)
- if (cframe_canyield(cf)) return 0;
- if (cframe_errfunc(cf) >= 0)
- return cframe_errfunc(cf);
-+ cf = cframe_prev(cf);
- frame = frame_prevd(frame);
- break;
- case FRAME_PCALL:
diff --git a/main/luajit/fix-compilation-error-on-ppc.patch b/main/luajit/fix-compilation-error-on-ppc.patch
new file mode 100644
index 0000000000..a00e948a87
--- /dev/null
+++ b/main/luajit/fix-compilation-error-on-ppc.patch
@@ -0,0 +1,26 @@
+From 4d080589ada785636bf440e3e8afe9947671f406 Mon Sep 17 00:00:00 2001
+From: Maniraj Deivendran <maniraj.deivendran@ibm.com>
+Date: Tue, 1 Jun 2021 09:14:02 +0000
+Subject: [PATCH] Change: Resolve compilation error in ppc
+
+---
+ src/lj_ccallback.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+Patch-Source: https://github.com/openresty/luajit2/pull/124
+
+diff --git a/src/lj_ccallback.c b/src/lj_ccallback.c
+index 3dbf1e9c..568ab336 100644
+--- a/src/lj_ccallback.c
++++ b/src/lj_ccallback.c
+@@ -21,6 +21,10 @@
+ #include "lj_trace.h"
+ #include "lj_vm.h"
+
++#if LJ_ARCH_PPC_ELFV2
++#include "lualib.h"
++#endif
++
+ /* -- Target-specific handling of callback slots -------------------------- */
+
+ #define CALLBACK_MCODE_SIZE (LJ_PAGESIZE * LJ_NUM_CBPAGE)
diff --git a/main/luajit/fix-lual_newstate-returns-null-on-ppc64le.patch b/main/luajit/fix-lual_newstate-returns-null-on-ppc64le.patch
new file mode 100644
index 0000000000..95fda15545
--- /dev/null
+++ b/main/luajit/fix-lual_newstate-returns-null-on-ppc64le.patch
@@ -0,0 +1,24 @@
+From e1c27418c7d3dc6161a70e119e588091957c80b9 Mon Sep 17 00:00:00 2001
+From: Maniraj Deivendran <maniraj.deivendran@ibm.com>
+Date: Tue, 1 Jun 2021 08:27:51 +0000
+Subject: [PATCH] Change: Resolve luaL_newstate() return NULL in ppc64le issue
+
+---
+ src/lj_def.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Patch-Source: https://github.com/openresty/luajit2/pull/123
+
+diff --git a/src/lj_def.h b/src/lj_def.h
+index 68ae3d51..56362092 100644
+--- a/src/lj_def.h
++++ b/src/lj_def.h
+@@ -111,7 +111,7 @@ typedef unsigned int uintptr_t;
+ #define checkptr31(x) (((uint64_t)(uintptr_t)(x) >> 31) == 0)
+ #define checkptr32(x) ((uintptr_t)(x) == (uint32_t)(uintptr_t)(x))
+ #define checkptr47(x) (((uint64_t)(uintptr_t)(x) >> 47) == 0)
+-#define checkptrGC(x) (LJ_GC64 ? checkptr47((x)) : LJ_64 ? checkptr31((x)) :1)
++#define checkptrGC(x) (LJ_GC64 ? checkptr47((x)) : LJ_64 ? checkptr32((x)) :1)
+
+ /* Every half-decent C compiler transforms this into a rotate instruction. */
+ #define lj_rol(x, n) (((x)<<(n)) | ((x)>>(-(int)(n)&(8*sizeof(x)-1))))
diff --git a/main/luajit/fix-tests-alpine.patch b/main/luajit/fix-tests-alpine.patch
new file mode 100644
index 0000000000..3a93009852
--- /dev/null
+++ b/main/luajit/fix-tests-alpine.patch
@@ -0,0 +1,88 @@
+Fix tests to pass on musl and also avoid extra dependencies (e.g. ncurses, mpc, ...).
+
+--- a/test-suite/run-tests
++++ b/test-suite/run-tests
+@@ -73,14 +73,6 @@
+
+ $ENV{LUA_CPATH} = "$cwd/test/clib/?;;";
+
+-my $cmd = "pkg-config --cflags --libs gtk+-2.0";
+-my $cdefs = `$cmd`;
+-if ($? != 0) {
+- die "failed to run command $cmd: $?";
+-}
+-chomp $cdefs;
+-$ENV{CDEFS} = $cdefs;
+-
+ if (@ARGV) {
+ for my $test_file (@ARGV) {
+ my ($dir, $fname);
+--- a/test-suite/test/ffi/ffi_redir.lua
++++ b/test-suite/test/ffi/ffi_redir.lua
+@@ -12,7 +12,7 @@
+ ]]
+ else
+ ffi.cdef[[
+- int bar asm("errno");
++ int bar asm("opterr");
+ ]]
+ end
+
+--- a/test-suite/test/sysdep/ffi_include_gtk.lua
++++ b/test-suite/test/sysdep/ffi_include_gtk.lua
+@@ -1,9 +0,0 @@
+-local ffi = require("ffi")
+-
+-dofile("../common/ffi_util.inc")
+-
+-if cdefs == "" then
+- cdefs = "-pthread -D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gdk-pixbuf-2.0"
+-end
+-
+-include"/usr/include/gtk-2.0/gtk/gtk.h"
+--- a/test-suite/test/sysdep/ffi_include_std.lua
++++ b/test-suite/test/sysdep/ffi_include_std.lua
+@@ -14,15 +14,8 @@
+ #define _Float128 long double
+
+ #include <sqlite3.h>
+-#include <thread_db.h>
+ #include <resolv.h>
+-#include <mpfr.h>
+-#include <mpc.h>
+-#include <curses.h>
+-#include <form.h>
+ #include <aio.h>
+-#include <unistd.h>
+-#include <zlib.h>
+ #include <netdb.h>
+ #include <math.h>
+ #include <tgmath.h>
+--- a/test-suite/test/sysdep/ffi_lib_c.lua
++++ b/test-suite/test/sysdep/ffi_lib_c.lua
+@@ -7,6 +7,9 @@
+ int rmdir(const char *name);
+ int errno;
+
++// musl libc
++int *__errno_location(void);
++
+ // Windows
+ unsigned int GetSystemDirectoryA(char *buf, unsigned int sz);
+ char *CharUpperA(char *str);
+@@ -62,11 +65,11 @@
+ ffi.C._fmode = ffi.C._O_TEXT
+ else
+ assert(ffi.C.rmdir("/tmp/does_not_exist") == -1)
+- assert(ffi.C.errno == 2)
++ assert(ffi.C.__errno_location()[0] == 2)
+
+- ffi.C.errno = 17
+- assert(ffi.C.errno == 17)
+- ffi.C.errno = 0
++ ffi.C.__errno_location()[0] = 17
++ assert(ffi.C.__errno_location()[0] == 17)
++ ffi.C.__errno_location()[0] = 0
+ end
+
+ do
diff --git a/main/luajit/10-module-paths.patch b/main/luajit/module-paths.patch
index 46e8d12cf5..46e8d12cf5 100644
--- a/main/luajit/10-module-paths.patch
+++ b/main/luajit/module-paths.patch