Skip to content
New issue

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

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

Already on GitHub? # to your account

Requiring compat53 with LuaJIT fails #1542

Open
cassava opened this issue Oct 23, 2023 · 0 comments
Open

Requiring compat53 with LuaJIT fails #1542

cassava opened this issue Oct 23, 2023 · 0 comments

Comments

@cassava
Copy link

cassava commented Oct 23, 2023

Versions:

  • sol 3.3.1
  • luajit 2.1.0-beta3

Problem:
When requiring "compat53" module when LuaJIT is used, I get a curious error.

Output:

$ ./build/Debug/sol_compat53
[sol2] An error occurred and has been passed to an error handler: sol: runtime error: /usr/local/share/lua/5.1/compat53/init.lua:1: attempt to index global '_VERSION' (a string value)
stack traceback:
	/usr/local/share/lua/5.1/compat53/init.lua:1: in main chunk
	[C]: in function 'require'
	[string "..."]:2: in main chunk
terminate called after throwing an instance of 'sol::error'
  what():  sol: runtime error: /usr/local/share/lua/5.1/compat53/init.lua:1: attempt to index global '_VERSION' (a string value)
stack traceback:
	/usr/local/share/lua/5.1/compat53/init.lua:1: in main chunk
	[C]: in function 'require'
	[string "..."]:2: in main chunk
[1]    255547 abort (core dumped)  ./build/Debug/sol_compat53

Source:
sol_compat53.cpp:

#define SOL_ALL_SAFETIES_ON 1
#include <sol/sol.hpp>

int main() {
    sol::state lua;
    lua.open_libraries(sol::lib::base, sol::lib::package);

    lua.script(R"(
        require("compat53")
    )");
}

Here is the line that fails...

$ cat /usr/local/share/lua/5.1/compat53/init.lua | head -1
local lua_version = _VERSION:sub(-3)

Compile-Command:

/usr/bin/c++ \
  -DSOL_LUAJIT \
  -isystem [sol2-3.3.1]/include \
  -isystem [luajit-2.1.0-beta3]/include/luajit-2.1 \
  -m64 -g -std=gnu++17 \
  -o sol_compat53.cpp.o \
  -c sol_compat53.cpp

If I add a print statement above the require:

print(_VERSION)

I get the expected "Lua 5.1".

I feel like I'm missing something substantial, but I'm at a loss.

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

No branches or pull requests

1 participant