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

support for LuaJIT -- Lua 5.1 compatibility #14

Open
fhoefling opened this issue Feb 20, 2014 · 6 comments
Open

support for LuaJIT -- Lua 5.1 compatibility #14

fhoefling opened this issue Feb 20, 2014 · 6 comments

Comments

@fhoefling
Copy link

I was wondering whether the current development of luabind is still supporting LuaJIT? As of version 2.0.2, it provides Lua 5.1 headers and library.

The branch build_improvements has a file FindLua52.cmake which suggests that support for 5.1 has been dropped?

I have added LuaJIT to the CMake module (see https://github.com/fhoefling/luaponte/tree/build-improvements). It compiles with Clang 3.3, but all test except for one fail with a segfault.

@fhoefling
Copy link
Author

With a patch from https://github.com/hishamhm/lua-compat-5.2 the SEGFAULTS have been fixed:
halmd-org@3a5d225

The following tests FAILED:
19 - free_functions (Failed)
30 - object (Failed)

@fhoefling
Copy link
Author

The failing test "free_functions" has been fixed in halmd-org@707be05 . The reason was a typo (?) in the error message of Lua 5.1, which was fixed in LuaJIT.

The "object" test has the following output:

  30: Test command: /home/fluids/hoefling/build/luabind/test/test_object
  30: Test timeout computed to be: 1500
  30: .../luabind/test/test_object.cpp:465"TEST_CHECK failed: "boost::lexical_cast<std::string>(globals(L)["obj"]) == "custom __tostring"""
  1/1 Test #30: object ...........................***Failed    0.00 sec

with the following stack trace:

  #5  0x00007ffff7fcab22 in lua_rawset () from /local/modules/luajit-2.0.2/lib/libluajit-5.1.so.2
  #6  0x000000000042b052 in lua_rawsetp(lua_State*, int, void*) ()
  #7  0x0000000000439e7a in void* luabind::(anonymous namespace)::create_gc_udata<luabind::detail::class_registry>(lua_State*, void*) ()
  #8  0x0000000000439a21 in void luabind::(anonymous namespace)::push_gc_udata<luabind::detail::class_registry, lua_State*>(lua_State*, void*, lua_State*) ()
  #9  0x0000000000439912 in luabind::open(lua_State*) ()
  #10 0x00000000004226b2 in lua_state::lua_state() ()
  #11 0x0000000000422a22 in main ()

@the-nic
Copy link

the-nic commented Feb 21, 2014

This is due to the incorrect implementation of "luaL_tolstring" in lua_include.h. Further lua_[g,s]etuservalue seem to be wrong, too.
I'd suggest to use the implementations from https://github.com/hishamhm/lua-compat-5.2

@fhoefling
Copy link
Author

lua-compat-5.2 could be included as a submodule, which is only needed if Lua 5.1 was found. Then, lua-include.h would include compat-5.2.hpp instead of lua.hpp. In addition, one has to link against a small library liblua-compat-5.2 (next to the Lua 5.1 library).

For the CMake build system, the following would be needed:

  • FindLuaCompat.cmake
  • add_library(lua-compat-5.2 compat-5.2.c)
  • list(APPEND LUA_LIBRARIES "lua-compat-5.2")
  • include_directories(LUA_COMPAT_INCLUDE_DIR) pointing to ".../lua-compat-5.2/c-api"

I'm not yet sure where to place it, and I don't know what to do for other build systems.

@decimad
Copy link

decimad commented Feb 21, 2014

There are like how many calls in luabind that fail without a compatibility layer? 3 or so? If it were me to decide that would not be worth adding another external dependency. Of course it's a clean and modular solution in theory, but reality is always a tradeoff. So I'd go for simply copying the respective implementations from lua-compat with copyright info etc...

@fhoefling
Copy link
Author

"luaL_tolstring" has been fixed in halmd-org@4ed73bc

The branch now fully supports Lua 5.1 and LuaJIT 2.0.

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