From b5d171212331b279e6c5b00aff698d7046d933ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Mon, 9 Aug 2021 07:17:16 +0200 Subject: [PATCH] Define lua_pushglobaltable only if it's not already defined This fixes compatibility with moonjit, a luajit replacement that lies about which API level it implements. Also link more stuff statically on linux. --- meson.build | 4 ++++ src/lua/LuaCompat.c | 2 ++ src/lua/LuaCompat.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/meson.build b/meson.build index af89919e6..a94f04310 100644 --- a/meson.build +++ b/meson.build @@ -234,6 +234,10 @@ if copt_platform == 'win' configure_file(input: input_and_output[0], output: input_and_output[1], copy: true) endforeach endif +elif copt_platform == 'lin' + if uopt_static != 'none' + project_link_args = [ '-static-libgcc', '-static-libstdc++' ] + endif endif if copt_platform == 'mac' and uopt_lua == 'luajit' diff --git a/src/lua/LuaCompat.c b/src/lua/LuaCompat.c index 96a56fef7..cabf38806 100644 --- a/src/lua/LuaCompat.c +++ b/src/lua/LuaCompat.c @@ -19,11 +19,13 @@ void tpt_lua_getmainthread(lua_State *L) #else +# ifndef lua_pushglobaltable // * Thank you moonjit // Implement function added in lua 5.2 that we now use void lua_pushglobaltable(lua_State *L) { lua_pushvalue(L, LUA_GLOBALSINDEX); } +# endif void tpt_lua_setmainthread(lua_State *L) { diff --git a/src/lua/LuaCompat.h b/src/lua/LuaCompat.h index 8ff3ccf69..1ca761ca8 100644 --- a/src/lua/LuaCompat.h +++ b/src/lua/LuaCompat.h @@ -17,7 +17,9 @@ LUALIB_API void tpt_lua_getmainthread(lua_State *L); #if LUA_VERSION_NUM >= 502 LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); #else +# ifndef lua_pushglobaltable // * Thank you moonjit LUALIB_API void (lua_pushglobaltable) (lua_State *L); +# endif #endif int luaL_tostring(lua_State *L, int n);