Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors with Lua 5.4.7 #2102

Open
noncom opened this issue Sep 20, 2024 · 4 comments
Open

Compilation errors with Lua 5.4.7 #2102

noncom opened this issue Sep 20, 2024 · 4 comments

Comments

@noncom
Copy link

noncom commented Sep 20, 2024

Getting some compilation errors when using latest Lua 5.4.7, like:

...
love\src\modules\graphics\wrap_Mesh.cpp(294,18): error C3861: 'luaL_checkint': identifier not found
...
love\src\modules\graphics\wrap_Graphics.cpp(1298,28): error C3861: 'luaL_checkint': identifier not found 
...
love\src\modules\image\wrap_ImageData.cpp(166,11): error C3861: 'luaL_optint': identifier not found
...

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.

@MikuAuahDark
Copy link
Contributor

MikuAuahDark commented Sep 20, 2024

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.

@noncom
Copy link
Author

noncom commented Sep 21, 2024

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

@slime73
Copy link
Member

slime73 commented Sep 29, 2024

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.

@noncom
Copy link
Author

noncom commented Oct 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants