sol2
sol2 copied to clipboard
LuaJIT: print(jit) and print(require('jit')) are different.
StackOverflow post: https://stackoverflow.com/questions/72081958/why-does-luajits-jit-module-appear-as-a-string-when-loaded-through-require
Hi. I noticed something strange. I compiled a program using Sol3 (cloned from this repo on the day of posting) and LuaJIT (2.1.0-beta3, pulled from Arch repositories). The problem: print(jit)
and print(require('jit'))
return different things. The former returns a table, while the latter returns a string.
Some internal LuaJIT libraries require LuaJIT via require('jit')
, and then try to index it as a table. For example, p.lua
(the profiler). This explodes quickly and violently for obvious reasons.
I made a repro here. If the built library does not work on your machine, I just cloned the LuaJIT repository and ran make install
into the repo directory. Here's the output:
inspect(jit): {
arch = "x64",
attach = <function 1>,
flush = <function 2>,
off = <function 3>,
on = <function 4>,
opt = {
start = <function 5>
},
os = "Linux",
security = <function 6>,
status = <function 7>,
version = "LuaJIT 2.1.0-beta3",
version_num = 20100
}
inspect(require("jit")) "LuaJIT 2.1.0-beta3"
https://github.com/spaderthomas/luajit-sol-repro
I am not sure if this is me being silly, or a bug somewhere.
Hi, just giving this a little bump. Thanks for your time!