Skip to content
Snippets Groups Projects
Commit c9d88d5f authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

Fix #984: add jit.* library to the binary

parent 9481a731
No related branches found
No related tags found
No related merge requests found
...@@ -178,7 +178,7 @@ macro(luajit_build) ...@@ -178,7 +178,7 @@ macro(luajit_build)
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/third_party/luajit/src/libluajit.a add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/third_party/luajit/src/libluajit.a
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/third_party/luajit WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/third_party/luajit
COMMAND $(MAKE) ${luajit_buildoptions} clean COMMAND $(MAKE) ${luajit_buildoptions} clean
COMMAND $(MAKE) -C src ${luajit_buildoptions} libluajit.a COMMAND $(MAKE) -C src ${luajit_buildoptions}
DEPENDS ${CMAKE_SOURCE_DIR}/CMakeCache.txt DEPENDS ${CMAKE_SOURCE_DIR}/CMakeCache.txt
) )
else() else()
...@@ -189,7 +189,7 @@ macro(luajit_build) ...@@ -189,7 +189,7 @@ macro(luajit_build)
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/third_party/luajit WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/third_party/luajit
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/third_party/luajit ${PROJECT_BINARY_DIR}/third_party/luajit COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/third_party/luajit ${PROJECT_BINARY_DIR}/third_party/luajit
COMMAND $(MAKE) ${luajit_buildoptions} clean COMMAND $(MAKE) ${luajit_buildoptions} clean
COMMAND $(MAKE) -C src ${luajit_buildoptions} libluajit.a COMMAND $(MAKE) -C src ${luajit_buildoptions}
DEPENDS ${PROJECT_BINARY_DIR}/CMakeCache.txt ${PROJECT_BINARY_DIR}/third_party/luajit DEPENDS ${PROJECT_BINARY_DIR}/CMakeCache.txt ${PROJECT_BINARY_DIR}/third_party/luajit
) )
endif() endif()
......
...@@ -56,7 +56,7 @@ function(lua_source varname filename) ...@@ -56,7 +56,7 @@ function(lua_source varname filename)
COMMAND ${ECHO} '\;' >> ${tmpfile} COMMAND ${ECHO} '\;' >> ${tmpfile}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmpfile} ${dstfile} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmpfile} ${dstfile}
COMMAND ${CMAKE_COMMAND} -E remove ${tmpfile} COMMAND ${CMAKE_COMMAND} -E remove ${tmpfile}
DEPENDS ${srcfile} txt2c) DEPENDS ${srcfile} txt2c libluajit)
set(var ${${varname}}) set(var ${${varname}})
set(${varname} ${var} ${dstfile} PARENT_SCOPE) set(${varname} ${var} ${dstfile} PARENT_SCOPE)
......
...@@ -31,6 +31,19 @@ lua_source(lua_sources lua/tap.lua) ...@@ -31,6 +31,19 @@ lua_source(lua_sources lua/tap.lua)
lua_source(lua_sources lua/fio.lua) lua_source(lua_sources lua/fio.lua)
lua_source(lua_sources lua/strict.lua) lua_source(lua_sources lua/strict.lua)
lua_source(lua_sources ../third_party/luafun/fun.lua) lua_source(lua_sources ../third_party/luafun/fun.lua)
# LuaJIT jit.* library
lua_source(lua_sources ../third_party/luajit/src/jit/bc.lua)
lua_source(lua_sources ../third_party/luajit/src/jit/bcsave.lua)
lua_source(lua_sources ../third_party/luajit/src/jit/dis_x86.lua)
lua_source(lua_sources ../third_party/luajit/src/jit/dis_x64.lua)
lua_source(lua_sources ../third_party/luajit/src/jit/dump.lua)
lua_source(lua_sources ../third_party/luajit/src/jit/vmdef.lua)
lua_source(lua_sources ../third_party/luajit/src/jit/v.lua)
if (EXISTS ../third_party/luajit/src/jit/p.lua)
# Profiler LuaJIT 2.1+
lua_source(lua_sources ../third_party/luajit/src/jit/p.lua)
lua_source(lua_sources ../third_party/luajit/src/jit/zone.lua)
endif()
add_custom_target(generate_lua_sources add_custom_target(generate_lua_sources
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/box WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/box
......
...@@ -88,7 +88,18 @@ extern char strict_lua[], ...@@ -88,7 +88,18 @@ extern char strict_lua[],
help_lua[], help_lua[],
help_en_US_lua[], help_en_US_lua[],
tap_lua[], tap_lua[],
fio_lua[]; fio_lua[],
/* jit.* library */
vmdef_lua[],
bc_lua[],
bcsave_lua[],
dis_x86_lua[],
dis_x64_lua[],
dump_lua[],
v_lua[];
#if LUAJIT_VERSION_NUM >= 20100 /* LuaJIT 2.1+ */
extern char p_lua[], zone_lua[];
#endif /* LuaJIT 2.1+ */
static const char *lua_modules[] = { static const char *lua_modules[] = {
/* Make it first to affect load of all other modules */ /* Make it first to affect load of all other modules */
...@@ -109,6 +120,19 @@ static const char *lua_modules[] = { ...@@ -109,6 +120,19 @@ static const char *lua_modules[] = {
"tap", tap_lua, "tap", tap_lua,
"help.en_US", help_en_US_lua, "help.en_US", help_en_US_lua,
"help", help_lua, "help", help_lua,
/* jit.* library */
"jit.vmdef", vmdef_lua,
"jit.bc", bc_lua,
"jit.bcsave", bcsave_lua,
"jit.dis_x86", dis_x86_lua,
"jit.dis_x64", dis_x64_lua,
"jit.dump", dump_lua,
"jit.v", v_lua,
#if LUAJIT_VERSION_NUM >= 20100 /* LuaJIT 2.1+ */
/* Profiler */
"jit.p", p_lua,
"jit.zone", zone_lua,
#endif /* LuaJIT 2.1+ */
NULL NULL
}; };
...@@ -366,8 +390,13 @@ tarantool_lua_init(const char *tarantool_bin, int argc, char **argv) ...@@ -366,8 +390,13 @@ tarantool_lua_init(const char *tarantool_bin, int argc, char **argv)
if (luaL_loadbuffer(L, modsrc, strlen(modsrc), modfile)) if (luaL_loadbuffer(L, modsrc, strlen(modsrc), modfile))
panic("Error loading Lua module %s...: %s", panic("Error loading Lua module %s...: %s",
modname, lua_tostring(L, -1)); modname, lua_tostring(L, -1));
lua_call(L, 0, 1); lua_pushstring(L, modname);
lua_setfield(L, -3, modname); /* package.loaded.modname = t */ lua_call(L, 1, 1);
if (!lua_isnil(L, -1)) {
lua_setfield(L, -3, modname); /* package.loaded.modname = t */
} else {
lua_pop(L, 1); /* nil */
}
lua_pop(L, 1); /* chunkname */ lua_pop(L, 1); /* chunkname */
} }
lua_pop(L, 1); /* _LOADED */ lua_pop(L, 1); /* _LOADED */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment