Open noncom opened 1 month ago
If you can send a PR for it, we'll review it.
Note that our official distribution is compiled using LuaJIT, for compatibility and performance reasons.
Ok so I researched the situation a bit more, and discovered this: https://github.com/lua/lua/blob/v5.4/lauxlib.h#L282.
Adding
#define LUA_COMPAT_APIINTCASTS 1
enables the compatibility mode and fixes the compilation error.
This reveals another compilation error about lua_assert()
not being found in function utf8esc()
in lutf8lib.c
. Probably it's another API change.
This one is fixed by adding
#include "llimits.h"
to the includes in the file.
And after that Love2D compiles well with Lua 5.4.7 (*).
So the conclusion I came to here is: I don't think that creating a meaningful PR for this is possible? It feels more like just some info for some "Compiling with Lua 5.4+" doc or something. Even having this ticket as a reference probably would do.
(*) -- For future reference, of course this required changing all Lua5.1-related paths and constants in the makefile, and then creating the project and building with the LuaJit off flag:
cmake -G "Visual Studio 17 2022" -A x64 -S . -B build -DLOVE_JIT=OFF
cmake --build build --target love/love --config Release
Adding luax_checkint
and luax_optint
wrapper functions to runtime.h
which do return (int) luaL_check/optinteger(L, ...)
and then switching existing luaL_checkint
and luaL_optint
calls to those would be a good change, if you want to make a PR.
Yes, it would be great to simplify usage of Love2D with any LuaVM of choice. I will do this PR soon.
Also, the CMakeFiles of Love2D and megasource have the Lua51
and MEGA_LUA51
constant names to refer to a non-LuaJIT Lua.
I would propose changing them to just Lua
and MEGA_LUA
since all CMakeLists already have JIT-specific constants with "JIT" in their name, and the Lua version number isn't really relevant. That's what I did locally, and it worked fine.
Alternatively maybe PucLua
and MEGA_PUCLUA
if just "Lua" is too imprecise, but most often in other projects I saw just "LUA" and "LUAJIT" to differentiate between them.
Getting some compilation errors when using latest Lua 5.4.7, like:
There's quite a number of them, these are just some examples, but all of then are in the
wrap_*.cpp
files.I think that the explanation can be found in the last point of section
8.3 – Changes in the API
at https://www.lua.org/manual/5.3/manual.html. Long story short -- these macros are deprecated, and need to be replaced with different calls for Lua 5.3+. It would be great if Love2D would handle this to support the most rececnt Lua versions.