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

Compatible Layer Compiler Errors While Using MoonJIT #967

Closed
atom0s opened this issue May 13, 2020 · 7 comments
Closed

Compatible Layer Compiler Errors While Using MoonJIT #967

atom0s opened this issue May 13, 2020 · 7 comments
Assignees
Labels
Bug.External Can't Fix Shit outta luck, fam. Bug.Well Shit Here we go again...
Milestone

Comments

@atom0s
Copy link
Contributor

atom0s commented May 13, 2020

Didn't want to make a pull request to fix this without first seeing if there is something I am missing config wise that would avoid this. I am new to sol3, and still getting used to how it is setup.

Environment setup:

The Lua 5.3 compat header has two errors in it while making use of MoonJIT which can be easily fixed. However, I am not sure if this is the appropriate fix for this, or if I am just overlooking a define.

The errors are:

compat-5.3.h(102,16): error C2371: 'lua_Unsigned': redefinition; different basic types

compat-5.3.h(157,1): warning C4005: 'lua_pushglobaltable': macro redefinition

Second is only a warning by default, but I generally compile with warnings as errors.

The first can be fixed by assuming LuaJIT is the only time this issue will be seen, as I did not have it while compiling with stock Lua. So I fixed that via:

#if !defined(LUAJIT_VERSION)
typedef size_t lua_Unsigned;
#endif

The second is fixed by just checking for existing definitions like the other functions near it:

#ifndef lua_pushglobaltable
#define lua_pushglobaltable(L) \
  lua_pushvalue((L), LUA_GLOBALSINDEX)
#endif

Edit; sorry forgot to include a small snippet:

// MoonJIT lib
#pragma comment(lib, "lua51.lib")

// General includes..
#include <sol/sol.hpp>
#include <Windows.h>
#include <string>
#include <vector>

int32_t __cdecl main(int32_t argc, char* argv[])
{
    sol::state lua;
    lua.open_libraries();
}

This is enough to produce these errors. Include paths point to sol and moonjit accordingly.

@ThePhD
Copy link
Owner

ThePhD commented May 13, 2020

Is there a MoonJIT-specific macro I can use for the first case? The second I can happily fix up.

@atom0s
Copy link
Contributor Author

atom0s commented May 13, 2020

I don't believe so, they just forked LuaJIT with a new name and continued some development. The actual Lua header and usage remains the same/unchanged, and the Lua versioning variables/macros are left as LUAJIT_ prefixed.

#define LUAJIT_VERSION		"moonjit 2.2.0"
#define LUAJIT_VERSION_NUM	20200  /* Version 2.2.0 = 02.02.00. */
#define LUAJIT_VERSION_SYM	moonjit_version_2_2_0
#define LUAJIT_COPYRIGHT	"Copyright (C) 2019-2020 moonjit developers"
#define LUAJIT_URL		"https://github.com/moonjit/moonjit"

You could base it on the values, but that may be a bit more annoying to maintain.

@ThePhD
Copy link
Owner

ThePhD commented May 14, 2020

I've left an issue in the MoonJIT repository. If I don't get a simple answer then the hackery begins.

@ThePhD ThePhD self-assigned this May 14, 2020
@ThePhD ThePhD added Bug.External Can't Fix Shit outta luck, fam. Bug.Well Shit Here we go again... labels May 14, 2020
@ThePhD ThePhD added this to the Bugs milestone May 14, 2020
@ThePhD
Copy link
Owner

ThePhD commented May 14, 2020

Spicy: moonjit/moonjit@d7784a3

We can now just check for MOONJIT_VERSION. If you're okay with that, I'll use that to check for MoonJIT.

@atom0s
Copy link
Contributor Author

atom0s commented May 14, 2020

Ultimately up to you, but LuaJIT stock will probably have the same issues.

I am looking into other libraries than sol at this point though as sol does not seem to deal with coroutines well from the C side.

@ThePhD
Copy link
Owner

ThePhD commented May 14, 2020

Fair enough! Good luck.

@ThePhD
Copy link
Owner

ThePhD commented May 18, 2020

This is taken care of.

@ThePhD ThePhD closed this as completed May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug.External Can't Fix Shit outta luck, fam. Bug.Well Shit Here we go again...
Projects
None yet
Development

No branches or pull requests

2 participants