From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 27C855B75C7; Wed, 8 Nov 2023 00:19:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 27C855B75C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1699391979; bh=ZE9gNW7lNLnV07ZOY0I6nV2+RxZ4WGmJvLa0bchh/M4=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ms6hZWTFbbnQuC+V+q+BLxkGWQGcFm4yJ4aPIuysY/Pvd51hdY5SJQw3P9bLknHiz 1QrznobyLs/XACOKMPDGNkSNf4pikavuFTa+vr4iDyMceqGuO2PlY8EXJj1cLThfvP xYXyOrVq9VCmHalLUrm0HN/jA+LQdJD9hHDAMjwI= Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [95.163.41.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 1A6AB5B75C7 for ; Wed, 8 Nov 2023 00:19:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1A6AB5B75C7 Received: by smtp60.i.mail.ru with esmtpa (envelope-from ) id 1r0TU0-004axT-2T; Wed, 08 Nov 2023 00:19:37 +0300 Content-Type: multipart/alternative; boundary="------------XAtMRFzrWnBqmT523Ksp9miC" Message-ID: Date: Wed, 8 Nov 2023 00:19:36 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Kaplun Cc: Sergey Bronnikov , tarantool-patches@dev.tarantool.org, max.kokryashkin@gmail.com References: Content-Language: en-US In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD99FFD3FA9E0A670D887F1D9EE15A21FD697EC2FBA9506A2A000894C459B0CD1B9AC065057DE1C2FD289EE53A0918DA82FDED29B4EB5339865D0E8197CAB852897 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7EC5C31BCB549C52BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377A2EA98384B91C6C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D82A2908D9647ECEF0521494F5D59F9D45117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA1C5B227563B4AFA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520B28585415E75ADA9CB629EEF1311BF91D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE140C956E756FBB7A2D242C3BD2E3F4C64AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3E0C144949FACE77E76E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C22495FF0BFC5AEE34BE6E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6C44E7F8E725E999E089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A564E36391E5EE554D4F5EA8678227F925E5E8BF0B34EF2CF6F87CCE6106E1FC07E67D4AC08A07B9B0251EFD5447B32ED6CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFF380FCDEC9059FECEC90901B2DB21F24D0F6FB1572C847A52FE72895BA658639B23470503F0B8DDF2B33B16BC67043E0BFC7A1330915AC3B047A5CBCFCC4269EA74DFFEFA5DC0E7F02C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojoiosMWyUVRdpYO+3L/moZw== X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F2588458BA1E1100741DEECE18EB00F2EE09652C85AB3DD385E8E483282EC151BADDC1D3523A6D01B4765B2DFB59E2DDD9FE06B14FA522850F29BC30B0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Fix C file generation in jit.bcsave. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------XAtMRFzrWnBqmT523Ksp9miC Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello, Sergey On 10/31/23 16:21, Sergey Kaplun wrote: >> --- 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 > --------------XAtMRFzrWnBqmT523Ksp9miC Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

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

--------------XAtMRFzrWnBqmT523Ksp9miC--