I compiled a program on Linux using LuaJit 2.1 beta3.I loaded the profiler as recommended in the docs, like so:
require("jit.p").start(options, output)
require("jit.p").stop()
However, the module failed to open, citing a version mismatch. Upon inspection of the source code of the module I was loading (p), I noticed that the code checked the version like so:
-- Cache some library functions and objects.
local jit = require("jit")
assert(jit.version_num == 20100, "LuaJIT core/library version mismatch")
I also noticed that these two things are different:
print(require('jit')) -- This prints a string describing my LuaJIT version
print(jit) -- This prints the table of the jit module
In other words, the LuaJIT profiler source code calls require('jit')
, which returns a string, but is clearly expecting a table. If I change that line to comment out jit = require('jit')
, it uses the preloaded jit package and everything works.
Why do jit
and require('jit')
return different things? Is this a remnant of Sol3?
Environment:
- Arch Linux
- luajit-2.1.0-beta3
- Binding to C++ with Sol3
- Repro here: https://github.com/spaderthomas/luajit-sol-repro