[Tarantool-patches] [PATCH luajit] Fix C file generation in jit.bcsave.
Sergey Bronnikov
sergeyb at tarantool.org
Wed Nov 8 00:19:36 MSK 2023
Hello, Sergey
On 10/31/23 16:21, Sergey Kaplun wrote:
<snipped>
>> --- a/test/tarantool-tests/lj-551-bytecode-c-broken-macro/CMakeLists.txt
>> +++ b/test/tarantool-tests/lj-551-bytecode-c-broken-macro/CMakeLists.txt
>> @@ -1,5 +1,6 @@
>> set(LIB_NAME "bcsaved_clib") -set(LUA_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.lua)
>> +set(LUA_FILE_ORIG ${CMAKE_CURRENT_SOURCE_DIR}/bcsaved.lua)
>> +set(LUA_FILE ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}.lua)
>> set(C_FILE ${LIB_NAME}.c) make_lua_path(LUA_PATH @@ -8,11 +9,24 @@
>> make_lua_path(LUA_PATH ${PROJECT_SOURCE_DIR}/src/jit/?.lua )
>> +add_custom_target(copy_lua + COMMAND ${CMAKE_COMMAND} -E + copy
>> + ${LUA_FILE_ORIG} + ${LUA_FILE} + DEPENDS
>> ${LUA_FILE_ORIG} + BYPRODUCTS ${LUA_FILE} + COMMENT "Copying Lua module"
>> + VERBATIM
>> +)
>> +
>> add_custom_target(export_bc
>> COMMAND ${CMAKE_COMMAND} -E
>> env
>> LUA_PATH=${LUA_PATH}
>> ${LUAJIT_BINARY} -b ${LUA_FILE} ${C_FILE}
>> + COMMAND ${CMAKE_COMMAND} -E
>> + remove ${LUA_FILE}
>> DEPENDS luajit-main ${LUA_FILE}
>> BYPRODUCTS ${C_FILE}
>> COMMENT "Exporting bytecode to a C file"
> The test still doesn't fail before the commit.
> The reason is that the C file is compiled by C compiler, not the C++
> compiler (so this macro is irrelevant).
Fixed, thanks.
>
> I suppose that we should add a .cpp file for the test too (and add the
> LINKER_LANGUAGE CXX [1] property for this target if its necessary).
Unfortunately, setting property with LINKER_LANGUAGE is not enough.
Additionally one need setting CXX language for a project or enable CXX
in required CMakeLists.txt
and it is better to have .cc extension for a file too. Otherwise CMake
fails to build a file by CXX compiler.
I believe you will not against to backporting
e826d0c101d750fac8334d71e221c50d8dbe236c ("Add 'cc' file type for saving
bytecode.")
as well because commit enables saving bc to .cc file directly.
Final patch:
diff --git
a/test/tarantool-tests/lj-551-bytecode-c-broken-macro/CMakeLists.txt
b/test/tarantool-tests/lj-551-bytecode-c-broken-macro/CMakeLists.txt
index 45857386..1baf6ec8 100644
--- a/test/tarantool-tests/lj-551-bytecode-c-broken-macro/CMakeLists.txt
+++ b/test/tarantool-tests/lj-551-bytecode-c-broken-macro/CMakeLists.txt
@@ -1,7 +1,9 @@
+enable_language(CXX)
+
set(LIB_NAME "bcsaved_clib")
set(LUA_FILE_ORIG ${CMAKE_CURRENT_SOURCE_DIR}/bcsaved.lua)
set(LUA_FILE ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}.lua)
-set(C_FILE ${LIB_NAME}.c)
+set(CXX_FILE ${LIB_NAME}.cc)
make_lua_path(LUA_PATH
PATHS
@@ -24,14 +26,14 @@ add_custom_target(export_bc
COMMAND ${CMAKE_COMMAND} -E
env
LUA_PATH=${LUA_PATH}
- ${LUAJIT_BINARY} -b ${LUA_FILE} ${C_FILE}
+ ${LUAJIT_BINARY} -b ${LUA_FILE} ${CXX_FILE}
COMMAND ${CMAKE_COMMAND} -E
remove ${LUA_FILE}
DEPENDS luajit-main ${LUA_FILE}
- BYPRODUCTS ${C_FILE}
+ BYPRODUCTS ${CXX_FILE}
- COMMENT "Exporting bytecode to a C file"
+ COMMENT "Exporting bytecode to a CXX file"
VERBATIM
)
-BuildTestCLib(${LIB_NAME} ${C_FILE})
+BuildTestCLib(${LIB_NAME} ${CXX_FILE})
add_dependencies(${LIB_NAME} export_bc)
>
> [1]:https://cmake.org/cmake/help/latest/prop_tgt/LINKER_LANGUAGE.html#linker-language
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20231108/c4e33f7a/attachment.htm>
More information about the Tarantool-patches
mailing list