forked from LuaJIT/LuaJIT
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix C file generation in jit.bcsave.
Thanks to codicodi. (cherry picked from commit 62903ba) --- l1.txt 2023-10-18 19:21:23.939547944 +0300 +++ l2.txt 2023-10-18 19:21:28.891489600 +0300 @@ -8,12 +8,11 @@ ... -0000000000002000 R luaJIT_BC_lj_lib_xxx ...
- Loading branch information
Showing
5 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
local tap = require('tap') | ||
local test = tap.test('lj-jit-bcsave-c-generation') | ||
|
||
test:plan(1) | ||
|
||
local module_name = 'lj_lib_xxx' | ||
local ok, _ = pcall(require, module_name) | ||
local symbol_name = ('luaJIT_BC_%s'):format(module_name) | ||
local message = ('symbol "%s" is available in a library'):format(module_name) | ||
|
||
test:ok(ok == true, message) | ||
|
||
test:done(true) |
46 changes: 46 additions & 0 deletions
46
test/tarantool-tests/lj-jit-bcsave-c-generation/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
set(LIB_NAME "lj_lib_xxx") | ||
set(LUA_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.lua) | ||
set(C_FILE ${LIB_NAME}.c) | ||
set(CXX_FILE ${LIB_NAME}.cc) | ||
|
||
make_lua_path(LUA_PATH | ||
PATHS | ||
${PROJECT_SOURCE_DIR}/src/?.lua | ||
${PROJECT_SOURCE_DIR}/src/jit/?.lua | ||
) | ||
|
||
add_custom_target(export_bc | ||
COMMAND ${CMAKE_COMMAND} -E env LUA_PATH=${LUA_PATH} ${LUAJIT_BINARY} -b ${LUA_FILE} ${C_FILE} | ||
# Enforce CMake to using CXX compiler. | ||
# COMMAND ${CMAKE_COMMAND} -E rename ${C_FILE} ${CXX_FILE} | ||
DEPENDS luajit-main ${LUA_FILE} | ||
# BYPRODUCTS ${CXX_FILE} | ||
BYPRODUCTS ${C_FILE} | ||
COMMENT "Exporting bytecode to a C file" | ||
VERBATIM | ||
) | ||
|
||
# add_custom_command( | ||
# OUTPUT ${CXX_FILE} | ||
# COMMAND ${CMAKE_COMMAND} -E env LUA_PATH=${LUA_PATH} ${LUAJIT_BINARY} -b ${LUA_FILE} ${C_FILE} | ||
# # Enforce CMake to using CXX compiler. | ||
# COMMAND ${CMAKE_COMMAND} -E rename ${C_FILE} ${CXX_FILE} | ||
# DEPENDS luajit-main ${LUA_FILE} | ||
# BYPRODUCTS ${CXX_FILE} | ||
# COMMENT "Exporting bytecode to a C file" | ||
# VERBATIM | ||
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
# ) | ||
|
||
# add_library(${LIB_NAME} SHARED OBJECT EXCLUDE_FROM_ALL ${CXX_FILE}) | ||
# add_dependencies(${LIB_NAME} export_bc) | ||
# # set_target_properties("xxx" PROPERTIES LINKER_LANGUAGE CXX) | ||
# set_target_properties(${LIB_NAME} PROPERTIES | ||
# LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" | ||
# PREFIX "" | ||
# ) | ||
# list(APPEND TESTLIBS ${LIB_NAME}) | ||
|
||
# BuildTestCLib(${LIB_NAME} ${CXX_FILE}) | ||
BuildTestCLib(${LIB_NAME} ${C_FILE}) | ||
add_dependencies(${LIB_NAME} export_bc) |
7 changes: 7 additions & 0 deletions
7
test/tarantool-tests/lj-jit-bcsave-c-generation/lj_lib_xxx.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
local a = 1 | ||
local b = 2 | ||
|
||
return { | ||
a = a, | ||
b = b, | ||
} |