-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Not possible to build sol2 v3.3.0 with Lua 5.3 with bitlib compatibility enabled #1461
Comments
Compile Lua as C++. When Lua is compiled as C, it uses setjmp/longjmp for error handling, resulting in failure to unwind intermediate stack frames. Trying to ensure no objects with non-trivial destructors are in scope when raising a Lua error is error-prone. In particular, converting an exception to a Lua error becomes convoluted, and raising a Lua error from a constructor is effectively impossible. Updated Lua to 5.4.4 - this includes a brand-new garbage collector implementation with better performance. The main thing removed is the deprecated bitlib. Updated sol2 to version 3.3.0 - this adds support for Lua 5.4 and fixes a number of issues, including not correctly handling errors when Lua is built as C++. Updated LuaFileSystem to version 1.8.0 - this adds support for symbolic links on Windows, as well as Lua 5.4 compatibility. Updated LuaSQLite3 to version 0.9.5 - this fixes issues in multi-threaded environments, as well as Lua 5.4 compatibility. Fixed double-free after attempting to construct a debugger expression from Lua with an invalid string, and exposed expression error to Lua in a better way. Added warning level print function to Lua. Fixed saving cheats with shift operators in expressions, although this code isn't actually used as there's no cheat editor.
Bump, I can reproduce this and can confirm that the proposed fix solves the issue. It seems to be just a typo to compare against 0 instead of the proper |
See ThePhD/sol2#1461. Closes longturn#1895.
Lua may define the macros but leaves them empty. The code assumed they would contain a boolean value. This is required to use sol2 with system Lua on Fedora 37. Closes ThePhD#1461.
See ThePhD/sol2#1461. Closes #1895.
See ThePhD/sol2#1461. Closes #1895. (cherry picked from commit 974262c)
This is not a typo, it's intentional. There should be a value in there, and it should be an integer -- any integer at all, indicating if it's on or off. |
That’s not correct though. If you look at the Lua source, it does not check for “a value in there”, it simply checks whether the macro is defined or not. You’re assuming Lua uses the same semantics for its feature macros that you use for yours. This assumption is incorrect. |
7f4e7f9b8 fix for sol2 compilation issue ThePhD/sol2#1461 git-subtree-dir: cmake git-subtree-split: 7f4e7f9b85076bac8823d7cab35153ff2e5de689
The issue is an apparent misinterpretation of how Lua compatibility macros are defined.
Consider this fragment from Lua’s src/luaconf.h (starts at line 303 in Lua 5.3.4):
Note that if Lua 5.2 compatibility is enabled,
LUA_COMPAT_BITLIB
will be defined as an empty macro.Now consider this code in sol2’s include/sol/compatibility/lua_version.hpp (beginning at line 186 in sol2 v3.3.0):
https://github.com/ThePhD/sol2/blob/v3.3.0/include/sol/compatibility/lua_version.hpp#L186
On line 195, this fragment causes a compilation error with clang and GCC:
(defined(LUA_COMPAT_BITLIB) && (LUA_COMPAT_BITLIB != 0))
Because
LUA_COMPAT_BITLIB
is defined as an empty macro, it’s substituted as(1 && ( != 0))
so the compilers produce an error because there’s no left-hand argument to the not-equal operator (!=
).The
LUA_COMPAT_*
macros should only be tested for being defined or undefined. The Lua headers define them as empty macros when enabled, so attempting to compare them to 1/0 causes compilation errors.I can open a PR to change line 195 to this if it would be considered a good solution:
#if (SOL_LUA_VERSION_I_ == 502) || defined(LUA_COMPAT_BITLIB) || (SOL_LUA_VERSION_I_ < 504 && defined(LUA_COMPAT_5_2))
The text was updated successfully, but these errors were encountered: