How to enable LuaJIT in GeeXLab




LuaJIT logo

LuaJIT is a Just-In-Time compiler for Lua. It’s actually a special version of Lua that optimizes Lua bytecode and when possible, converts it to machine code (see DynASM). Thanks to LuaJIT, Lua code can be really fast!

LuaJIT support is available in GeeXLab for Windows since version 0.16.1.1 and has been added to Linux in version 0.22.1.0. I also tested LuaJIT on macOS but I didn’t manage to make it work. I will retry later.

I will add LuaJIT support to Raspberry Pi and Tinker Board as soon as possible.

GeeXLab comes with the latest version of Lua which is Lua 5.3.4. On the other hand, the current version of LuaJIT supports Lua 5.1 only. So as long as you use regular Lua code (read compatible with Lua 5.1), everything is perfect and LuaJIT works fine. But if you use some features like bitwise operators (added in Lua 5.3), LuaJIT will generates an compilation error (for that particular case, the Lua Bit Operations Module can help).

Now that you know the limitations of LuaJIT, let’s see how to enable it in GeeXLab. You have to rename two dynamic libraries:

– on Windows, the regular Lua 5.3.4 engine is embedded in the gxl_x{32|64}.dll while the LuaJIT 2.0.5 engine is linked with gxl_x{32|64}_luajit.dll. GeeXLab is linked with gxl_x{32|64}.dll. So take advantage of LuaJIT, just rename gxl_x{32|64}_luajit.dll in gxl_x{32|64}.dll. That’s all.

– same thing on Linux: you have two dynamic libraries in the dylibs/ folders: libgxl_r_linux_x64.so and libgxl_r_linux_x64_luajit.so. Just rename libgxl_r_linux_x64_luajit.so in libgxl_r_linux_x64.so.

Last thing: there is a function in the gh_utils lib that allows to know if the current Lua engine is LuaJIT:

local ret = gh_utils.is_luajit()

For any feedback or bug report, a discussion thread is available HERE.