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 2F8CA6C7D3; Fri, 5 Feb 2021 01:54:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2F8CA6C7D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612479264; bh=RElWCvtYUz5iPdNzS3rSOoh2vRdSxYdIN9PU4BymP/s=; h=To:Cc:References:In-Reply-To:Date:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=GrpdRFtxf+Y36pTfXtl7X7MgwnulCjxlaNzA/q3CJAuKnUxVxWuR5In6g75mBIXrq 9ba0aHbch/MXQ9XcY+soqPBwi0poIdrg05KLZWR5PcQDWc4rZNT1jr7tcEUGmXMfTv aMuFhaNQMH8QNA5f1C4ipZyI10ooerQKap8/J4ck= Received: from smtp53.i.mail.ru (smtp53.i.mail.ru [94.100.177.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4D815686CB for ; Fri, 5 Feb 2021 01:54:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4D815686CB Received: by smtp53.i.mail.ru with esmtpa (envelope-from ) id 1l7nVf-0005pS-Lo; Fri, 05 Feb 2021 01:54:00 +0300 To: "'Igor Munkin'" , "'Sergey Kaplun'" Cc: References: <7cd42be38d86c832ecd4ba0f3edd7ae83aead7ad.1612291495.git.imun@tarantool.org> In-Reply-To: <7cd42be38d86c832ecd4ba0f3edd7ae83aead7ad.1612291495.git.imun@tarantool.org> Date: Fri, 5 Feb 2021 01:53:53 +0300 Message-ID: <11be01d6fb48$9d0e1050$d72a30f0$@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQJPfenCWrjRxS0krGRZARdqgOlJ3gKwr8KjqUH5+8A= Content-Language: ru X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD953AC099BC0052A9CC9F923E808BA4A11AAD7C69F0036037C182A05F538085040A1CCC4161EB908A91B79D4F5AD2649DB612AD5C7D3AF5EB811FD756A4D28BB0C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE75210414551E8CD62EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637A431CDDF496E6E598638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC0302E880A7698C906BF3551F651DA6F2AA950BED828872FC389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C078FCF50C7EAF9C588941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6E232F00D8D26902CA471835C12D1D977C4224003CC836476EB9C4185024447017B076A6E789B0E975F5C1EE8F4F765FC6239B7BD0418277D3AA81AA40904B5D9CF19DD082D7633A078D18283394535A93AA81AA40904B5D98AA50765F79006379A1BF4F7E3B00F62D81D268191BDAD3D698AB9A7B718F8C442539A7722CA490C13377AFFFEAFD26923F8577A6DFFEA7CDC7F9DB2523BC7CD4AD6D5ED66289B524E70A05D1297E1BB35872C767BF85DA227C277FBC8AE2E8B8E48D8FAA4D20A9F75ECD9A6C639B01B4E70A05D1297E1BBC6867C52282FAC85D9B7C4F32B44FF57D4B828FA1BC0F1ACBD9CCCA9EDD067B1EDA766A37F9254B7 X-B7AD71C0: 6FEFE4C63DFE2D85469AD6E133326EAB664F5199923B286E81C2AD9CFA0FBF5C9C2BBA594F31363B155B1761B7403232F73F1311AF95AC6E06DFED9C0DFF453C1DEC476C306F9A18E3A50EC8D60E8AF88E1CD14B953EB46DB4C6C20EE3CA1E5E355D89D7DBCDD132 X-C1DE0DAB: 0D63561A33F958A5146CD0D17FD1C7A060A7934F9698BA2362C99697629E26DFD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34B3611847B8BC2D0BEF43496802EBFA9F217EE3F7A3ECE4C277238D7515A909B9A9D4FEEA73F73D211D7E09C32AA3244C1B601FE4F8CF6CA3CCBD29B6F57E39D3C3B3ADDA61883BB5FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj9Cv0SAP7uQVO0B+0yeMfgQ== X-Mailru-Sender: 6CA451E36783D721CBEA96CEA26D325DD583EFBDFC714CE2E0E6176F84E8729AB7CBEF92542CD7C82F97C478340294DCC77752E0C033A69E0F0C7111264B8915FF1320A92A5534336C18EFA0BB12DBB0 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/5] build: replace GNU Make with CMake 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: Timur Safin via Tarantool-patches Reply-To: Timur Safin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Few preliminary observations below... : From: Igor Munkin : Subject: [PATCH luajit 2/5] build: replace GNU Make with CMake :=20 ... :=20 : diff --git a/.gitignore b/.gitignore : index 1a07bf7..a21ee1c 100644 : --- a/.gitignore : +++ b/.gitignore : @@ -1,5 +1,5 @@ : *.[oa] : -*.so : +*.so* : *.obj : *.lib : *.exp : @@ -9,3 +9,13 @@ : *.dmp : *.swp : .tags : + : +# CMake generated artefacts : +CMakeCache.txt : +CMakeFiles : +Makefile : +cmake_install.cmake : +compile_commands.json : +install_manifest.txt : +luajit-parse-memprof : +luajit.pc Uh-oh, this ugly hack would be handled by single exclusion build*/ if we would all use the same (idiomatic) approach for out-of-source build. But we do not yet accustomed to that, so... never mind! : diff --git a/CMakeLists.txt b/CMakeLists.txt : new file mode 100644 : index 0000000..0dba5d8 : --- /dev/null : +++ b/CMakeLists.txt : @@ -0,0 +1,261 @@ : +# LuaJIT -- interpreter and JIT compiler for Lua language. : +# This is the main entry point for building, testing and : +# packaging the project. : +# Major portions taken verbatim or adapted from the uJIT. : +# Copyright (C) 2015-2019 IPONWEB Ltd. 2019, IPONWEB? ... : +# --- Fine-tuning cmake environment = --------------------------------------- : ----- : + : +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") : +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) Could you please remove this enforcement of = CMAKE_EXPORT_COMPILE_COMMANDS here? Agreed that this is always a good idea to generate = compile_commands.json. But=20 disagreed that we should enforce it automatically. This is developer = choice to=20 either generate or not this compile database. (And it's slowing down a = bit cmake generation phase on big projects. Which is not yet case here, but in any = case) ... : + : +# Features from Lua 5.2 that are unlikely to break existing code : +# are enabled by default. Some other features that *might* break : +# some existing code (e.g. __pairs or os.execute() return values) : +# can be enabled here. : +# XXX: this does not provide full compatibility with Lua 5.2 at : +# this time. : +option(LUAJIT_LUA52COMPAT "Compatibility with Lua 5.2" OFF) : +if(LUAJIT_LUA52COMPAT) : + AppendFlags(TARGET_C_FLAGS -DLUAJIT_ENABLE_LUA52COMPAT) : +endif() I do not know whether we do care that much about consistency of an = option names or not care? But worth to mention that all other options do have = ENABLE/DISABLE or HAS prefix in similar contexts, but here we do not use it that way, = and it's simple LUAJIT_LUA52COMPAT. What about LUAJIT_ENABLE_LUA52COMPAT as it's=20 passed to compile options? (Not insist, but worth to note) : + : +# Disable the JIT compiler, i.e. turn LuaJIT into a pure : +# interpreter. : +option(LUAJIT_DISABLE_JIT "JIT support" OFF) : +if(LUAJIT_DISABLE_JIT) : + AppendFlags(TARGET_C_FLAGS -DLUAJIT_DISABLE_JIT) : +endif() : +set(LUAJIT_HAS_JIT NOT LUAJIT_DISABLE_JIT) : + ... : +# Enable GC64 mode for x64. : +option(LUAJIT_ENABLE_GC64 "GC64 mode for x64" OFF) : +if(LUAJIT_ENABLE_GC64) : + AppendFlags(TARGET_C_FLAGS -DLUAJIT_ENABLE_GC64) : +endif() : + : +# Disable memory profiler. : +option(LUAJIT_DISABLE_MEMPROF "LuaJIT memory profiler support" OFF) : +if(LUAJIT_DISABLE_MEMPROF) : + AppendFlags(TARGET_C_FLAGS -DLUAJIT_DISABLE_MEMPROF) : +endif() : + : +# Switch to harder (and slower) hash function when a collision : +# chain in the string hash table exceeds certain length. : +option(LUAJIT_SMART_STRINGS "Harder string hashing function" ON) : +if(LUAJIT_SMART_STRINGS) : + AppendFlags(TARGET_C_FLAGS -DLUAJIT_SMART_STRINGS=3D1) : +endif() The same note about lack of ENABLE prefix in the option name. : + : +# Turn on assertions for the whole LuaJIT VM. This significantly : +# slows down everything. Use only if you suspect a problem with : +# LuaJIT itself. : +option(LUAJIT_USE_ASSERT "Assertions for the whole LuaJIT VM" OFF) : +if(LUAJIT_USE_ASSERT) : + AppendFlags(TARGET_C_FLAGS -DLUA_USE_ASSERT) : +endif() : + : --- /dev/null : +++ b/cmake/LuaJITUtils.cmake : @@ -0,0 +1,31 @@ ... : diff --git a/cmake/MakeSourceList.cmake b/cmake/MakeSourceList.cmake : new file mode 100644 : index 0000000..fa455bb : --- /dev/null : +++ b/cmake/MakeSourceList.cmake : @@ -0,0 +1,47 @@ : +# Major portions taken verbatim or adapted from the uJIT. : +# Copyright (C) 2015-2019 IPONWEB Ltd. : +# : +# make_source_list provides a convenient way to define a list of = sources : +# and get a list of absolute paths. : +# : +# Example usage: : +# : +# make_source_list(SOURCES_CORE : +# SOURCES : +# main.c : +# test.c : +# subdir/test2.c : +# ) : +# : +# This will give you the list: : +# "<...>/main.c;<...>/test.c;<...>/subdir/test2.c" : +# (where `<...>` is ${CMAKE_CURRENT_SOURCE_DIR}). : +# : +# Absolute paths in `SOURCES` list don't get = ${CMAKE_CURRENT_SOURCE_DIR} : +# prepended to them. : + Very convenient macro below! Much respect to author! : +function(make_source_list list) : + set(prefix ARG) : + set(noValues) : + set(singleValues) : + set(multiValues SOURCES) : + : + include(CMakeParseArguments) # if we update to CMake >=3D 3.5, can = remove : this line : + cmake_parse_arguments(${prefix} : + "${noValues}" : + "${singleValues}" : + "${multiValues}" : + ${ARGN}) : + : + set(result_list "") : + : + foreach(fn ${ARG_SOURCES}) : + if (IS_ABSOLUTE ${fn}) : + list(APPEND result_list "${fn}") : + else() : + list(APPEND result_list "${CMAKE_CURRENT_SOURCE_DIR}/${fn}") : + endif() : + endforeach() : + : + set(${list} "${result_list}" PARENT_SCOPE) : +endfunction() ... : diff --git a/cmake/SetTargetFlags.cmake b/cmake/SetTargetFlags.cmake : new file mode 100644 : index 0000000..260fc6b : --- /dev/null : +++ b/cmake/SetTargetFlags.cmake : @@ -0,0 +1,42 @@ ... : + : +LuaJITTestArch(TESTARCH "${TARGET_C_FLAGS}") : +LuaJITArch(LUAJIT_ARCH "${TESTARCH}") : + : +# Target-specific compiler options. : +# : +# x86/x64 only: For GCC 4.2 or higher and if you don't intend to : +# distribute the binaries to a different machine you could also : +# use: -march=3Dnative. : +if(LUAJIT_ARCH STREQUAL "x86") : + AppendFlags(TARGET_C_FLAGS -march=3Di686 -msse -msse2 = -mfpmath=3Dsse) : +endif() FWIW -msse2 implicitly assumes -msse but if that way it used to be in makefiles than so be it. Don't need to "improve" it. ... : diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt : new file mode 100644 : index 0000000..8ada1a4 : --- /dev/null : +++ b/src/CMakeLists.txt : @@ -0,0 +1,391 @@ : +# Building LuaJIT core: bootstrapping, VM, runtime, JIT compiler. : +# Major portions taken verbatim or adapted from the uJIT. : +# Copyright (C) 2015-2019 IPONWEB Ltd. 2019 IPONWEB? : + : +cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) : + ... : + : +include(SetTargetFlags) : +list(APPEND TARGET_LIBS m) ${TARGET_LIBS} below used as space separated list of words, it's = probably bad idea to operate with it as list, because we end up in trace with = something like ./third_party/luajit/src/CMakeLists.txt(302): = target_include_directories(luajit_static PRIVATE = ./build/third_party/luajit/src ) ./third_party/luajit/src/CMakeLists.txt(305): = target_link_libraries(luajit_static libluajit_static dl;m ) ... : +# Compiling and linking CLIs. : + : +add_executable(luajit_static EXCLUDE_FROM_ALL ${CLI_SOURCES}) : +set_target_properties(luajit_static PROPERTIES : + OUTPUT_NAME "${LUAJIT_CLI_NAME}" : + COMPILE_FLAGS "${TARGET_C_FLAGS}" : + LINK_FLAGS "${TARGET_BIN_FLAGS}" : + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" : +) : +target_include_directories(luajit_static PRIVATE : + ${CMAKE_CURRENT_BINARY_DIR} : +) : +target_link_libraries(luajit_static libluajit_static ${TARGET_LIBS}) : + : +add_executable(luajit_shared EXCLUDE_FROM_ALL ${CLI_SOURCES}) : +set_target_properties(luajit_shared PROPERTIES : + OUTPUT_NAME "${LUAJIT_CLI_NAME}" : + COMPILE_FLAGS "${TARGET_C_FLAGS}" : + LINK_FLAGS "${TARGET_BIN_FLAGS}" : + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" : +) : +target_include_directories(luajit_shared PRIVATE : + ${CMAKE_CURRENT_BINARY_DIR} : +) : +target_link_libraries(luajit_shared libluajit_shared ${TARGET_LIBS}) : + : +if(NOT BUILDMODE STREQUAL "dynamic") : + set(LIBLUAJIT_STATIC_DEPS libluajit_static) : +endif() : +if(NOT BUILDMODE STREQUAL "static") : + set(LIBLUAJIT_SHARED_DEPS libluajit_shared) : +endif() : +set(LIBLUAJIT_DEPS ${LIBLUAJIT_STATIC_DEPS} ${LIBLUAJIT_SHARED_DEPS}) : + : +if(BUILDMODE STREQUAL "dynamic") : + set(LUAJIT_DEPS luajit_shared) : +else() : + set(LUAJIT_DEPS luajit_static) : +endif() : + : +add_custom_target(libluajit DEPENDS ${LIBLUAJIT_DEPS}) : +add_custom_target(luajit ALL DEPENDS libluajit ${LUAJIT_DEPS}) : + : +install(TARGETS ${LUAJIT_DEPS} : + RUNTIME : + DESTINATION bin : + COMPONENT luajit : +) Here we have reasonable cmake complain: -- Configuring done WARNING: Target "luajit_static" has EXCLUDE_FROM_ALL set and will not = be built by default but an install rule has been provided for it. CMake does not define = behavior for this case. WARNING: Target "libluajit_static" has EXCLUDE_FROM_ALL set and will = not be built by default but an install rule has been provided for it. CMake does not define = behavior for this case. There is no much point to install ${LIBLUAJIT_STATIC_DEPS} or = ${LIBLUAJIT_SHARED_DEPS} if we have=20 excluded luajit_static and/or libluajit_shared from target all = dependencies via EXCLUDE_FROM_ALL. : +install(TARGETS ${LIBLUAJIT_STATIC_DEPS} : + ARCHIVE : + DESTINATION lib : + COMPONENT luajit : +) : +install(TARGETS ${LIBLUAJIT_SHARED_DEPS} : + LIBRARY : + DESTINATION lib : + COMPONENT luajit : +) : + : diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt : new file mode 100644 : index 0000000..f9ffc5e : --- /dev/null : +++ b/tools/CMakeLists.txt : @@ -0,0 +1,77 @@ : +# Building tools for developing with uJIT. : +# Major portions taken verbatim or adapted from the uJIT. : +# Copyright (C) 2015-2019 IPONWEB Ltd. 2019 IPONWEB? : + : +# See the rationale in the root CMakeLists.txt : +cmake_minimum_required(VERSION 3.1 FATAL_ERROR) : + : +set(LUAJIT_TOOLS_DEPS) : + : +if(LUAJIT_DISABLE_MEMPROF) : + message(STATUS "LuaJIT memory profiler support is disabled") : +else() : + # XXX: Can use genex here since the value need to be evaluated : + # on the configuration phase. Fortunately, we know the exact : + # path where LuaJIT binary is located. : + set(LUAJIT_TOOLS_BIN ${LUAJIT_BINARY_DIR}/${LUAJIT_CLI_NAME}) : + set(LUAJIT_TOOLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}) : + configure_file(luajit-parse-memprof.in luajit-parse-memprof @ONLY : ESCAPE_QUOTES) : + : + add_custom_target(tools-parse-memprof EXCLUDE_FROM_ALL DEPENDS : + luajit-parse-memprof : + memprof/humanize.lua : + memprof/parse.lua : + memprof.lua : + utils/bufread.lua : + utils/symtab.lua : + ) : + list(APPEND LUAJIT_TOOLS_DEPS tools-parse-memprof) : + : + install(FILES : + ${CMAKE_CURRENT_SOURCE_DIR}/memprof/humanize.lua : + ${CMAKE_CURRENT_SOURCE_DIR}/memprof/parse.lua : + DESTINATION ${LUAJIT_DATAROOTDIR}/memprof : + PERMISSIONS : + OWNER_READ OWNER_WRITE : + GROUP_READ : + WORLD_READ : + COMPONENT tools-parse-memprof : + ) : + install(FILES : + ${CMAKE_CURRENT_SOURCE_DIR}/utils/bufread.lua : + ${CMAKE_CURRENT_SOURCE_DIR}/utils/symtab.lua : + DESTINATION ${LUAJIT_DATAROOTDIR}/utils : + PERMISSIONS : + OWNER_READ OWNER_WRITE : + GROUP_READ : + WORLD_READ : + COMPONENT tools-parse-memprof : + ) : + install(FILES : + ${CMAKE_CURRENT_SOURCE_DIR}/memprof.lua : + DESTINATION ${LUAJIT_DATAROOTDIR} : + PERMISSIONS : + OWNER_READ OWNER_WRITE : + GROUP_READ : + WORLD_READ : + COMPONENT tools-parse-memprof : + ) : + install(CODE : + # XXX: Since the auxiliary script need to be configured in : + # other way it need to be reconfigured it prior to its : + # installation. Unfortunately, we need to manually specify : + # the installation path in command. : + # Hope this script will be gone as a result of the issue below : + # https://github.com/tarantool/tarantool/issues/5688. : + " : + set(LUAJIT_TOOLS_BIN = ${CMAKE_INSTALL_PREFIX}/bin/${LUAJIT_CLI_NAME}) : + set(LUAJIT_TOOLS_DIR = ${CMAKE_INSTALL_PREFIX}/${LUAJIT_DATAROOTDIR}) : + = configure_file(${CMAKE_CURRENT_SOURCE_DIR}/luajit-parse-memprof.in : + ${CMAKE_INSTALL_PREFIX}/bin/luajit-parse-memprof @ONLY : ESCAPE_QUOTES) : + message(STATUS \"Installing: = ${CMAKE_INSTALL_PREFIX}/bin/luajit- : parse-memprof\") : + " : + COMPONENT tools-parse-memprof : + ) =D0=A8=D0=B0=D0=B9=D1=82=D0=B0=D0=BD! : +endif() : + : +add_custom_target(LuaJIT-tools DEPENDS ${LUAJIT_TOOLS_DEPS}) : -- : 2.25.0 Regards, Timur