diff mbox series

Revert "package/luajit: back to mainline and bump to 05f1984e"

Message ID 20211106190057.2487641-1-romain.naour@gmail.com
State Superseded
Headers show
Series Revert "package/luajit: back to mainline and bump to 05f1984e" | expand

Commit Message

Romain Naour Nov. 6, 2021, 7 p.m. UTC
This reverts commit 9450b53c8e06f1b5a75840b82c0f4663a5d75c45 since it
introcude a regretion to luvi package [1].

luvi doesn't work since the luv static linking doesn't seems to
work anymore.
(see https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c08622d70f6b7067)

 # luvi -v

[string "return require('init')(...)"]:1: module 'init' not found:

	no field package.preload['init']
	no file './init.lua'
	no file '/usr/share/luajit-2.1.0-beta3/init.lua'
	no file '/usr/local/share/lua/5.1/init.lua'
	no file '/usr/local/share/lua/5.1/init/init.lua'
	no file '/usr/share/lua/5.1/init.lua'
	no file '/usr/share/lua/5.1/init/init.lua'
	no file './init.so'
	no file '/usr/local/lib/lua/5.1/init.so'
	no file '/usr/lib/lua/5.1/init.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'

stack traceback:
	[C]: in function 'require'
	[string "return require('init')(...)"]:1: in main chunk

luvi now try to load init.lua script:
https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176

Luvi seems to rely on some moonjit extentions [2] not available yet in
luajit.

[1] http://lists.busybox.net/pipermail/buildroot/2021-October/627134.html
[2] https://github.com/moonjit/moonjit/blob/master/doc/extensions.md

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Francois Perrad <francois.perrad@gadz.org>
Cc: Jörg Krause <joerg.krause@embedded.rocks>
---
 package/luajit/Config.in   | 2 +-
 package/luajit/luajit.hash | 4 ++--
 package/luajit/luajit.mk   | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

Comments

Francois Perrad Nov. 6, 2021, 9:19 p.m. UTC | #1
Le sam. 6 nov. 2021 à 20:01, Romain Naour <romain.naour@gmail.com> a écrit :

> This reverts commit 9450b53c8e06f1b5a75840b82c0f4663a5d75c45 since it
> introcude a regretion to luvi package [1].
>
> luvi doesn't work since the luv static linking doesn't seems to
> work anymore.
> (see
> https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c08622d70f6b7067
> )
>
>  # luvi -v
>
> [string "return require('init')(...)"]:1: module 'init' not found:
>
>         no field package.preload['init']
>         no file './init.lua'
>         no file '/usr/share/luajit-2.1.0-beta3/init.lua'
>         no file '/usr/local/share/lua/5.1/init.lua'
>         no file '/usr/local/share/lua/5.1/init/init.lua'
>         no file '/usr/share/lua/5.1/init.lua'
>         no file '/usr/share/lua/5.1/init/init.lua'
>         no file './init.so'
>         no file '/usr/local/lib/lua/5.1/init.so'
>         no file '/usr/lib/lua/5.1/init.so'
>         no file '/usr/local/lib/lua/5.1/loadall.so'
>
> stack traceback:
>         [C]: in function 'require'
>         [string "return require('init')(...)"]:1: in main chunk
>
> luvi now try to load init.lua script:
> https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176
>
> Luvi seems to rely on some moonjit extentions [2] not available yet in
> luajit.
>
> [1] http://lists.busybox.net/pipermail/buildroot/2021-October/627134.html
> [2] https://github.com/moonjit/moonjit/blob/master/doc/extensions.md
>
>
the module `init.lua` is supplied by luvi (see
https://github.com/luvit/luvi/blob/master/src/lua/init.lua)
and installed somewhere or not (I cannot find it).

moonjit 2.1.2 try to load a Lua module from these locations :
    './init.lua'
    '/usr/share/luajit-2.1.2/init.lua' (usually reserved to luajit itself)
    '/usr/local/share/lua/5.1/init.lua'
    '/usr/local/share/lua/5.1/init/init.lua'
    '/usr/share/lua/5.1/init.lua'
    '/usr/share/lua/5.1/init/init.lua'

luajit try to load a Lua module from these locations :
    './init.lua'
    '/usr/share/luajit-2.1.0-beta3/init.lua' (usually reserved to luajit
itself)
    '/usr/local/share/lua/5.1/init.lua'
    '/usr/local/share/lua/5.1/init/init.lua'
    '/usr/share/lua/5.1/init.lua'
    '/usr/share/lua/5.1/init/init.lua'

this issue is not about moonjit vs luajit,
it is about `init.lua` is not installed by luvi package.

François


> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> Cc: Francois Perrad <francois.perrad@gadz.org>
> Cc: Jörg Krause <joerg.krause@embedded.rocks>
>
>
Romain Naour Nov. 6, 2021, 10:02 p.m. UTC | #2
Le 06/11/2021 à 22:19, François Perrad a écrit :
> 
> 
> Le sam. 6 nov. 2021 à 20:01, Romain Naour <romain.naour@gmail.com
> <mailto:romain.naour@gmail.com>> a écrit :
> 
>     This reverts commit 9450b53c8e06f1b5a75840b82c0f4663a5d75c45 since it
>     introcude a regretion to luvi package [1].
> 
>     luvi doesn't work since the luv static linking doesn't seems to
>     work anymore.
>     (see
>     https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c08622d70f6b7067 <https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c08622d70f6b7067>)
> 
>      # luvi -v
> 
>     [string "return require('init')(...)"]:1: module 'init' not found:
> 
>             no field package.preload['init']
>             no file './init.lua'
>             no file '/usr/share/luajit-2.1.0-beta3/init.lua'
>             no file '/usr/local/share/lua/5.1/init.lua'
>             no file '/usr/local/share/lua/5.1/init/init.lua'
>             no file '/usr/share/lua/5.1/init.lua'
>             no file '/usr/share/lua/5.1/init/init.lua'
>             no file './init.so'
>             no file '/usr/local/lib/lua/5.1/init.so'
>             no file '/usr/lib/lua/5.1/init.so'
>             no file '/usr/local/lib/lua/5.1/loadall.so'
> 
>     stack traceback:
>             [C]: in function 'require'
>             [string "return require('init')(...)"]:1: in main chunk
> 
>     luvi now try to load init.lua script:
>     https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176
>     <https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176>
> 
>     Luvi seems to rely on some moonjit extentions [2] not available yet in
>     luajit.
> 
>     [1] http://lists.busybox.net/pipermail/buildroot/2021-October/627134.html
>     <http://lists.busybox.net/pipermail/buildroot/2021-October/627134.html>
>     [2] https://github.com/moonjit/moonjit/blob/master/doc/extensions.md
>     <https://github.com/moonjit/moonjit/blob/master/doc/extensions.md>
> 
> 
> the module `init.lua` is supplied by luvi (see
> https://github.com/luvit/luvi/blob/master/src/lua/init.lua
> <https://github.com/luvit/luvi/blob/master/src/lua/init.lua>)
> and installed somewhere or not (I cannot find it).
> 
> moonjit 2.1.2 try to load a Lua module from these locations :
>     './init.lua'
>     '/usr/share/luajit-2.1.2/init.lua' (usually reserved to luajit itself)
>     '/usr/local/share/lua/5.1/init.lua'
>     '/usr/local/share/lua/5.1/init/init.lua'
>     '/usr/share/lua/5.1/init.lua'
>     '/usr/share/lua/5.1/init/init.lua'
> 
> luajit try to load a Lua module from these locations :
>     './init.lua'
>     '/usr/share/luajit-2.1.0-beta3/init.lua' (usually reserved to luajit itself)
>     '/usr/local/share/lua/5.1/init.lua'
>     '/usr/local/share/lua/5.1/init/init.lua'
>     '/usr/share/lua/5.1/init.lua'
>     '/usr/share/lua/5.1/init/init.lua'
> 
> this issue is not about moonjit vs luajit,

The luajit vs moonjit traces are clearly not the same (using strace)

moonjit doesn't even try to open init.lua (init.lua is not installed in target):

open("/usr/bin/luvi", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 13
statx(13, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL,
{stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0,
stx_mode=S_IFREG|0755, stx_size=401472, ...}) = 0
pread64(13,
"\213\240\5\0h'\4\0\373\277\5\0X5\4\0\342\305\5\0t-\4\0G\260\5\0\34'\4\0"...,
4096, 397376) = 4096
pread64(13,
"\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\351\232\5\0K\253\5\0\361\232\5\0\367\232\5"...,
4096, 393283) = 4096
pread64(13,
"\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N"...,
4096, 389190) = 4096
pread64(13, "ed\0lz.inflate.meta\0BEST_SPEED\0BE"..., 4096, 385097) = 4096
pread64(13, "Luvi/build/luvi-2.12.0/deps/lua-"..., 4096, 381004) = 4096
pread64(13, "ept fail\0#1 BIO must be memory t"..., 4096, 376911) = 4096
pread64(13, "scape_ca_dn_bug\0netscape_challen"..., 4096, 372818) = 4096
pread64(13, " to cert\0PKCS12_careate failed,p"..., 4096, 368725) = 4096
pread64(13,
"\200+\10\0\0-\t\0\08\t\7\t9\t\0\t\22\n\0\0B\t\2\3\22\3\n\0\22\10\t"..., 4096,
364632) = 4096
pread64(13, "'\7\2\0\22\10\2\0\22\t\3\0B\5\5\2&\4\5\4L\4\2\0K\0\1\0\6\\\6/"...,
4096, 360539) = 4096
pread64(13, "ve is too large\0validation faile"..., 4096, 356446) = 4096
pread64(13,
"\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21"...,
4096, 352353) = 4096
pread64(13,
"TP\237\345\3p\300\343\200\1\240\341\30`\0\342H\200\237\345\25V\240\341\1\220\240\341\0\0\227\345"...,
4096, 348260) = 4096
pread64(13,
"\1#\0\0:\1\0P\341\32\0\0\232\2\0\21\341\33\0\0\n\21?o\341\20/o\341\2 C"...,
4096, 344167) = 4096
pread64(13,
"\215\342\4\360\235\344\363G-\351\34\221\237\345\0`\240\341\0@\240\343\2p\240\341\f\0\220\345\4
"..., 4096, 340074) = 4096
pread64(13,
"!\315\341\3\0\226\350\276\v\377\353\f\0p\343\0\0P\23\0p\240\341%\0\0\272\0\0P\343\0"...,
4096, 335981) = 4096
pread64(13, "@\26\377\353\0\0P\343\n\0\0\32\4\0\235\345\326\f\0\353\0
\240\341\0010\240\341\4\0\240\341"..., 4096, 331888) = 4096
write(1, "luvi v2.12.0\n", 13luvi v2.12.0


luajit:

pipe2([6, 7], O_NONBLOCK|O_CLOEXEC)     = 0
eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 8
open("./init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/usr/share/luajit-2.1.0-beta3/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT
(No such file or directory)
open("/usr/local/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No
such file or directory)
open("/usr/local/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT
(No such file or directory)
open("/usr/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such
file or directory)
open("/usr/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No
such file or directory)
open("./init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No
such file or directory)
open("/usr/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file
or directory)
open("/usr/local/lib/lua/5.1/loadall.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No
such file or directory)
write(2, "[string \"return require('init')("..., 596[string "return
require('init')(...)"]:1: module 'init' not found:

Something is strange here...

Best regards,
Romain


> it is about `init.lua` is not installed by luvi package.
> 
> François
>  
> 
>     Signed-off-by: Romain Naour <romain.naour@gmail.com
>     <mailto:romain.naour@gmail.com>>
>     Cc: Francois Perrad <francois.perrad@gadz.org <mailto:francois.perrad@gadz.org>>
>     Cc: Jörg Krause <joerg.krause@embedded.rocks>
>
Francois Perrad Nov. 7, 2021, 8:30 a.m. UTC | #3
Le sam. 6 nov. 2021 à 23:02, Romain Naour <romain.naour@gmail.com> a écrit :

> Le 06/11/2021 à 22:19, François Perrad a écrit :
> >
> >
> > Le sam. 6 nov. 2021 à 20:01, Romain Naour <romain.naour@gmail.com
> > <mailto:romain.naour@gmail.com>> a écrit :
> >
> >     This reverts commit 9450b53c8e06f1b5a75840b82c0f4663a5d75c45 since it
> >     introcude a regretion to luvi package [1].
> >
> >     luvi doesn't work since the luv static linking doesn't seems to
> >     work anymore.
> >     (see
> >
> https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c08622d70f6b7067
> <
> https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c08622d70f6b7067
> >)
> >
> >      # luvi -v
> >
> >     [string "return require('init')(...)"]:1: module 'init' not found:
> >
> >             no field package.preload['init']
> >             no file './init.lua'
> >             no file '/usr/share/luajit-2.1.0-beta3/init.lua'
> >             no file '/usr/local/share/lua/5.1/init.lua'
> >             no file '/usr/local/share/lua/5.1/init/init.lua'
> >             no file '/usr/share/lua/5.1/init.lua'
> >             no file '/usr/share/lua/5.1/init/init.lua'
> >             no file './init.so'
> >             no file '/usr/local/lib/lua/5.1/init.so'
> >             no file '/usr/lib/lua/5.1/init.so'
> >             no file '/usr/local/lib/lua/5.1/loadall.so'
> >
> >     stack traceback:
> >             [C]: in function 'require'
> >             [string "return require('init')(...)"]:1: in main chunk
> >
> >     luvi now try to load init.lua script:
> >     https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176
> >     <https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176>
> >
> >     Luvi seems to rely on some moonjit extentions [2] not available yet
> in
> >     luajit.
> >
> >     [1]
> http://lists.busybox.net/pipermail/buildroot/2021-October/627134.html
> >     <
> http://lists.busybox.net/pipermail/buildroot/2021-October/627134.html>
> >     [2] https://github.com/moonjit/moonjit/blob/master/doc/extensions.md
> >     <https://github.com/moonjit/moonjit/blob/master/doc/extensions.md>
> >
> >
> > the module `init.lua` is supplied by luvi (see
> > https://github.com/luvit/luvi/blob/master/src/lua/init.lua
> > <https://github.com/luvit/luvi/blob/master/src/lua/init.lua>)
> > and installed somewhere or not (I cannot find it).
> >
> > moonjit 2.1.2 try to load a Lua module from these locations :
> >     './init.lua'
> >     '/usr/share/luajit-2.1.2/init.lua' (usually reserved to luajit
> itself)
> >     '/usr/local/share/lua/5.1/init.lua'
> >     '/usr/local/share/lua/5.1/init/init.lua'
> >     '/usr/share/lua/5.1/init.lua'
> >     '/usr/share/lua/5.1/init/init.lua'
> >
> > luajit try to load a Lua module from these locations :
> >     './init.lua'
> >     '/usr/share/luajit-2.1.0-beta3/init.lua' (usually reserved to luajit
> itself)
> >     '/usr/local/share/lua/5.1/init.lua'
> >     '/usr/local/share/lua/5.1/init/init.lua'
> >     '/usr/share/lua/5.1/init.lua'
> >     '/usr/share/lua/5.1/init/init.lua'
> >
> > this issue is not about moonjit vs luajit,
>
> The luajit vs moonjit traces are clearly not the same (using strace)
>
> moonjit doesn't even try to open init.lua (init.lua is not installed in
> target):
>
> open("/usr/bin/luvi", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 13
> statx(13, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL,
> {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0,
> stx_mode=S_IFREG|0755, stx_size=401472, ...}) = 0
> pread64(13,
>
> "\213\240\5\0h'\4\0\373\277\5\0X5\4\0\342\305\5\0t-\4\0G\260\5\0\34'\4\0"...,
> 4096, 397376) = 4096
> pread64(13,
>
> "\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\351\232\5\0K\253\5\0\361\232\5\0\367\232\5"...,
> 4096, 393283) = 4096
> pread64(13,
>
> "\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N"...,
> 4096, 389190) = 4096
> pread64(13, "ed\0lz.inflate.meta\0BEST_SPEED\0BE"..., 4096, 385097) = 4096
> pread64(13, "Luvi/build/luvi-2.12.0/deps/lua-"..., 4096, 381004) = 4096
> pread64(13, "ept fail\0#1 BIO must be memory t"..., 4096, 376911) = 4096
> pread64(13, "scape_ca_dn_bug\0netscape_challen"..., 4096, 372818) = 4096
> pread64(13, " to cert\0PKCS12_careate failed,p"..., 4096, 368725) = 4096
> pread64(13,
> "\200+\10\0\0-\t\0\08\t\7\t9\t\0\t\22\n\0\0B\t\2\3\22\3\n\0\22\10\t"...,
> 4096,
> 364632) = 4096
> pread64(13,
> "'\7\2\0\22\10\2\0\22\t\3\0B\5\5\2&\4\5\4L\4\2\0K\0\1\0\6\\\6/"...,
> 4096, 360539) = 4096
> pread64(13, "ve is too large\0validation faile"..., 4096, 356446) = 4096
> pread64(13,
>
> "\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21"...,
> 4096, 352353) = 4096
> pread64(13,
>
> "TP\237\345\3p\300\343\200\1\240\341\30`\0\342H\200\237\345\25V\240\341\1\220\240\341\0\0\227\345"...,
> 4096, 348260) = 4096
> pread64(13,
> "\1#\0\0:\1\0P\341\32\0\0\232\2\0\21\341\33\0\0\n\21?o\341\20/o\341\2
> C"...,
> 4096, 344167) = 4096
> pread64(13,
> "\215\342\4\360\235\344\363G-\351\34\221\237\345\0`\240\341\0@
> \240\343\2p\240\341\f\0\220\345\4
> "..., 4096, 340074) = 4096
> pread64(13,
>
> "!\315\341\3\0\226\350\276\v\377\353\f\0p\343\0\0P\23\0p\240\341%\0\0\272\0\0P\343\0"...,
> 4096, 335981) = 4096
> pread64(13, "@\26\377\353\0\0P\343\n\0\0\32\4\0\235\345\326\f\0\353\0
> \240\341\0010\240\341\4\0\240\341"..., 4096, 331888) = 4096
> write(1, "luvi v2.12.0\n", 13luvi v2.12.0
>
>
> luajit:
>
> pipe2([6, 7], O_NONBLOCK|O_CLOEXEC)     = 0
> eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 8
> open("./init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
> directory)
> open("/usr/share/luajit-2.1.0-beta3/init.lua", O_RDONLY|O_LARGEFILE) = -1
> ENOENT
> (No such file or directory)
> open("/usr/local/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1
> ENOENT (No
> such file or directory)
> open("/usr/local/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE) = -1
> ENOENT
> (No such file or directory)
> open("/usr/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No
> such
> file or directory)
> open("/usr/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT
> (No
> such file or directory)
> open("./init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
> directory)
> open("/usr/local/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT
> (No
> such file or directory)
> open("/usr/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No
> such file
> or directory)
> open("/usr/local/lib/lua/5.1/loadall.so", O_RDONLY|O_LARGEFILE) = -1
> ENOENT (No
> such file or directory)
> write(2, "[string \"return require('init')("..., 596[string "return
> require('init')(...)"]:1: module 'init' not found:
>
> Something is strange here...
>
> Best regards,
> Romain
>
>
luvi requires a luajit built with the `-DLUAJIT_ENABLE_LUA52COMPAT` flag.
it was the default with moonjit.
the package luvi must :
       select BR2_PACKAGE_LUAJIT_COMPAT52

François


>
> > it is about `init.lua` is not installed by luvi package.
> >
> > François
> >
> >
> >     Signed-off-by: Romain Naour <romain.naour@gmail.com
> >     <mailto:romain.naour@gmail.com>>
> >     Cc: Francois Perrad <francois.perrad@gadz.org <mailto:
> francois.perrad@gadz.org>>
> >     Cc: Jörg Krause <joerg.krause@embedded.rocks>
> >
>
>
Jörg Krause Nov. 7, 2021, 11:04 a.m. UTC | #4
Hi François, Hi Romain,

the issue has nothing to do with static linking (the issue Romain cited
was raised by in 2015 has been fixed long time ago) nor is it an issue
about moonjit vs luajit as correctly stated by François. Also, it is
not about setting `LUAJIT_ENABLE_LUA52COMPAT`.

After applying the patch [1] from Romain I am building and running luvi
on my machine successfully:

```
LD_LIBRARY_PATH="./output/target/usr/lib/:./output/target/lib" ./output/target/usr/bin/luvi
./output/target/usr/bin/luvi v2.12.0
libuv: 1.42.0
```

The file `init.lua` is Luajitted into an object file: 
```
Building $BR/output/host/share/luajit-2.1.0-beta3/?.lua Luajitted $BR/output/build/luvi-2.12.0/src/lua/init.lua: $BR/output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
```

My first guess is, that the byte code generated by luajit is generated
for a different machine than luvi is actually running on. Is
`file output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o`
printing the correct file type information?

[1] http://patchwork.ozlabs.org/project/buildroot/patch/20211031210258.654193-1-romain.naour@gmail.com/

Best regards
Jörg Krause

On Sun, 2021-11-07 at 09:30 +0100, François Perrad wrote:
> 
> 
> Le sam. 6 nov. 2021 à 23:02, Romain Naour <romain.naour@gmail.com> a
> écrit :
> > Le 06/11/2021 à 22:19, François Perrad a écrit :
> > > 
> > > 
> > > Le sam. 6 nov. 2021 à 20:01, Romain Naour <romain.naour@gmail.com
> > > <mailto:romain.naour@gmail.com>> a écrit :
> > > 
> > >      This reverts commit 9450b53c8e06f1b5a75840b82c0f4663a5d75c45
> > > since it
> > >      introcude a regretion to luvi package [1].
> > > 
> > >      luvi doesn't work since the luv static linking doesn't seems
> > > to
> > >      work anymore.
> > >      (see
> > >    
> > >  https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
> > > 2d70f6b7067
> > > <https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
> > > 2d70f6b7067>)
> > > 
> > >       # luvi -v
> > > 
> > >      [string "return require('init')(...)"]:1: module 'init' not
> > > found:
> > > 
> > >              no field package.preload['init']
> > >              no file './init.lua'
> > >              no file '/usr/share/luajit-2.1.0-beta3/init.lua'
> > >              no file '/usr/local/share/lua/5.1/init.lua'
> > >              no file '/usr/local/share/lua/5.1/init/init.lua'
> > >              no file '/usr/share/lua/5.1/init.lua'
> > >              no file '/usr/share/lua/5.1/init/init.lua'
> > >              no file './init.so'
> > >              no file '/usr/local/lib/lua/5.1/init.so'
> > >              no file '/usr/lib/lua/5.1/init.so'
> > >              no file '/usr/local/lib/lua/5.1/loadall.so'
> > > 
> > >      stack traceback:
> > >              [C]: in function 'require'
> > >              [string "return require('init')(...)"]:1: in main
> > > chunk
> > > 
> > >      luvi now try to load init.lua script:
> > >      https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176
> > >      <https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176>
> > > 
> > >      Luvi seems to rely on some moonjit extentions [2] not
> > > available yet in
> > >      luajit.
> > > 
> > >      [1] http://lists.busybox.net/pipermail/buildroot/2021-
> > > October/627134.html
> > >      <http://lists.busybox.net/pipermail/buildroot/2021-
> > > October/627134.html>
> > >      [2]
> > > https://github.com/moonjit/moonjit/blob/master/doc/extensions.md
> > >    
> > >  <https://github.com/moonjit/moonjit/blob/master/doc/extensions.md>
> > > 
> > > 
> > > the module `init.lua` is supplied by luvi (see
> > > https://github.com/luvit/luvi/blob/master/src/lua/init.lua
> > > <https://github.com/luvit/luvi/blob/master/src/lua/init.lua>)
> > > and installed somewhere or not (I cannot find it).
> > > 
> > > moonjit 2.1.2 try to load a Lua module from these locations :
> > >     './init.lua'
> > >     '/usr/share/luajit-2.1.2/init.lua' (usually reserved to luajit
> > > itself)
> > >     '/usr/local/share/lua/5.1/init.lua'
> > >     '/usr/local/share/lua/5.1/init/init.lua'
> > >     '/usr/share/lua/5.1/init.lua'
> > >     '/usr/share/lua/5.1/init/init.lua'
> > > 
> > > luajit try to load a Lua module from these locations :
> > >     './init.lua'
> > >     '/usr/share/luajit-2.1.0-beta3/init.lua' (usually reserved to
> > > luajit itself)
> > >     '/usr/local/share/lua/5.1/init.lua'
> > >     '/usr/local/share/lua/5.1/init/init.lua'
> > >     '/usr/share/lua/5.1/init.lua'
> > >     '/usr/share/lua/5.1/init/init.lua'
> > > 
> > > this issue is not about moonjit vs luajit,
> > 
> > The luajit vs moonjit traces are clearly not the same (using strace)
> > 
> > moonjit doesn't even try to open init.lua (init.lua is not installed
> > in target):
> > 
> > open("/usr/bin/luvi", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 13
> > statx(13, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL,
> > {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0,
> > stx_mode=S_IFREG|0755, stx_size=401472, ...}) = 0
> > pread64(13,
> > "\213\240\5\0h'\4\0\373\277\5\0X5\4\0\342\305\5\0t-
> > \4\0G\260\5\0\34'\4\0"...,
> > 4096, 397376) = 4096
> > pread64(13,
> > "\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\351\232\5\0K\253\5\0\361\232\5\0\
> > 367\232\5"...,
> > 4096, 393283) = 4096
> > pread64(13,
> > "\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\
> > 334N"...,
> > 4096, 389190) = 4096
> > pread64(13, "ed\0lz.inflate.meta\0BEST_SPEED\0BE"..., 4096, 385097) =
> > 4096
> > pread64(13, "Luvi/build/luvi-2.12.0/deps/lua-"..., 4096, 381004) =
> > 4096
> > pread64(13, "ept fail\0#1 BIO must be memory t"..., 4096, 376911) =
> > 4096
> > pread64(13, "scape_ca_dn_bug\0netscape_challen"..., 4096, 372818) =
> > 4096
> > pread64(13, " to cert\0PKCS12_careate failed,p"..., 4096, 368725) =
> > 4096
> > pread64(13,
> > "\200+\10\0\0-
> > \t\0\08\t\7\t9\t\0\t\22\n\0\0B\t\2\3\22\3\n\0\22\10\t"..., 4096,
> > 364632) = 4096
> > pread64(13,
> > "'\7\2\0\22\10\2\0\22\t\3\0B\5\5\2&\4\5\4L\4\2\0K\0\1\0\6\\\6/"...,
> > 4096, 360539) = 4096
> > pread64(13, "ve is too large\0validation faile"..., 4096, 356446) =
> > 4096
> > pread64(13,
> > "\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\2
> > 1\21\21\21\21\21\21\21\21\21"...,
> > 4096, 352353) = 4096
> > pread64(13,
> > "TP\237\345\3p\300\343\200\1\240\341\30`\0\342H\200\237\345\25V\240\3
> > 41\1\220\240\341\0\0\227\345"...,
> > 4096, 348260) = 4096
> > pread64(13,
> > "\1#\0\0:\1\0P\341\32\0\0\232\2\0\21\341\33\0\0\n\21?o\341\20/o\341\2
> > C"...,
> > 4096, 344167) = 4096
> > pread64(13,
> > "\215\342\4\360\235\344\363G-
> > \351\34\221\237\345\0`\240\341\0@\240\343\2p\240\341\f\0\220\345\4
> > "..., 4096, 340074) = 4096
> > pread64(13,
> > "!\315\341\3\0\226\350\276\v\377\353\f\0p\343\0\0P\23\0p\240\341%\0\0
> > \272\0\0P\343\0"...,
> > 4096, 335981) = 4096
> > pread64(13, "@\26\377\353\0\0P\343\n\0\0\32\4\0\235\345\326\f\0\353\0
> > \240\341\0010\240\341\4\0\240\341"..., 4096, 331888) = 4096
> > write(1, "luvi v2.12.0\n", 13luvi v2.12.0
> > 
> > 
> > luajit:
> > 
> > pipe2([6, 7], O_NONBLOCK|O_CLOEXEC)     = 0
> > eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 8
> > open("./init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
> > directory)
> > open("/usr/share/luajit-2.1.0-beta3/init.lua", O_RDONLY|O_LARGEFILE)
> > = -1 ENOENT
> > (No such file or directory)
> > open("/usr/local/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1
> > ENOENT (No
> > such file or directory)
> > open("/usr/local/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE)
> > = -1 ENOENT
> > (No such file or directory)
> > open("/usr/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT
> > (No such
> > file or directory)
> > open("/usr/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE) = -1
> > ENOENT (No
> > such file or directory)
> > open("./init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
> > directory)
> > open("/usr/local/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1
> > ENOENT (No
> > such file or directory)
> > open("/usr/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT
> > (No such file
> > or directory)
> > open("/usr/local/lib/lua/5.1/loadall.so", O_RDONLY|O_LARGEFILE) = -1
> > ENOENT (No
> > such file or directory)
> > write(2, "[string \"return require('init')("..., 596[string "return
> > require('init')(...)"]:1: module 'init' not found:
> > 
> > Something is strange here...
> > 
> > Best regards,
> > Romain
> > 
> > 
> 
> 
> luvi requires a luajit built with the `-DLUAJIT_ENABLE_LUA52COMPAT`
> flag.
> it was the default with moonjit.
> the package luvi must :
>        select BR2_PACKAGE_LUAJIT_COMPAT52
> 
> François
>  
> > 
> > > it is about `init.lua` is not installed by luvi package.
> > > 
> > > François
> > >  
> > > 
> > >      Signed-off-by: Romain Naour <romain.naour@gmail.com
> > >      <mailto:romain.naour@gmail.com>>
> > >      Cc: Francois Perrad <francois.perrad@gadz.org
> > > <mailto:francois.perrad@gadz.org>>
> > >      Cc: Jörg Krause <joerg.krause@embedded.rocks>
> > > 
> >
Francois Perrad Nov. 7, 2021, 1:14 p.m. UTC | #5
Le dim. 7 nov. 2021 à 12:12, Jörg Krause <joerg.krause@embedded.rocks> a
écrit :

> Hi François, Hi Romain,
>
> the issue has nothing to do with static linking (the issue Romain cited
> was raised by in 2015 has been fixed long time ago) nor is it an issue
> about moonjit vs luajit as correctly stated by François. Also, it is
> not about setting `LUAJIT_ENABLE_LUA52COMPAT`.
>
> After applying the patch [1] from Romain I am building and running luvi
> on my machine successfully:
>
> ```
> LD_LIBRARY_PATH="./output/target/usr/lib/:./output/target/lib"
> ./output/target/usr/bin/luvi
> ./output/target/usr/bin/luvi v2.12.0
> libuv: 1.42.0
> ```
>
> The file `init.lua` is Luajitted into an object file:
> ```
> Building $BR/output/host/share/luajit-2.1.0-beta3/?.lua Luajitted
> $BR/output/build/luvi-2.12.0/src/lua/init.lua:
> $BR/output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
> ```
>
> My first guess is, that the byte code generated by luajit is generated
> for a different machine than luvi is actually running on. Is
> `file
> output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o`
> printing the correct file type information?
>
>
correct, src/init.lua is bytecoded in
jitted_tmp/lua/src/init.lua_luvi_generated.o
by the following command :
LUA_PATH=.../host/share/luajit-2.1.0-beta3/?.lua \
luajit -b -a arm .../src/lua/init.lua
.../jitted_tmp/src/lua/init.lua_luvi_generated.o

$ nm .../jitted_tmp/src/lua/init.lua_luvi_generated.o
00000000 R luaJIT_BC_init

$ file .../jitted_tmp/src/lua/init.lua_luvi_generated.o
jitted_tmp/src/lua/init.lua_luvi_generated.o: ELF 32-bit LSB relocatable,
ARM, version 1 (SYSV), not stripped

$ nm .../luvi | grep luaJIT_BC_
000173e3 R luaJIT_BC_init
00018248 R luaJIT_BC_luvibundle
00017d28 R luaJIT_BC_luvipath

$ file .../luvi
luvi: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV),
dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux
3.2.0, with debug_info, not stripped

The LuaJIT bytecode is platform independent (not the case for PUC Lua).
The bytecode could exported as C array in a .c or .h file :
    const unsigned char luaJIT_BC_init[] = {
    ...
when exported as .o or .obj, the option -a allows to set the target
architecture.

François


> [1]
> http://patchwork.ozlabs.org/project/buildroot/patch/20211031210258.654193-1-romain.naour@gmail.com/
>
> Best regards
> Jörg Krause
>
>
>
Romain Naour Nov. 7, 2021, 2:01 p.m. UTC | #6
Hello Jörg, François,

Le 07/11/2021 à 12:04, Jörg Krause a écrit :
> Hi François, Hi Romain,
> 
> the issue has nothing to do with static linking (the issue Romain cited
> was raised by in 2015 has been fixed long time ago) nor is it an issue
> about moonjit vs luajit as correctly stated by François. Also, it is
> not about setting `LUAJIT_ENABLE_LUA52COMPAT`.
> 
> After applying the patch [1] from Romain I am building and running luvi
> on my machine successfully:

To reproduce easily the issue you can use the

./support/testing/run-tests -o testsuite-master/ -d dl/ -k --timeout-multiplier
10 tests.package.test_luvi.TestLuvi

Indeed, even with LUAJIT_ENABLE_LUA52COMPAT enabled the test is failing.

> 
> ```
> LD_LIBRARY_PATH="./output/target/usr/lib/:./output/target/lib" ./output/target/usr/bin/luvi
> ./output/target/usr/bin/luvi v2.12.0
> libuv: 1.42.0
> ```
> 
> The file `init.lua` is Luajitted into an object file: 
> ```
> Building $BR/output/host/share/luajit-2.1.0-beta3/?.lua Luajitted $BR/output/build/luvi-2.12.0/src/lua/init.lua: $BR/output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o

Sorry, I used "static linking" but I talked about what you call "luajitted".
When building using luajit I can still see init.lua_luvi_generated.o being
compiled and used to link luvi binary.

Do you remember this issue ? it seems similar:
https://github.com/luvit/luvi/commit/b8781653dcb8815a3019a77baf4f3b7f7a255ebe

> ```
> 
> My first guess is, that the byte code generated by luajit is generated
> for a different machine than luvi is actually running on. Is
> `file output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o`
> printing the correct file type information?

This .o file seems ok

$ readelf -h
./TestLuvi/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
En-tête ELF:
  Magique:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Classe:                            ELF32
  Données:                          complément à 2, système à octets de poids
faible d'abord (little endian)
  Version:                           1 (actuelle)
  OS/ABI:                            UNIX - System V
  Version ABI:                       0
  Type:                              REL (Fichier de réadressage)
  Machine:                           ARM


The luvi test has been added to buildroot before the switch to moonjit (was
luajit 2.0.5). I just tested with luajit 2.0.5 and the test pass.

Best regards,
Romain


> 
> [1] http://patchwork.ozlabs.org/project/buildroot/patch/20211031210258.654193-1-romain.naour@gmail.com/
> 
> Best regards
> Jörg Krause
> 
> On Sun, 2021-11-07 at 09:30 +0100, François Perrad wrote:
>>
>>
>> Le sam. 6 nov. 2021 à 23:02, Romain Naour <romain.naour@gmail.com> a
>> écrit :
>>> Le 06/11/2021 à 22:19, François Perrad a écrit :
>>>>
>>>>
>>>> Le sam. 6 nov. 2021 à 20:01, Romain Naour <romain.naour@gmail.com
>>>> <mailto:romain.naour@gmail.com>> a écrit :
>>>>
>>>>      This reverts commit 9450b53c8e06f1b5a75840b82c0f4663a5d75c45
>>>> since it
>>>>      introcude a regretion to luvi package [1].
>>>>
>>>>      luvi doesn't work since the luv static linking doesn't seems
>>>> to
>>>>      work anymore.
>>>>      (see
>>>>    
>>>>  https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
>>>> 2d70f6b7067
>>>> <https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
>>>> 2d70f6b7067>)
>>>>
>>>>       # luvi -v
>>>>
>>>>      [string "return require('init')(...)"]:1: module 'init' not
>>>> found:
>>>>
>>>>              no field package.preload['init']
>>>>              no file './init.lua'
>>>>              no file '/usr/share/luajit-2.1.0-beta3/init.lua'
>>>>              no file '/usr/local/share/lua/5.1/init.lua'
>>>>              no file '/usr/local/share/lua/5.1/init/init.lua'
>>>>              no file '/usr/share/lua/5.1/init.lua'
>>>>              no file '/usr/share/lua/5.1/init/init.lua'
>>>>              no file './init.so'
>>>>              no file '/usr/local/lib/lua/5.1/init.so'
>>>>              no file '/usr/lib/lua/5.1/init.so'
>>>>              no file '/usr/local/lib/lua/5.1/loadall.so'
>>>>
>>>>      stack traceback:
>>>>              [C]: in function 'require'
>>>>              [string "return require('init')(...)"]:1: in main
>>>> chunk
>>>>
>>>>      luvi now try to load init.lua script:
>>>>      https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176
>>>>      <https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176>
>>>>
>>>>      Luvi seems to rely on some moonjit extentions [2] not
>>>> available yet in
>>>>      luajit.
>>>>
>>>>      [1] http://lists.busybox.net/pipermail/buildroot/2021-
>>>> October/627134.html
>>>>      <http://lists.busybox.net/pipermail/buildroot/2021-
>>>> October/627134.html>
>>>>      [2]
>>>> https://github.com/moonjit/moonjit/blob/master/doc/extensions.md
>>>>    
>>>>  <https://github.com/moonjit/moonjit/blob/master/doc/extensions.md>
>>>>
>>>>
>>>> the module `init.lua` is supplied by luvi (see
>>>> https://github.com/luvit/luvi/blob/master/src/lua/init.lua
>>>> <https://github.com/luvit/luvi/blob/master/src/lua/init.lua>)
>>>> and installed somewhere or not (I cannot find it).
>>>>
>>>> moonjit 2.1.2 try to load a Lua module from these locations :
>>>>     './init.lua'
>>>>     '/usr/share/luajit-2.1.2/init.lua' (usually reserved to luajit
>>>> itself)
>>>>     '/usr/local/share/lua/5.1/init.lua'
>>>>     '/usr/local/share/lua/5.1/init/init.lua'
>>>>     '/usr/share/lua/5.1/init.lua'
>>>>     '/usr/share/lua/5.1/init/init.lua'
>>>>
>>>> luajit try to load a Lua module from these locations :
>>>>     './init.lua'
>>>>     '/usr/share/luajit-2.1.0-beta3/init.lua' (usually reserved to
>>>> luajit itself)
>>>>     '/usr/local/share/lua/5.1/init.lua'
>>>>     '/usr/local/share/lua/5.1/init/init.lua'
>>>>     '/usr/share/lua/5.1/init.lua'
>>>>     '/usr/share/lua/5.1/init/init.lua'
>>>>
>>>> this issue is not about moonjit vs luajit,
>>>
>>> The luajit vs moonjit traces are clearly not the same (using strace)
>>>
>>> moonjit doesn't even try to open init.lua (init.lua is not installed
>>> in target):
>>>
>>> open("/usr/bin/luvi", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 13
>>> statx(13, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL,
>>> {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0,
>>> stx_mode=S_IFREG|0755, stx_size=401472, ...}) = 0
>>> pread64(13,
>>> "\213\240\5\0h'\4\0\373\277\5\0X5\4\0\342\305\5\0t-
>>> \4\0G\260\5\0\34'\4\0"...,
>>> 4096, 397376) = 4096
>>> pread64(13,
>>> "\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\351\232\5\0K\253\5\0\361\232\5\0\
>>> 367\232\5"...,
>>> 4096, 393283) = 4096
>>> pread64(13,
>>> "\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\
>>> 334N"...,
>>> 4096, 389190) = 4096
>>> pread64(13, "ed\0lz.inflate.meta\0BEST_SPEED\0BE"..., 4096, 385097) =
>>> 4096
>>> pread64(13, "Luvi/build/luvi-2.12.0/deps/lua-"..., 4096, 381004) =
>>> 4096
>>> pread64(13, "ept fail\0#1 BIO must be memory t"..., 4096, 376911) =
>>> 4096
>>> pread64(13, "scape_ca_dn_bug\0netscape_challen"..., 4096, 372818) =
>>> 4096
>>> pread64(13, " to cert\0PKCS12_careate failed,p"..., 4096, 368725) =
>>> 4096
>>> pread64(13,
>>> "\200+\10\0\0-
>>> \t\0\08\t\7\t9\t\0\t\22\n\0\0B\t\2\3\22\3\n\0\22\10\t"..., 4096,
>>> 364632) = 4096
>>> pread64(13,
>>> "'\7\2\0\22\10\2\0\22\t\3\0B\5\5\2&\4\5\4L\4\2\0K\0\1\0\6\\\6/"...,
>>> 4096, 360539) = 4096
>>> pread64(13, "ve is too large\0validation faile"..., 4096, 356446) =
>>> 4096
>>> pread64(13,
>>> "\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\2
>>> 1\21\21\21\21\21\21\21\21\21"...,
>>> 4096, 352353) = 4096
>>> pread64(13,
>>> "TP\237\345\3p\300\343\200\1\240\341\30`\0\342H\200\237\345\25V\240\3
>>> 41\1\220\240\341\0\0\227\345"...,
>>> 4096, 348260) = 4096
>>> pread64(13,
>>> "\1#\0\0:\1\0P\341\32\0\0\232\2\0\21\341\33\0\0\n\21?o\341\20/o\341\2
>>> C"...,
>>> 4096, 344167) = 4096
>>> pread64(13,
>>> "\215\342\4\360\235\344\363G-
>>> \351\34\221\237\345\0`\240\341\0@\240\343\2p\240\341\f\0\220\345\4
>>> "..., 4096, 340074) = 4096
>>> pread64(13,
>>> "!\315\341\3\0\226\350\276\v\377\353\f\0p\343\0\0P\23\0p\240\341%\0\0
>>> \272\0\0P\343\0"...,
>>> 4096, 335981) = 4096
>>> pread64(13, "@\26\377\353\0\0P\343\n\0\0\32\4\0\235\345\326\f\0\353\0
>>> \240\341\0010\240\341\4\0\240\341"..., 4096, 331888) = 4096
>>> write(1, "luvi v2.12.0\n", 13luvi v2.12.0
>>>
>>>
>>> luajit:
>>>
>>> pipe2([6, 7], O_NONBLOCK|O_CLOEXEC)     = 0
>>> eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 8
>>> open("./init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
>>> directory)
>>> open("/usr/share/luajit-2.1.0-beta3/init.lua", O_RDONLY|O_LARGEFILE)
>>> = -1 ENOENT
>>> (No such file or directory)
>>> open("/usr/local/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1
>>> ENOENT (No
>>> such file or directory)
>>> open("/usr/local/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE)
>>> = -1 ENOENT
>>> (No such file or directory)
>>> open("/usr/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT
>>> (No such
>>> file or directory)
>>> open("/usr/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE) = -1
>>> ENOENT (No
>>> such file or directory)
>>> open("./init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
>>> directory)
>>> open("/usr/local/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1
>>> ENOENT (No
>>> such file or directory)
>>> open("/usr/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT
>>> (No such file
>>> or directory)
>>> open("/usr/local/lib/lua/5.1/loadall.so", O_RDONLY|O_LARGEFILE) = -1
>>> ENOENT (No
>>> such file or directory)
>>> write(2, "[string \"return require('init')("..., 596[string "return
>>> require('init')(...)"]:1: module 'init' not found:
>>>
>>> Something is strange here...
>>>
>>> Best regards,
>>> Romain
>>>
>>>
>>
>>
>> luvi requires a luajit built with the `-DLUAJIT_ENABLE_LUA52COMPAT`
>> flag.
>> it was the default with moonjit.
>> the package luvi must :
>>        select BR2_PACKAGE_LUAJIT_COMPAT52
>>
>> François
>>  
>>>
>>>> it is about `init.lua` is not installed by luvi package.
>>>>
>>>> François
>>>>  
>>>>
>>>>      Signed-off-by: Romain Naour <romain.naour@gmail.com
>>>>      <mailto:romain.naour@gmail.com>>
>>>>      Cc: Francois Perrad <francois.perrad@gadz.org
>>>> <mailto:francois.perrad@gadz.org>>
>>>>      Cc: Jörg Krause <joerg.krause@embedded.rocks>
>>>>
>>>
>
Jörg Krause Nov. 7, 2021, 8:04 p.m. UTC | #7
Hi Romain,

I did run on my host machine:

```
./support/testing/run-tests -o testsuite-master/ -d dl/ -k --timeout-multiplier 10 tests.package.test_luvi.TestLuvi
```

Luvi build successfully (with the patch applied I mentioned in my
previous mail. Running `luvi -v` hangs in qemu and eventually the
command times out.

Can you provide a full log, please.

Best regards
Jörg Krause

On Sun, 2021-11-07 at 15:01 +0100, Romain Naour wrote:
> Hello Jörg, François,
> 
> Le 07/11/2021 à 12:04, Jörg Krause a écrit :
> > Hi François, Hi Romain,
> > 
> > the issue has nothing to do with static linking (the issue Romain cited
> > was raised by in 2015 has been fixed long time ago) nor is it an issue
> > about moonjit vs luajit as correctly stated by François. Also, it is
> > not about setting `LUAJIT_ENABLE_LUA52COMPAT`.
> > 
> > After applying the patch [1] from Romain I am building and running luvi
> > on my machine successfully:
> 
> To reproduce easily the issue you can use the
> 
> ./support/testing/run-tests -o testsuite-master/ -d dl/ -k --timeout-multiplier
> 10 tests.package.test_luvi.TestLuvi
> 
> Indeed, even with LUAJIT_ENABLE_LUA52COMPAT enabled the test is failing.
> 
> > 
> > ```
> > LD_LIBRARY_PATH="./output/target/usr/lib/:./output/target/lib" ./output/target/usr/bin/luvi
> > ./output/target/usr/bin/luvi v2.12.0
> > libuv: 1.42.0
> > ```
> > 
> > The file `init.lua` is Luajitted into an object file: 
> > ```
> > Building $BR/output/host/share/luajit-2.1.0-beta3/?.lua Luajitted $BR/output/build/luvi-2.12.0/src/lua/init.lua: $BR/output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
> 
> Sorry, I used "static linking" but I talked about what you call "luajitted".
> When building using luajit I can still see init.lua_luvi_generated.o being
> compiled and used to link luvi binary.
> 
> Do you remember this issue ? it seems similar:
> https://github.com/luvit/luvi/commit/b8781653dcb8815a3019a77baf4f3b7f7a255ebe
> 
> > ```
> > 
> > My first guess is, that the byte code generated by luajit is generated
> > for a different machine than luvi is actually running on. Is
> > `file output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o`
> > printing the correct file type information?
> 
> This .o file seems ok
> 
> $ readelf -h
> ./TestLuvi/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
> En-tête ELF:
>   Magique:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
>   Classe:                            ELF32
>   Données:                          complément à 2, système à octets de poids
> faible d'abord (little endian)
>   Version:                           1 (actuelle)
>   OS/ABI:                            UNIX - System V
>   Version ABI:                       0
>   Type:                              REL (Fichier de réadressage)
>   Machine:                           ARM
> 
> 
> The luvi test has been added to buildroot before the switch to moonjit (was
> luajit 2.0.5). I just tested with luajit 2.0.5 and the test pass.
> 
> Best regards,
> Romain
> 
> 
> > 
> > [1] http://patchwork.ozlabs.org/project/buildroot/patch/20211031210258.654193-1-romain.naour@gmail.com/
> > 
> > Best regards
> > Jörg Krause
> > 
> > On Sun, 2021-11-07 at 09:30 +0100, François Perrad wrote:
> > > 
> > > 
> > > Le sam. 6 nov. 2021 à 23:02, Romain Naour <romain.naour@gmail.com> a
> > > écrit :
> > > > Le 06/11/2021 à 22:19, François Perrad a écrit :
> > > > > 
> > > > > 
> > > > > Le sam. 6 nov. 2021 à 20:01, Romain Naour <romain.naour@gmail.com
> > > > > <mailto:romain.naour@gmail.com>> a écrit :
> > > > > 
> > > > >      This reverts commit 9450b53c8e06f1b5a75840b82c0f4663a5d75c45
> > > > > since it
> > > > >      introcude a regretion to luvi package [1].
> > > > > 
> > > > >      luvi doesn't work since the luv static linking doesn't seems
> > > > > to
> > > > >      work anymore.
> > > > >      (see
> > > > >    
> > > > >  https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
> > > > > 2d70f6b7067
> > > > > <https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
> > > > > 2d70f6b7067>)
> > > > > 
> > > > >       # luvi -v
> > > > > 
> > > > >      [string "return require('init')(...)"]:1: module 'init' not
> > > > > found:
> > > > > 
> > > > >              no field package.preload['init']
> > > > >              no file './init.lua'
> > > > >              no file '/usr/share/luajit-2.1.0-beta3/init.lua'
> > > > >              no file '/usr/local/share/lua/5.1/init.lua'
> > > > >              no file '/usr/local/share/lua/5.1/init/init.lua'
> > > > >              no file '/usr/share/lua/5.1/init.lua'
> > > > >              no file '/usr/share/lua/5.1/init/init.lua'
> > > > >              no file './init.so'
> > > > >              no file '/usr/local/lib/lua/5.1/init.so'
> > > > >              no file '/usr/lib/lua/5.1/init.so'
> > > > >              no file '/usr/local/lib/lua/5.1/loadall.so'
> > > > > 
> > > > >      stack traceback:
> > > > >              [C]: in function 'require'
> > > > >              [string "return require('init')(...)"]:1: in main
> > > > > chunk
> > > > > 
> > > > >      luvi now try to load init.lua script:
> > > > >      https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176
> > > > >      <https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176>
> > > > > 
> > > > >      Luvi seems to rely on some moonjit extentions [2] not
> > > > > available yet in
> > > > >      luajit.
> > > > > 
> > > > >      [1] http://lists.busybox.net/pipermail/buildroot/2021-
> > > > > October/627134.html
> > > > >      <http://lists.busybox.net/pipermail/buildroot/2021-
> > > > > October/627134.html>
> > > > >      [2]
> > > > > https://github.com/moonjit/moonjit/blob/master/doc/extensions.md
> > > > >    
> > > > >  <https://github.com/moonjit/moonjit/blob/master/doc/extensions.md>
> > > > > 
> > > > > 
> > > > > the module `init.lua` is supplied by luvi (see
> > > > > https://github.com/luvit/luvi/blob/master/src/lua/init.lua
> > > > > <https://github.com/luvit/luvi/blob/master/src/lua/init.lua>)
> > > > > and installed somewhere or not (I cannot find it).
> > > > > 
> > > > > moonjit 2.1.2 try to load a Lua module from these locations :
> > > > >     './init.lua'
> > > > >     '/usr/share/luajit-2.1.2/init.lua' (usually reserved to luajit
> > > > > itself)
> > > > >     '/usr/local/share/lua/5.1/init.lua'
> > > > >     '/usr/local/share/lua/5.1/init/init.lua'
> > > > >     '/usr/share/lua/5.1/init.lua'
> > > > >     '/usr/share/lua/5.1/init/init.lua'
> > > > > 
> > > > > luajit try to load a Lua module from these locations :
> > > > >     './init.lua'
> > > > >     '/usr/share/luajit-2.1.0-beta3/init.lua' (usually reserved to
> > > > > luajit itself)
> > > > >     '/usr/local/share/lua/5.1/init.lua'
> > > > >     '/usr/local/share/lua/5.1/init/init.lua'
> > > > >     '/usr/share/lua/5.1/init.lua'
> > > > >     '/usr/share/lua/5.1/init/init.lua'
> > > > > 
> > > > > this issue is not about moonjit vs luajit,
> > > > 
> > > > The luajit vs moonjit traces are clearly not the same (using strace)
> > > > 
> > > > moonjit doesn't even try to open init.lua (init.lua is not installed
> > > > in target):
> > > > 
> > > > open("/usr/bin/luvi", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 13
> > > > statx(13, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL,
> > > > {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0,
> > > > stx_mode=S_IFREG|0755, stx_size=401472, ...}) = 0
> > > > pread64(13,
> > > > "\213\240\5\0h'\4\0\373\277\5\0X5\4\0\342\305\5\0t-
> > > > \4\0G\260\5\0\34'\4\0"...,
> > > > 4096, 397376) = 4096
> > > > pread64(13,
> > > > "\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\351\232\5\0K\253\5\0\361\232\5\0\
> > > > 367\232\5"...,
> > > > 4096, 393283) = 4096
> > > > pread64(13,
> > > > "\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\
> > > > 334N"...,
> > > > 4096, 389190) = 4096
> > > > pread64(13, "ed\0lz.inflate.meta\0BEST_SPEED\0BE"..., 4096, 385097) =
> > > > 4096
> > > > pread64(13, "Luvi/build/luvi-2.12.0/deps/lua-"..., 4096, 381004) =
> > > > 4096
> > > > pread64(13, "ept fail\0#1 BIO must be memory t"..., 4096, 376911) =
> > > > 4096
> > > > pread64(13, "scape_ca_dn_bug\0netscape_challen"..., 4096, 372818) =
> > > > 4096
> > > > pread64(13, " to cert\0PKCS12_careate failed,p"..., 4096, 368725) =
> > > > 4096
> > > > pread64(13,
> > > > "\200+\10\0\0-
> > > > \t\0\08\t\7\t9\t\0\t\22\n\0\0B\t\2\3\22\3\n\0\22\10\t"..., 4096,
> > > > 364632) = 4096
> > > > pread64(13,
> > > > "'\7\2\0\22\10\2\0\22\t\3\0B\5\5\2&\4\5\4L\4\2\0K\0\1\0\6\\\6/"...,
> > > > 4096, 360539) = 4096
> > > > pread64(13, "ve is too large\0validation faile"..., 4096, 356446) =
> > > > 4096
> > > > pread64(13,
> > > > "\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\2
> > > > 1\21\21\21\21\21\21\21\21\21"...,
> > > > 4096, 352353) = 4096
> > > > pread64(13,
> > > > "TP\237\345\3p\300\343\200\1\240\341\30`\0\342H\200\237\345\25V\240\3
> > > > 41\1\220\240\341\0\0\227\345"...,
> > > > 4096, 348260) = 4096
> > > > pread64(13,
> > > > "\1#\0\0:\1\0P\341\32\0\0\232\2\0\21\341\33\0\0\n\21?o\341\20/o\341\2
> > > > C"...,
> > > > 4096, 344167) = 4096
> > > > pread64(13,
> > > > "\215\342\4\360\235\344\363G-
> > > > \351\34\221\237\345\0`\240\341\0@\240\343\2p\240\341\f\0\220\345\4
> > > > "..., 4096, 340074) = 4096
> > > > pread64(13,
> > > > "!\315\341\3\0\226\350\276\v\377\353\f\0p\343\0\0P\23\0p\240\341%\0\0
> > > > \272\0\0P\343\0"...,
> > > > 4096, 335981) = 4096
> > > > pread64(13, "@\26\377\353\0\0P\343\n\0\0\32\4\0\235\345\326\f\0\353\0
> > > > \240\341\0010\240\341\4\0\240\341"..., 4096, 331888) = 4096
> > > > write(1, "luvi v2.12.0\n", 13luvi v2.12.0
> > > > 
> > > > 
> > > > luajit:
> > > > 
> > > > pipe2([6, 7], O_NONBLOCK|O_CLOEXEC)     = 0
> > > > eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 8
> > > > open("./init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
> > > > directory)
> > > > open("/usr/share/luajit-2.1.0-beta3/init.lua", O_RDONLY|O_LARGEFILE)
> > > > = -1 ENOENT
> > > > (No such file or directory)
> > > > open("/usr/local/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1
> > > > ENOENT (No
> > > > such file or directory)
> > > > open("/usr/local/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE)
> > > > = -1 ENOENT
> > > > (No such file or directory)
> > > > open("/usr/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT
> > > > (No such
> > > > file or directory)
> > > > open("/usr/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE) = -1
> > > > ENOENT (No
> > > > such file or directory)
> > > > open("./init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
> > > > directory)
> > > > open("/usr/local/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1
> > > > ENOENT (No
> > > > such file or directory)
> > > > open("/usr/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT
> > > > (No such file
> > > > or directory)
> > > > open("/usr/local/lib/lua/5.1/loadall.so", O_RDONLY|O_LARGEFILE) = -1
> > > > ENOENT (No
> > > > such file or directory)
> > > > write(2, "[string \"return require('init')("..., 596[string "return
> > > > require('init')(...)"]:1: module 'init' not found:
> > > > 
> > > > Something is strange here...
> > > > 
> > > > Best regards,
> > > > Romain
> > > > 
> > > > 
> > > 
> > > 
> > > luvi requires a luajit built with the `-DLUAJIT_ENABLE_LUA52COMPAT`
> > > flag.
> > > it was the default with moonjit.
> > > the package luvi must :
> > >        select BR2_PACKAGE_LUAJIT_COMPAT52
> > > 
> > > François
> > >  
> > > > 
> > > > > it is about `init.lua` is not installed by luvi package.
> > > > > 
> > > > > François
> > > > >  
> > > > > 
> > > > >      Signed-off-by: Romain Naour <romain.naour@gmail.com
> > > > >      <mailto:romain.naour@gmail.com>>
> > > > >      Cc: Francois Perrad <francois.perrad@gadz.org
> > > > > <mailto:francois.perrad@gadz.org>>
> > > > >      Cc: Jörg Krause <joerg.krause@embedded.rocks>
> > > > > 
> > > > 
> > 
>
Jörg Krause Nov. 7, 2021, 8:08 p.m. UTC | #8
Hello,

just noticed I missed the second patch [2] of the series. I will re-run
the test with the patch applied.

[2]
http://patchwork.ozlabs.org/project/buildroot/patch/20211031210258.654193-2-romain.naour@gmail.com/

Best regards
Jörg Krause

On Sun, 2021-11-07 at 15:01 +0100, Romain Naour wrote:
> Hello Jörg, François,
> 
> Le 07/11/2021 à 12:04, Jörg Krause a écrit :
> > Hi François, Hi Romain,
> > 
> > the issue has nothing to do with static linking (the issue Romain cited
> > was raised by in 2015 has been fixed long time ago) nor is it an issue
> > about moonjit vs luajit as correctly stated by François. Also, it is
> > not about setting `LUAJIT_ENABLE_LUA52COMPAT`.
> > 
> > After applying the patch [1] from Romain I am building and running luvi
> > on my machine successfully:
> 
> To reproduce easily the issue you can use the
> 
> ./support/testing/run-tests -o testsuite-master/ -d dl/ -k --timeout-multiplier
> 10 tests.package.test_luvi.TestLuvi
> 
> Indeed, even with LUAJIT_ENABLE_LUA52COMPAT enabled the test is failing.
> 
> > 
> > ```
> > LD_LIBRARY_PATH="./output/target/usr/lib/:./output/target/lib" ./output/target/usr/bin/luvi
> > ./output/target/usr/bin/luvi v2.12.0
> > libuv: 1.42.0
> > ```
> > 
> > The file `init.lua` is Luajitted into an object file: 
> > ```
> > Building $BR/output/host/share/luajit-2.1.0-beta3/?.lua Luajitted $BR/output/build/luvi-2.12.0/src/lua/init.lua: $BR/output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
> 
> Sorry, I used "static linking" but I talked about what you call "luajitted".
> When building using luajit I can still see init.lua_luvi_generated.o being
> compiled and used to link luvi binary.
> 
> Do you remember this issue ? it seems similar:
> https://github.com/luvit/luvi/commit/b8781653dcb8815a3019a77baf4f3b7f7a255ebe
> 
> > ```
> > 
> > My first guess is, that the byte code generated by luajit is generated
> > for a different machine than luvi is actually running on. Is
> > `file output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o`
> > printing the correct file type information?
> 
> This .o file seems ok
> 
> $ readelf -h
> ./TestLuvi/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
> En-tête ELF:
>   Magique:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
>   Classe:                            ELF32
>   Données:                          complément à 2, système à octets de poids
> faible d'abord (little endian)
>   Version:                           1 (actuelle)
>   OS/ABI:                            UNIX - System V
>   Version ABI:                       0
>   Type:                              REL (Fichier de réadressage)
>   Machine:                           ARM
> 
> 
> The luvi test has been added to buildroot before the switch to moonjit (was
> luajit 2.0.5). I just tested with luajit 2.0.5 and the test pass.
> 
> Best regards,
> Romain
> 
> 
> > 
> > [1] http://patchwork.ozlabs.org/project/buildroot/patch/20211031210258.654193-1-romain.naour@gmail.com/
> > 
> > Best regards
> > Jörg Krause
> > 
> > On Sun, 2021-11-07 at 09:30 +0100, François Perrad wrote:
> > > 
> > > 
> > > Le sam. 6 nov. 2021 à 23:02, Romain Naour <romain.naour@gmail.com> a
> > > écrit :
> > > > Le 06/11/2021 à 22:19, François Perrad a écrit :
> > > > > 
> > > > > 
> > > > > Le sam. 6 nov. 2021 à 20:01, Romain Naour <romain.naour@gmail.com
> > > > > <mailto:romain.naour@gmail.com>> a écrit :
> > > > > 
> > > > >      This reverts commit 9450b53c8e06f1b5a75840b82c0f4663a5d75c45
> > > > > since it
> > > > >      introcude a regretion to luvi package [1].
> > > > > 
> > > > >      luvi doesn't work since the luv static linking doesn't seems
> > > > > to
> > > > >      work anymore.
> > > > >      (see
> > > > >    
> > > > >  https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
> > > > > 2d70f6b7067
> > > > > <https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
> > > > > 2d70f6b7067>)
> > > > > 
> > > > >       # luvi -v
> > > > > 
> > > > >      [string "return require('init')(...)"]:1: module 'init' not
> > > > > found:
> > > > > 
> > > > >              no field package.preload['init']
> > > > >              no file './init.lua'
> > > > >              no file '/usr/share/luajit-2.1.0-beta3/init.lua'
> > > > >              no file '/usr/local/share/lua/5.1/init.lua'
> > > > >              no file '/usr/local/share/lua/5.1/init/init.lua'
> > > > >              no file '/usr/share/lua/5.1/init.lua'
> > > > >              no file '/usr/share/lua/5.1/init/init.lua'
> > > > >              no file './init.so'
> > > > >              no file '/usr/local/lib/lua/5.1/init.so'
> > > > >              no file '/usr/lib/lua/5.1/init.so'
> > > > >              no file '/usr/local/lib/lua/5.1/loadall.so'
> > > > > 
> > > > >      stack traceback:
> > > > >              [C]: in function 'require'
> > > > >              [string "return require('init')(...)"]:1: in main
> > > > > chunk
> > > > > 
> > > > >      luvi now try to load init.lua script:
> > > > >      https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176
> > > > >      <https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176>
> > > > > 
> > > > >      Luvi seems to rely on some moonjit extentions [2] not
> > > > > available yet in
> > > > >      luajit.
> > > > > 
> > > > >      [1] http://lists.busybox.net/pipermail/buildroot/2021-
> > > > > October/627134.html
> > > > >      <http://lists.busybox.net/pipermail/buildroot/2021-
> > > > > October/627134.html>
> > > > >      [2]
> > > > > https://github.com/moonjit/moonjit/blob/master/doc/extensions.md
> > > > >    
> > > > >  <https://github.com/moonjit/moonjit/blob/master/doc/extensions.md>
> > > > > 
> > > > > 
> > > > > the module `init.lua` is supplied by luvi (see
> > > > > https://github.com/luvit/luvi/blob/master/src/lua/init.lua
> > > > > <https://github.com/luvit/luvi/blob/master/src/lua/init.lua>)
> > > > > and installed somewhere or not (I cannot find it).
> > > > > 
> > > > > moonjit 2.1.2 try to load a Lua module from these locations :
> > > > >     './init.lua'
> > > > >     '/usr/share/luajit-2.1.2/init.lua' (usually reserved to luajit
> > > > > itself)
> > > > >     '/usr/local/share/lua/5.1/init.lua'
> > > > >     '/usr/local/share/lua/5.1/init/init.lua'
> > > > >     '/usr/share/lua/5.1/init.lua'
> > > > >     '/usr/share/lua/5.1/init/init.lua'
> > > > > 
> > > > > luajit try to load a Lua module from these locations :
> > > > >     './init.lua'
> > > > >     '/usr/share/luajit-2.1.0-beta3/init.lua' (usually reserved to
> > > > > luajit itself)
> > > > >     '/usr/local/share/lua/5.1/init.lua'
> > > > >     '/usr/local/share/lua/5.1/init/init.lua'
> > > > >     '/usr/share/lua/5.1/init.lua'
> > > > >     '/usr/share/lua/5.1/init/init.lua'
> > > > > 
> > > > > this issue is not about moonjit vs luajit,
> > > > 
> > > > The luajit vs moonjit traces are clearly not the same (using strace)
> > > > 
> > > > moonjit doesn't even try to open init.lua (init.lua is not installed
> > > > in target):
> > > > 
> > > > open("/usr/bin/luvi", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 13
> > > > statx(13, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL,
> > > > {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0,
> > > > stx_mode=S_IFREG|0755, stx_size=401472, ...}) = 0
> > > > pread64(13,
> > > > "\213\240\5\0h'\4\0\373\277\5\0X5\4\0\342\305\5\0t-
> > > > \4\0G\260\5\0\34'\4\0"...,
> > > > 4096, 397376) = 4096
> > > > pread64(13,
> > > > "\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\351\232\5\0K\253\5\0\361\232\5\0\
> > > > 367\232\5"...,
> > > > 4096, 393283) = 4096
> > > > pread64(13,
> > > > "\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\
> > > > 334N"...,
> > > > 4096, 389190) = 4096
> > > > pread64(13, "ed\0lz.inflate.meta\0BEST_SPEED\0BE"..., 4096, 385097) =
> > > > 4096
> > > > pread64(13, "Luvi/build/luvi-2.12.0/deps/lua-"..., 4096, 381004) =
> > > > 4096
> > > > pread64(13, "ept fail\0#1 BIO must be memory t"..., 4096, 376911) =
> > > > 4096
> > > > pread64(13, "scape_ca_dn_bug\0netscape_challen"..., 4096, 372818) =
> > > > 4096
> > > > pread64(13, " to cert\0PKCS12_careate failed,p"..., 4096, 368725) =
> > > > 4096
> > > > pread64(13,
> > > > "\200+\10\0\0-
> > > > \t\0\08\t\7\t9\t\0\t\22\n\0\0B\t\2\3\22\3\n\0\22\10\t"..., 4096,
> > > > 364632) = 4096
> > > > pread64(13,
> > > > "'\7\2\0\22\10\2\0\22\t\3\0B\5\5\2&\4\5\4L\4\2\0K\0\1\0\6\\\6/"...,
> > > > 4096, 360539) = 4096
> > > > pread64(13, "ve is too large\0validation faile"..., 4096, 356446) =
> > > > 4096
> > > > pread64(13,
> > > > "\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\2
> > > > 1\21\21\21\21\21\21\21\21\21"...,
> > > > 4096, 352353) = 4096
> > > > pread64(13,
> > > > "TP\237\345\3p\300\343\200\1\240\341\30`\0\342H\200\237\345\25V\240\3
> > > > 41\1\220\240\341\0\0\227\345"...,
> > > > 4096, 348260) = 4096
> > > > pread64(13,
> > > > "\1#\0\0:\1\0P\341\32\0\0\232\2\0\21\341\33\0\0\n\21?o\341\20/o\341\2
> > > > C"...,
> > > > 4096, 344167) = 4096
> > > > pread64(13,
> > > > "\215\342\4\360\235\344\363G-
> > > > \351\34\221\237\345\0`\240\341\0@\240\343\2p\240\341\f\0\220\345\4
> > > > "..., 4096, 340074) = 4096
> > > > pread64(13,
> > > > "!\315\341\3\0\226\350\276\v\377\353\f\0p\343\0\0P\23\0p\240\341%\0\0
> > > > \272\0\0P\343\0"...,
> > > > 4096, 335981) = 4096
> > > > pread64(13, "@\26\377\353\0\0P\343\n\0\0\32\4\0\235\345\326\f\0\353\0
> > > > \240\341\0010\240\341\4\0\240\341"..., 4096, 331888) = 4096
> > > > write(1, "luvi v2.12.0\n", 13luvi v2.12.0
> > > > 
> > > > 
> > > > luajit:
> > > > 
> > > > pipe2([6, 7], O_NONBLOCK|O_CLOEXEC)     = 0
> > > > eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 8
> > > > open("./init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
> > > > directory)
> > > > open("/usr/share/luajit-2.1.0-beta3/init.lua", O_RDONLY|O_LARGEFILE)
> > > > = -1 ENOENT
> > > > (No such file or directory)
> > > > open("/usr/local/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1
> > > > ENOENT (No
> > > > such file or directory)
> > > > open("/usr/local/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE)
> > > > = -1 ENOENT
> > > > (No such file or directory)
> > > > open("/usr/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT
> > > > (No such
> > > > file or directory)
> > > > open("/usr/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE) = -1
> > > > ENOENT (No
> > > > such file or directory)
> > > > open("./init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
> > > > directory)
> > > > open("/usr/local/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1
> > > > ENOENT (No
> > > > such file or directory)
> > > > open("/usr/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT
> > > > (No such file
> > > > or directory)
> > > > open("/usr/local/lib/lua/5.1/loadall.so", O_RDONLY|O_LARGEFILE) = -1
> > > > ENOENT (No
> > > > such file or directory)
> > > > write(2, "[string \"return require('init')("..., 596[string "return
> > > > require('init')(...)"]:1: module 'init' not found:
> > > > 
> > > > Something is strange here...
> > > > 
> > > > Best regards,
> > > > Romain
> > > > 
> > > > 
> > > 
> > > 
> > > luvi requires a luajit built with the `-DLUAJIT_ENABLE_LUA52COMPAT`
> > > flag.
> > > it was the default with moonjit.
> > > the package luvi must :
> > >        select BR2_PACKAGE_LUAJIT_COMPAT52
> > > 
> > > François
> > >  
> > > > 
> > > > > it is about `init.lua` is not installed by luvi package.
> > > > > 
> > > > > François
> > > > >  
> > > > > 
> > > > >      Signed-off-by: Romain Naour <romain.naour@gmail.com
> > > > >      <mailto:romain.naour@gmail.com>>
> > > > >      Cc: Francois Perrad <francois.perrad@gadz.org
> > > > > <mailto:francois.perrad@gadz.org>>
> > > > >      Cc: Jörg Krause <joerg.krause@embedded.rocks>
> > > > > 
> > > > 
> > 
>
Romain Naour Nov. 7, 2021, 10:27 p.m. UTC | #9
Hi Jörg;

Le 07/11/2021 à 21:08, Jörg Krause a écrit :
> Hello,
> 
> just noticed I missed the second patch [2] of the series. I will re-run
> the test with the patch applied.

git bisect says that luvi doesn't work with luajit since this commit [1].

Adding -DLUAJIT_DISABLE_GC64 to luajit.mk allow to use luvi -v on the target but
I get a strange behavior. The list returned by luvi -v is not always in the same
order:

# luvi -v

                            luvi v2.12.0

                                                        rex: 8.45 2021-06-15


   libuv: 1.42.0

                               zlib: 1.2.11

                                                           ssl: OpenSSL 1.1.1l
24 Aug 2021, lua-openssl 0.7.8

# luvi -v

                            luvi v2.12.0

                                                        libuv: 1.42.0


   ssl: OpenSSL 1.1.1l  24 Aug 2021, lua-openssl 0.7.8

                               rex: 8.45 2021-06-15

                                                           zlib: 1.2.11

The current test is expecting having a reproducible result.

With moonjit we get the same result each time.

I'm not sure if using luajit is really safe for the upcoming Buildroot release.

[1] https://github.com/LuaJIT/LuaJIT/commit/bd00094c3b50e193fb32aad79b7ea8ea6b78ed25

Best regards,
Romain



> 
> [2]
> http://patchwork.ozlabs.org/project/buildroot/patch/20211031210258.654193-2-romain.naour@gmail.com/
> 
> Best regards
> Jörg Krause
> 
> On Sun, 2021-11-07 at 15:01 +0100, Romain Naour wrote:
>> Hello Jörg, François,
>>
>> Le 07/11/2021 à 12:04, Jörg Krause a écrit :
>>> Hi François, Hi Romain,
>>>
>>> the issue has nothing to do with static linking (the issue Romain cited
>>> was raised by in 2015 has been fixed long time ago) nor is it an issue
>>> about moonjit vs luajit as correctly stated by François. Also, it is
>>> not about setting `LUAJIT_ENABLE_LUA52COMPAT`.
>>>
>>> After applying the patch [1] from Romain I am building and running luvi
>>> on my machine successfully:
>>
>> To reproduce easily the issue you can use the
>>
>> ./support/testing/run-tests -o testsuite-master/ -d dl/ -k --timeout-multiplier
>> 10 tests.package.test_luvi.TestLuvi
>>
>> Indeed, even with LUAJIT_ENABLE_LUA52COMPAT enabled the test is failing.
>>
>>>
>>> ```
>>> LD_LIBRARY_PATH="./output/target/usr/lib/:./output/target/lib" ./output/target/usr/bin/luvi
>>> ./output/target/usr/bin/luvi v2.12.0
>>> libuv: 1.42.0
>>> ```
>>>
>>> The file `init.lua` is Luajitted into an object file: 
>>> ```
>>> Building $BR/output/host/share/luajit-2.1.0-beta3/?.lua Luajitted $BR/output/build/luvi-2.12.0/src/lua/init.lua: $BR/output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
>>
>> Sorry, I used "static linking" but I talked about what you call "luajitted".
>> When building using luajit I can still see init.lua_luvi_generated.o being
>> compiled and used to link luvi binary.
>>
>> Do you remember this issue ? it seems similar:
>> https://github.com/luvit/luvi/commit/b8781653dcb8815a3019a77baf4f3b7f7a255ebe
>>
>>> ```
>>>
>>> My first guess is, that the byte code generated by luajit is generated
>>> for a different machine than luvi is actually running on. Is
>>> `file output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o`
>>> printing the correct file type information?
>>
>> This .o file seems ok
>>
>> $ readelf -h
>> ./TestLuvi/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
>> En-tête ELF:
>>   Magique:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
>>   Classe:                            ELF32
>>   Données:                          complément à 2, système à octets de poids
>> faible d'abord (little endian)
>>   Version:                           1 (actuelle)
>>   OS/ABI:                            UNIX - System V
>>   Version ABI:                       0
>>   Type:                              REL (Fichier de réadressage)
>>   Machine:                           ARM
>>
>>
>> The luvi test has been added to buildroot before the switch to moonjit (was
>> luajit 2.0.5). I just tested with luajit 2.0.5 and the test pass.
>>
>> Best regards,
>> Romain
>>
>>
>>>
>>> [1] http://patchwork.ozlabs.org/project/buildroot/patch/20211031210258.654193-1-romain.naour@gmail.com/
>>>
>>> Best regards
>>> Jörg Krause
>>>
>>> On Sun, 2021-11-07 at 09:30 +0100, François Perrad wrote:
>>>>
>>>>
>>>> Le sam. 6 nov. 2021 à 23:02, Romain Naour <romain.naour@gmail.com> a
>>>> écrit :
>>>>> Le 06/11/2021 à 22:19, François Perrad a écrit :
>>>>>>
>>>>>>https://github.com/LuaJIT/LuaJIT/commit/bd00094c3b50e193fb32aad79b7ea8ea6b78ed25
>>>>>> Le sam. 6 nov. 2021 à 20:01, Romain Naour <romain.naour@gmail.com
>>>>>> <mailto:romain.naour@gmail.com>> a écrit :
>>>>>>
>>>>>>      This reverts commit 9450b53c8e06f1b5a75840b82c0f4663a5d75c45
>>>>>> since it
>>>>>>      introcude a regretion to luvi package [1].
>>>>>>
>>>>>>      luvi doesn't work since the luv static linking doesn't seems
>>>>>> to
>>>>>>      work anymore.
>>>>>>      (see
>>>>>>    
>>>>>>  https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
>>>>>> 2d70f6b7067
>>>>>> <https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
>>>>>> 2d70f6b7067>)
>>>>>>
>>>>>>       # luvi -v
>>>>>>
>>>>>>      [string "return require('init')(...)"]:1: module 'init' not
>>>>>> found:
>>>>>>
>>>>>>              no field package.preload['init']
>>>>>>              no file './init.lua'
>>>>>>              no file '/usr/share/luajit-2.1.0-beta3/init.lua'
>>>>>>              no file '/usr/local/share/lua/5.1/init.lua'
>>>>>>              no file '/usr/local/share/lua/5.1/init/init.lua'
>>>>>>              no file '/usr/share/lua/5.1/init.lua'
>>>>>>              no file '/usr/share/lua/5.1/init/init.lua'
>>>>>>              no file './init.so'
>>>>>>              no file '/usr/local/lib/lua/5.1/init.so'
>>>>>>              no file '/usr/lib/lua/5.1/init.so'
>>>>>>              no file '/usr/local/lib/lua/5.1/loadall.so'
>>>>>>
>>>>>>      stack traceback:
>>>>>>              [C]: in function 'require'
>>>>>>              [string "return require('init')(...)"]:1: in main
>>>>>> chunk
>>>>>>
>>>>>>      luvi now try to load init.lua script:
>>>>>>      https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176
>>>>>>      <https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176>
>>>>>>
>>>>>>      Luvi seems to rely on some moonjit extentions [2] not
>>>>>> available yet in
>>>>>>      luajit.
>>>>>>
>>>>>>      [1] http://lists.busybox.net/pipermail/buildroot/2021-
>>>>>> October/627134.html
>>>>>>      <http://lists.busybox.net/pipermail/buildroot/2021-
>>>>>> October/627134.html>
>>>>>>      [2]
>>>>>> https://github.com/moonjit/moonjit/blob/master/doc/extensions.md
>>>>>>    
>>>>>>  <https://github.com/moonjit/moonjit/blob/master/doc/extensions.md>
>>>>>>
>>>>>>
>>>>>> the module `init.lua` is supplied by luvi (see
>>>>>> https://github.com/luvit/luvi/blob/master/src/lua/init.lua
>>>>>> <https://github.com/luvit/luvi/blob/master/src/lua/init.lua>)
>>>>>> and installed somewhere or not (I cannot find it).
>>>>>>
>>>>>> moonjit 2.1.2 try to load a Lua module from these locations :
>>>>>>     './init.lua'
>>>>>>     '/usr/share/luajit-2.1.2/init.lua' (usually reserved to luajit
>>>>>> itself)
>>>>>>     '/usr/local/share/lua/5.1/init.lua'
>>>>>>     '/usr/local/share/lua/5.1/init/init.lua'
>>>>>>     '/usr/share/lua/5.1/init.lua'
>>>>>>     '/usr/share/lua/5.1/init/init.lua'
>>>>>>
>>>>>> luajit try to load a Lua module from these locations :
>>>>>>     './init.lua'
>>>>>>     '/usr/share/luajit-2.1.0-beta3/init.lua' (usually reserved to
>>>>>> luajit itself)
>>>>>>     '/usr/local/share/lua/5.1/init.lua'
>>>>>>     '/usr/local/share/lua/5.1/init/init.lua'
>>>>>>     '/usr/share/lua/5.1/init.lua'
>>>>>>     '/usr/share/lua/5.1/init/init.lua'
>>>>>>
>>>>>> this issue is not about moonjit vs luajit,
>>>>>
>>>>> The luajit vs moonjit traces are clearly not the same (using strace)
>>>>>
>>>>> moonjit doesn't even try to open init.lua (init.lua is not installed
>>>>> in target):
>>>>>
>>>>> open("/usr/bin/luvi", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 13
>>>>> statx(13, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL,
>>>>> {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0,
>>>>> stx_mode=S_IFREG|0755, stx_size=401472, ...}) = 0
>>>>> pread64(13,
>>>>> "\213\240\5\0h'\4\0\373\277\5\0X5\4\0\342\305\5\0t-
>>>>> \4\0G\260\5\0\34'\4\0"...,
>>>>> 4096, 397376) = 4096
>>>>> pread64(13,
>>>>> "\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\351\232\5\0K\253\5\0\361\232\5\0\
>>>>> 367\232\5"...,
>>>>> 4096, 393283) = 4096
>>>>> pread64(13,
>>>>> "\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\
>>>>> 334N"...,
>>>>> 4096, 389190) = 4096
>>>>> pread64(13, "ed\0lz.inflate.meta\0BEST_SPEED\0BE"..., 4096, 385097) =
>>>>> 4096
>>>>> pread64(13, "Luvi/build/luvi-2.12.0/deps/lua-"..., 4096, 381004) =
>>>>> 4096
>>>>> pread64(13, "ept fail\0#1 BIO must be memory t"..., 4096, 376911) =
>>>>> 4096
>>>>> pread64(13, "scape_ca_dn_bug\0netscape_challen"..., 4096, 372818) =
>>>>> 4096
>>>>> pread64(13, " to cert\0PKCS12_careate failed,p"..., 4096, 368725) =
>>>>> 4096
>>>>> pread64(13,
>>>>> "\200+\10\0\0-
>>>>> \t\0\08\t\7\t9\t\0\t\22\n\0\0B\t\2\3\22\3\n\0\22\10\t"..., 4096,
>>>>> 364632) = 4096
>>>>> pread64(13,
>>>>> "'\7\2\0\22\10\2\0\22\t\3\0B\5\5\2&\4\5\4L\4\2\0K\0\1\0\6\\\6/"...,
>>>>> 4096, 360539) = 4096
>>>>> pread64(13, "ve is too large\0validation faile"..., 4096, 356446) =
>>>>> 4096
>>>>> pread64(13,
>>>>> "\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\2
>>>>> 1\21\21\21\21\21\21\21\21\21"...,
>>>>> 4096, 352353) = 4096
>>>>> pread64(13,
>>>>> "TP\237\345\3p\300\343\200\1\240\341\30`\0\342H\200\237\345\25V\240\3
>>>>> 41\1\220\240\341\0\0\227\345"...,
>>>>> 4096, 348260) = 4096
>>>>> pread64(13,
>>>>> "\1#\0\0:\1\0P\341\32\0\0\232\2\0\21\341\33\0\0\n\21?o\341\20/o\341\2
>>>>> C"...,
>>>>> 4096, 344167) = 4096
>>>>> pread64(13,
>>>>> "\215\342\4\360\235\344\363G-
>>>>> \351\34\221\237\345\0`\240\341\0@\240\343\2p\240\341\f\0\220\345\4
>>>>> "..., 4096, 340074) = 4096
>>>>> pread64(13,
>>>>> "!\315\341\3\0\226\350\276\v\377\353\f\0p\343\0\0P\23\0p\240\341%\0\0
>>>>> \272\0\0P\343\0"...,
>>>>> 4096, 335981) = 4096
>>>>> pread64(13, "@\26\377\353\0\0P\343\n\0\0\32\4\0\235\345\326\f\0\353\0
>>>>> \240\341\0010\240\341\4\0\240\341"..., 4096, 331888) = 4096
>>>>> write(1, "luvi v2.12.0\n", 13luvi v2.12.0
>>>>>
>>>>>
>>>>> luajit:
>>>>>
>>>>> pipe2([6, 7], O_NONBLOCK|O_CLOEXEC)     = 0
>>>>> eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 8
>>>>> open("./init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
>>>>> directory)
>>>>> open("/usr/share/luajit-2.1.0-beta3/init.lua", O_RDONLY|O_LARGEFILE)
>>>>> = -1 ENOENT
>>>>> (No such file or directory)
>>>>> open("/usr/local/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1
>>>>> ENOENT (No
>>>>> such file or directory)
>>>>> open("/usr/local/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE)
>>>>> = -1 ENOENT
>>>>> (No such file or directory)
>>>>> open("/usr/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT
>>>>> (No such
>>>>> file or directory)
>>>>> open("/usr/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE) = -1
>>>>> ENOENT (No
>>>>> such file or directory)
>>>>> open("./init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
>>>>> directory)
>>>>> open("/usr/local/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1
>>>>> ENOENT (No
>>>>> such file or directory)
>>>>> open("/usr/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT
>>>>> (No such file
>>>>> or directory)
>>>>> open("/usr/local/lib/lua/5.1/loadall.so", O_RDONLY|O_LARGEFILE) = -1
>>>>> ENOENT (No
>>>>> such file or directory)
>>>>> write(2, "[string \"return require('init')("..., 596[string "return
>>>>> require('init')(...)"]:1: module 'init' not found:
>>>>>
>>>>> Something is strange here...
>>>>>
>>>>> Best regards,
>>>>> Romain
>>>>>
>>>>>
>>>>
>>>>
>>>> luvi requires a luajit built with the `-DLUAJIT_ENABLE_LUA52COMPAT`
>>>> flag.
>>>> it was the default with moonjit.
>>>> the package luvi must :
>>>>        select BR2_PACKAGE_LUAJIT_COMPAT52
>>>>
>>>> François
>>>>  
>>>>>
>>>>>> it is about `init.lua` is not installed by luvi package.
>>>>>>
>>>>>> François
>>>>>>  
>>>>>>
>>>>>>      Signed-off-by: Romain Naour <romain.naour@gmail.com
>>>>>>      <mailto:romain.naour@gmail.com>>
>>>>>>      Cc: Francois Perrad <francois.perrad@gadz.org
>>>>>> <mailto:francois.perrad@gadz.org>>
>>>>>>      Cc: Jörg Krause <joerg.krause@embedded.rocks>
>>>>>>
>>>>>
>>>
>>
>
Peter Korsgaard Nov. 8, 2021, 7:45 a.m. UTC | #10
>>>>> "Romain" == Romain Naour <romain.naour@gmail.com> writes:

 > Hi Jörg;
 > Le 07/11/2021 à 21:08, Jörg Krause a écrit :
 >> Hello,
 >> 
 >> just noticed I missed the second patch [2] of the series. I will re-run
 >> the test with the patch applied.

 > git bisect says that luvi doesn't work with luajit since this commit [1].

 > Adding -DLUAJIT_DISABLE_GC64 to luajit.mk allow to use luvi -v on the target but
 > I get a strange behavior. The list returned by luvi -v is not always in the same
 > order:

Funky. The commit says that this only applies to 64bit target, but the
test uses armv7, so perhaps it is indeed something related to
host/target confusion?

 > I'm not sure if using luajit is really safe for the upcoming Buildroot release.

Hmm, no perhaps not. Still, if moonjit is unmaintained we will need to
move away from it (E.G. before 2022.02) so it would be good to get to
the bottom of this issue.
Jörg Krause Nov. 8, 2021, 8:04 p.m. UTC | #11
Hi Romain,

On Sun, 2021-11-07 at 23:27 +0100, Romain Naour wrote:
> Hi Jörg;
> 
> Le 07/11/2021 à 21:08, Jörg Krause a écrit :
> > Hello,
> > 
> > just noticed I missed the second patch [2] of the series. I will re-run
> > the test with the patch applied.
> 
> git bisect says that luvi doesn't work with luajit since this commit [1].
> 

Thanks for digging into this!

The issue is that luvi is using the host-luajit binary to generate the
target specific luajitted object files, like init.lua_luvi_generated.o,
etc.

So, when host-luajit is build with GC64 enabled, luajit generates
different bytecode compared to host-luajit being build with GC64
disabled.

> Adding -DLUAJIT_DISABLE_GC64 to luajit.mk allow to use luvi -v on the target but
> I get a strange behavior. The list returned by luvi -v is not always in the same
> order:
> 

Seems this is expected behavior. See LuaJIT FAQ:
https://luajit.org/faq.html

Q: Table iteration with pairs() does not result in the same order?

> # luvi -v
> 
>                             luvi v2.12.0
> 
>                                                         rex: 8.45 2021-06-15
> 
> 
>    libuv: 1.42.0
> 
>                                zlib: 1.2.11
> 
>                                                            ssl: OpenSSL 1.1.1l
> 24 Aug 2021, lua-openssl 0.7.8
> 
> # luvi -v
> 
>                             luvi v2.12.0
> 
>                                                         libuv: 1.42.0
> 
> 
>    ssl: OpenSSL 1.1.1l  24 Aug 2021, lua-openssl 0.7.8
> 
>                                rex: 8.45 2021-06-15
> 
>                                                            zlib: 1.2.11
> 
> The current test is expecting having a reproducible result.
> 
> With moonjit we get the same result each time.
> 
> I'm not sure if using luajit is really safe for the upcoming Buildroot release.
> 
> [1] https://github.com/LuaJIT/LuaJIT/commit/bd00094c3b50e193fb32aad79b7ea8ea6b78ed25
> 
> Best regards,
> Romain
> 
> 

Best regards
Jörg Krause

> 
> > 
> > [2]
> > http://patchwork.ozlabs.org/project/buildroot/patch/20211031210258.654193-2-romain.naour@gmail.com/
> > 
> > Best regards
> > Jörg Krause
> > 
> > On Sun, 2021-11-07 at 15:01 +0100, Romain Naour wrote:
> > > Hello Jörg, François,
> > > 
> > > Le 07/11/2021 à 12:04, Jörg Krause a écrit :
> > > > Hi François, Hi Romain,
> > > > 
> > > > the issue has nothing to do with static linking (the issue Romain cited
> > > > was raised by in 2015 has been fixed long time ago) nor is it an issue
> > > > about moonjit vs luajit as correctly stated by François. Also, it is
> > > > not about setting `LUAJIT_ENABLE_LUA52COMPAT`.
> > > > 
> > > > After applying the patch [1] from Romain I am building and running luvi
> > > > on my machine successfully:
> > > 
> > > To reproduce easily the issue you can use the
> > > 
> > > ./support/testing/run-tests -o testsuite-master/ -d dl/ -k --timeout-multiplier
> > > 10 tests.package.test_luvi.TestLuvi
> > > 
> > > Indeed, even with LUAJIT_ENABLE_LUA52COMPAT enabled the test is failing.
> > > 
> > > > 
> > > > ```
> > > > LD_LIBRARY_PATH="./output/target/usr/lib/:./output/target/lib" ./output/target/usr/bin/luvi
> > > > ./output/target/usr/bin/luvi v2.12.0
> > > > libuv: 1.42.0
> > > > ```
> > > > 
> > > > The file `init.lua` is Luajitted into an object file: 
> > > > ```
> > > > Building $BR/output/host/share/luajit-2.1.0-beta3/?.lua Luajitted $BR/output/build/luvi-2.12.0/src/lua/init.lua: $BR/output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
> > > 
> > > Sorry, I used "static linking" but I talked about what you call "luajitted".
> > > When building using luajit I can still see init.lua_luvi_generated.o being
> > > compiled and used to link luvi binary.
> > > 
> > > Do you remember this issue ? it seems similar:
> > > https://github.com/luvit/luvi/commit/b8781653dcb8815a3019a77baf4f3b7f7a255ebe
> > > 
> > > > ```
> > > > 
> > > > My first guess is, that the byte code generated by luajit is generated
> > > > for a different machine than luvi is actually running on. Is
> > > > `file output/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o`
> > > > printing the correct file type information?
> > > 
> > > This .o file seems ok
> > > 
> > > $ readelf -h
> > > ./TestLuvi/build/luvi-2.12.0/jitted_tmp/src/lua/init.lua_luvi_generated.o
> > > En-tête ELF:
> > >   Magique:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
> > >   Classe:                            ELF32
> > >   Données:                          complément à 2, système à octets de poids
> > > faible d'abord (little endian)
> > >   Version:                           1 (actuelle)
> > >   OS/ABI:                            UNIX - System V
> > >   Version ABI:                       0
> > >   Type:                              REL (Fichier de réadressage)
> > >   Machine:                           ARM
> > > 
> > > 
> > > The luvi test has been added to buildroot before the switch to moonjit (was
> > > luajit 2.0.5). I just tested with luajit 2.0.5 and the test pass.
> > > 
> > > Best regards,
> > > Romain
> > > 
> > > 
> > > > 
> > > > [1] http://patchwork.ozlabs.org/project/buildroot/patch/20211031210258.654193-1-romain.naour@gmail.com/
> > > > 
> > > > Best regards
> > > > Jörg Krause
> > > > 
> > > > On Sun, 2021-11-07 at 09:30 +0100, François Perrad wrote:
> > > > > 
> > > > > 
> > > > > Le sam. 6 nov. 2021 à 23:02, Romain Naour <romain.naour@gmail.com> a
> > > > > écrit :
> > > > > > Le 06/11/2021 à 22:19, François Perrad a écrit :
> > > > > > > 
> > > > > > > https://github.com/LuaJIT/LuaJIT/commit/bd00094c3b50e193fb32aad79b7ea8ea6b78ed25
> > > > > > > Le sam. 6 nov. 2021 à 20:01, Romain Naour <romain.naour@gmail.com
> > > > > > > <mailto:romain.naour@gmail.com>> a écrit :
> > > > > > > 
> > > > > > >      This reverts commit 9450b53c8e06f1b5a75840b82c0f4663a5d75c45
> > > > > > > since it
> > > > > > >      introcude a regretion to luvi package [1].
> > > > > > > 
> > > > > > >      luvi doesn't work since the luv static linking doesn't seems
> > > > > > > to
> > > > > > >      work anymore.
> > > > > > >      (see
> > > > > > >    
> > > > > > >  https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
> > > > > > > 2d70f6b7067
> > > > > > > <https://github.com/luvit/luvi/commit/a9dc8dae2eb69d4a754a0cf5c0862
> > > > > > > 2d70f6b7067>)
> > > > > > > 
> > > > > > >       # luvi -v
> > > > > > > 
> > > > > > >      [string "return require('init')(...)"]:1: module 'init' not
> > > > > > > found:
> > > > > > > 
> > > > > > >              no field package.preload['init']
> > > > > > >              no file './init.lua'
> > > > > > >              no file '/usr/share/luajit-2.1.0-beta3/init.lua'
> > > > > > >              no file '/usr/local/share/lua/5.1/init.lua'
> > > > > > >              no file '/usr/local/share/lua/5.1/init/init.lua'
> > > > > > >              no file '/usr/share/lua/5.1/init.lua'
> > > > > > >              no file '/usr/share/lua/5.1/init/init.lua'
> > > > > > >              no file './init.so'
> > > > > > >              no file '/usr/local/lib/lua/5.1/init.so'
> > > > > > >              no file '/usr/lib/lua/5.1/init.so'
> > > > > > >              no file '/usr/local/lib/lua/5.1/loadall.so'
> > > > > > > 
> > > > > > >      stack traceback:
> > > > > > >              [C]: in function 'require'
> > > > > > >              [string "return require('init')(...)"]:1: in main
> > > > > > > chunk
> > > > > > > 
> > > > > > >      luvi now try to load init.lua script:
> > > > > > >      https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176
> > > > > > >      <https://github.com/luvit/luvi/blob/v2.12.0/src/main.c#L176>
> > > > > > > 
> > > > > > >      Luvi seems to rely on some moonjit extentions [2] not
> > > > > > > available yet in
> > > > > > >      luajit.
> > > > > > > 
> > > > > > >      [1] http://lists.busybox.net/pipermail/buildroot/2021-
> > > > > > > October/627134.html
> > > > > > >      <http://lists.busybox.net/pipermail/buildroot/2021-
> > > > > > > October/627134.html>
> > > > > > >      [2]
> > > > > > > https://github.com/moonjit/moonjit/blob/master/doc/extensions.md
> > > > > > >    
> > > > > > >  <https://github.com/moonjit/moonjit/blob/master/doc/extensions.md>
> > > > > > > 
> > > > > > > 
> > > > > > > the module `init.lua` is supplied by luvi (see
> > > > > > > https://github.com/luvit/luvi/blob/master/src/lua/init.lua
> > > > > > > <https://github.com/luvit/luvi/blob/master/src/lua/init.lua>)
> > > > > > > and installed somewhere or not (I cannot find it).
> > > > > > > 
> > > > > > > moonjit 2.1.2 try to load a Lua module from these locations :
> > > > > > >     './init.lua'
> > > > > > >     '/usr/share/luajit-2.1.2/init.lua' (usually reserved to luajit
> > > > > > > itself)
> > > > > > >     '/usr/local/share/lua/5.1/init.lua'
> > > > > > >     '/usr/local/share/lua/5.1/init/init.lua'
> > > > > > >     '/usr/share/lua/5.1/init.lua'
> > > > > > >     '/usr/share/lua/5.1/init/init.lua'
> > > > > > > 
> > > > > > > luajit try to load a Lua module from these locations :
> > > > > > >     './init.lua'
> > > > > > >     '/usr/share/luajit-2.1.0-beta3/init.lua' (usually reserved to
> > > > > > > luajit itself)
> > > > > > >     '/usr/local/share/lua/5.1/init.lua'
> > > > > > >     '/usr/local/share/lua/5.1/init/init.lua'
> > > > > > >     '/usr/share/lua/5.1/init.lua'
> > > > > > >     '/usr/share/lua/5.1/init/init.lua'
> > > > > > > 
> > > > > > > this issue is not about moonjit vs luajit,
> > > > > > 
> > > > > > The luajit vs moonjit traces are clearly not the same (using strace)
> > > > > > 
> > > > > > moonjit doesn't even try to open init.lua (init.lua is not installed
> > > > > > in target):
> > > > > > 
> > > > > > open("/usr/bin/luvi", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 13
> > > > > > statx(13, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL,
> > > > > > {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0,
> > > > > > stx_mode=S_IFREG|0755, stx_size=401472, ...}) = 0
> > > > > > pread64(13,
> > > > > > "\213\240\5\0h'\4\0\373\277\5\0X5\4\0\342\305\5\0t-
> > > > > > \4\0G\260\5\0\34'\4\0"...,
> > > > > > 4096, 397376) = 4096
> > > > > > pread64(13,
> > > > > > "\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\351\232\5\0K\253\5\0\361\232\5\0\
> > > > > > 367\232\5"...,
> > > > > > 4096, 393283) = 4096
> > > > > > pread64(13,
> > > > > > "\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\334N\1\0\
> > > > > > 334N"...,
> > > > > > 4096, 389190) = 4096
> > > > > > pread64(13, "ed\0lz.inflate.meta\0BEST_SPEED\0BE"..., 4096, 385097) =
> > > > > > 4096
> > > > > > pread64(13, "Luvi/build/luvi-2.12.0/deps/lua-"..., 4096, 381004) =
> > > > > > 4096
> > > > > > pread64(13, "ept fail\0#1 BIO must be memory t"..., 4096, 376911) =
> > > > > > 4096
> > > > > > pread64(13, "scape_ca_dn_bug\0netscape_challen"..., 4096, 372818) =
> > > > > > 4096
> > > > > > pread64(13, " to cert\0PKCS12_careate failed,p"..., 4096, 368725) =
> > > > > > 4096
> > > > > > pread64(13,
> > > > > > "\200+\10\0\0-
> > > > > > \t\0\08\t\7\t9\t\0\t\22\n\0\0B\t\2\3\22\3\n\0\22\10\t"..., 4096,
> > > > > > 364632) = 4096
> > > > > > pread64(13,
> > > > > > "'\7\2\0\22\10\2\0\22\t\3\0B\5\5\2&\4\5\4L\4\2\0K\0\1\0\6\\\6/"...,
> > > > > > 4096, 360539) = 4096
> > > > > > pread64(13, "ve is too large\0validation faile"..., 4096, 356446) =
> > > > > > 4096
> > > > > > pread64(13,
> > > > > > "\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\21\2
> > > > > > 1\21\21\21\21\21\21\21\21\21"...,
> > > > > > 4096, 352353) = 4096
> > > > > > pread64(13,
> > > > > > "TP\237\345\3p\300\343\200\1\240\341\30`\0\342H\200\237\345\25V\240\3
> > > > > > 41\1\220\240\341\0\0\227\345"...,
> > > > > > 4096, 348260) = 4096
> > > > > > pread64(13,
> > > > > > "\1#\0\0:\1\0P\341\32\0\0\232\2\0\21\341\33\0\0\n\21?o\341\20/o\341\2
> > > > > > C"...,
> > > > > > 4096, 344167) = 4096
> > > > > > pread64(13,
> > > > > > "\215\342\4\360\235\344\363G-
> > > > > > \351\34\221\237\345\0`\240\341\0@\240\343\2p\240\341\f\0\220\345\4
> > > > > > "..., 4096, 340074) = 4096
> > > > > > pread64(13,
> > > > > > "!\315\341\3\0\226\350\276\v\377\353\f\0p\343\0\0P\23\0p\240\341%\0\0
> > > > > > \272\0\0P\343\0"...,
> > > > > > 4096, 335981) = 4096
> > > > > > pread64(13, "@\26\377\353\0\0P\343\n\0\0\32\4\0\235\345\326\f\0\353\0
> > > > > > \240\341\0010\240\341\4\0\240\341"..., 4096, 331888) = 4096
> > > > > > write(1, "luvi v2.12.0\n", 13luvi v2.12.0
> > > > > > 
> > > > > > 
> > > > > > luajit:
> > > > > > 
> > > > > > pipe2([6, 7], O_NONBLOCK|O_CLOEXEC)     = 0
> > > > > > eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 8
> > > > > > open("./init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
> > > > > > directory)
> > > > > > open("/usr/share/luajit-2.1.0-beta3/init.lua", O_RDONLY|O_LARGEFILE)
> > > > > > = -1 ENOENT
> > > > > > (No such file or directory)
> > > > > > open("/usr/local/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1
> > > > > > ENOENT (No
> > > > > > such file or directory)
> > > > > > open("/usr/local/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE)
> > > > > > = -1 ENOENT
> > > > > > (No such file or directory)
> > > > > > open("/usr/share/lua/5.1/init.lua", O_RDONLY|O_LARGEFILE) = -1 ENOENT
> > > > > > (No such
> > > > > > file or directory)
> > > > > > open("/usr/share/lua/5.1/init/init.lua", O_RDONLY|O_LARGEFILE) = -1
> > > > > > ENOENT (No
> > > > > > such file or directory)
> > > > > > open("./init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or
> > > > > > directory)
> > > > > > open("/usr/local/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1
> > > > > > ENOENT (No
> > > > > > such file or directory)
> > > > > > open("/usr/lib/lua/5.1/init.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT
> > > > > > (No such file
> > > > > > or directory)
> > > > > > open("/usr/local/lib/lua/5.1/loadall.so", O_RDONLY|O_LARGEFILE) = -1
> > > > > > ENOENT (No
> > > > > > such file or directory)
> > > > > > write(2, "[string \"return require('init')("..., 596[string "return
> > > > > > require('init')(...)"]:1: module 'init' not found:
> > > > > > 
> > > > > > Something is strange here...
> > > > > > 
> > > > > > Best regards,
> > > > > > Romain
> > > > > > 
> > > > > > 
> > > > > 
> > > > > 
> > > > > luvi requires a luajit built with the `-DLUAJIT_ENABLE_LUA52COMPAT`
> > > > > flag.
> > > > > it was the default with moonjit.
> > > > > the package luvi must :
> > > > >        select BR2_PACKAGE_LUAJIT_COMPAT52
> > > > > 
> > > > > François
> > > > >  
> > > > > > 
> > > > > > > it is about `init.lua` is not installed by luvi package.
> > > > > > > 
> > > > > > > François
> > > > > > >  
> > > > > > > 
> > > > > > >      Signed-off-by: Romain Naour <romain.naour@gmail.com
> > > > > > >      <mailto:romain.naour@gmail.com>>
> > > > > > >      Cc: Francois Perrad <francois.perrad@gadz.org
> > > > > > > <mailto:francois.perrad@gadz.org>>
> > > > > > >      Cc: Jörg Krause <joerg.krause@embedded.rocks>
> > > > > > > 
> > > > > > 
> > > > 
> > > 
> > 
>
Francois Perrad Nov. 9, 2021, 8:39 a.m. UTC | #12
Le dim. 7 nov. 2021 à 23:27, Romain Naour <romain.naour@gmail.com> a écrit :

> Hi Jörg;
>
> Le 07/11/2021 à 21:08, Jörg Krause a écrit :
> > Hello,
> >
> > just noticed I missed the second patch [2] of the series. I will re-run
> > the test with the patch applied.
>
> git bisect says that luvi doesn't work with luajit since this commit [1].
>
> Adding -DLUAJIT_DISABLE_GC64 to luajit.mk allow to use luvi -v on the
> target but
> I get a strange behavior. The list returned by luvi -v is not always in
> the same
> order:
>
> # luvi -v
>
>                             luvi v2.12.0
>
>                                                         rex: 8.45
> 2021-06-15
>
>
>    libuv: 1.42.0
>
>                                zlib: 1.2.11
>
>                                                            ssl: OpenSSL
> 1.1.1l
> 24 Aug 2021, lua-openssl 0.7.8
>
> # luvi -v
>
>                             luvi v2.12.0
>
>                                                         libuv: 1.42.0
>
>
>    ssl: OpenSSL 1.1.1l  24 Aug 2021, lua-openssl 0.7.8
>
>                                rex: 8.45 2021-06-15
>
>                                                            zlib: 1.2.11
>
> The current test is expecting having a reproducible result.
>
> With moonjit we get the same result each time.
>
> I'm not sure if using luajit is really safe for the upcoming Buildroot
> release.
>
> [1]
> https://github.com/LuaJIT/LuaJIT/commit/bd00094c3b50e193fb32aad79b7ea8ea6b78ed25
>
>
thanks Romain,

your bisect gives the fix,
see
https://patchwork.ozlabs.org/project/buildroot/patch/20211108201054.225256-1-francois.perrad@gadz.org/

François

Best regards,
> Romain
>
>
>
>
>
diff mbox series

Patch

diff --git a/package/luajit/Config.in b/package/luajit/Config.in
index e4e1249240..eb3eb01998 100644
--- a/package/luajit/Config.in
+++ b/package/luajit/Config.in
@@ -27,7 +27,7 @@  config BR2_PACKAGE_LUAJIT
 	  ABI-compatible to the standard Lua interpreter and can be
 	  deployed as a drop-in replacement.
 
-	  https://luajit.org/luajit.html
+	  https://github.com/moonjit/moonjit
 
 if BR2_PACKAGE_LUAJIT
 
diff --git a/package/luajit/luajit.hash b/package/luajit/luajit.hash
index 1497ee9df4..532ec0b294 100644
--- a/package/luajit/luajit.hash
+++ b/package/luajit/luajit.hash
@@ -1,5 +1,5 @@ 
 # Locally calculated
-sha256  b1b19f92451a661ba1167ee0b259299616cb3a1cdaf5ab05d7ccffaffeb4a0fb  luajit-05f1984e1a862e4b3d3c3b370c773492e2edf84a.tar.gz
+sha256 c3de8e29aa617fc594c043f57636ab9ad71af2b4a3a513932b05f5cdaa4320b2  luajit-2.1.2.tar.gz
 
 # Locally calculated
-sha256  43fc251179d900f9948e51dd3cc93733d1219f2db060faaa0c8100ad054f54d8  COPYRIGHT
+sha256 aa64a7706ded773011b933f4230d7b35ba662598197f82ac2c7bca62abdaa4d7  COPYRIGHT
diff --git a/package/luajit/luajit.mk b/package/luajit/luajit.mk
index fbbd8ebc70..defa21dd3f 100644
--- a/package/luajit/luajit.mk
+++ b/package/luajit/luajit.mk
@@ -4,8 +4,8 @@ 
 #
 ################################################################################
 
-LUAJIT_VERSION = 05f1984e1a862e4b3d3c3b370c773492e2edf84a
-LUAJIT_SITE = $(call github,LuaJIT,LuaJIT,$(LUAJIT_VERSION))
+LUAJIT_VERSION = 2.1.2
+LUAJIT_SITE = $(call github,moonjit,moonjit,$(LUAJIT_VERSION))
 LUAJIT_LICENSE = MIT
 LUAJIT_LICENSE_FILES = COPYRIGHT