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 31B0E686CC; Thu, 4 Feb 2021 02:23:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 31B0E686CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612394605; bh=2or/xwo3ZyN6/6lDuXUvRJrzLwwILclRz510+8/v8W0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=u1Ws9ubFxl5muJhNXRGD32Uq/6ZGOpfyYyxFVdA11E7PpCls/JrzCmijXeFTUbU0T AGA5aSppfJRgR/DWMuqEjgKl7Ahpcf4sEZmOnu0N+/p6wtdrMoU1xn613VBNHEcNTu AlumvgcxquKmI8NGajHZC+adJ/0iNqrkyluJJJLE= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 AB630686CC for ; Thu, 4 Feb 2021 02:22:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AB630686CC Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1l7RTa-0008Pr-DH; Thu, 04 Feb 2021 02:22:22 +0300 To: Sergey Kaplun , Timur Safin Date: Thu, 4 Feb 2021 02:22:16 +0300 Message-Id: <9426dbd66c51aa466ab89272894ad33a7b22edec.1612390822.git.imun@tarantool.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD953AC099BC0052A9CC9F923E808BA4A11AAD7C69F0036037C182A05F538085040AE08AD9B45670034AF1FD4491667D9C9B53A20BBDCDE57D5F3ED80C0915DBE3B X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7C6068CE86C2B75F5EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006371E8C7BD479B346ED8638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC5A75D8C6D2262C88753A9A0A74363026C53A622E79BA751D389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C078FCF50C7EAF9C588941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6E5E764EB5D94DBD4CC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA567F23339F89546C55F5C1EE8F4F765FC3BBA039523A4428275ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4931B544F03EFBC4D5725A4AB119743A3B3C4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F05F538519369F3743B503F486389A921A5CC5B56E945C8DA X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C4C7A0BC55FA0FE5FC5A75D8C6D2262C88753A9A0A74363026E378AE254720FA2BB1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB791E6C230873D55CDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D342B94C1DAF75C4D22E7F7F7103E6D546B387D915791E5FFB4685951948417128C3B6E5F63B3D2E6431D7E09C32AA3244C600A33271E70E9E6B6A8B65B4D15F6703A92A9747B6CC886927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojSeaWuhK039JALGoI3j9X0w== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638224BDB328D134DFE20ED7F16A27A3698F1A7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 2/3] build: adjust LuaJIT build system 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" LuaJIT submodule is bumped to introduce the following changes: * test: run luacheck static analysis via CMake * test: fix warnings found with luacheck in misclib* * test: run LuaJIT tests via CMake * build: replace GNU Make with CMake * build: preserve the original build system Since LuaJIT build system is ported to CMake in scope of the changeset mentioned above, the module building the LuaJIT bundled in Tarantool is completely reworked. There is no option to build Tarantool against another prebuilt LuaJIT due to a91962c0df8f649f7ebee2fb2c90c0e3810acf5f ('Until Bug#962848 is fixed, don't try to compile with external LuaJIT'), so all redundant options defining the libluajit to be used in Tarantool are dropped with the related auxiliary files. To run LuaJIT related tests or static analysis for Lua files within LuaJIT repository, and targets are used respectively as a dependency of the corresponding Tarantool targets. As an additional dependency to run LuaJIT tests, prove[1] utility is required, so the necessary binary packages are added to the lists with build requirements. [1]: https://metacpan.org/pod/TAP::Harness#prove Closes #4862 Closes #5470 Signed-off-by: Igor Munkin --- .luacheckrc | 1 - CMakeLists.txt | 2 +- cmake/luajit.cmake | 375 ++++++++++++-------------------------------- cmake/luatest.cpp | 80 ---------- debian/control | 2 + rpm/tarantool.spec | 2 + src/CMakeLists.txt | 28 ++-- test/CMakeLists.txt | 18 +-- third_party/luajit | 2 +- 9 files changed, 119 insertions(+), 391 deletions(-) delete mode 100644 cmake/luatest.cpp diff --git a/.luacheckrc b/.luacheckrc index b75d89a0c..4d5593a83 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -35,7 +35,6 @@ exclude_files = { "test/box/*.test.lua", "test/engine/*.test.lua", "test/engine_long/*.test.lua", - "test/luajit-tap/**/*.lua", "test/replication/*.test.lua", "test/sql/**/*.lua", "test/swim/*.test.lua", diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fbd19558..b9f4ec465 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,7 +159,7 @@ add_custom_target(ctags DEPENDS tags) # Enable 'make luacheck' target. # -add_custom_target(luacheck) +add_custom_target(luacheck DEPENDS LuaJIT-luacheck) add_custom_command(TARGET luacheck COMMAND ${LUACHECK} --codes --config "${PROJECT_SOURCE_DIR}/.luacheckrc" "${PROJECT_SOURCE_DIR}" COMMENT "Perform static analysis of Lua code" diff --git a/cmake/luajit.cmake b/cmake/luajit.cmake index 1c7784e11..455b4967b 100644 --- a/cmake/luajit.cmake +++ b/cmake/luajit.cmake @@ -1,306 +1,125 @@ - # # LuaJIT configuration file. # -# A copy of LuaJIT is maintained within Tarantool -# source. It's located in third_party/luajit. -# -# Instead of this copy, Tarantool can be compiled -# with a system-wide LuaJIT, or LuaJIT at a given -# prefix. This is used when compiling Tarantool -# as part of a distribution, e.g. Debian. -# -# To explicitly request use of the bundled LuaJIT, -# add -DENABLE_BUNDLED_LUAJIT=True to CMake -# configuration flags. -# To explicitly request use of LuaJIT at a given -# prefix, use -DLUAJIT_PREFIX=/path/to/LuaJIT. -# -# These two options are incompatible with each other. -# -# If neither of the two options is given, this script -# first attempts to use the system-installed LuaJIT -# and, in case it is not present or can not be used, -# falls back to the bundled one. +# A copy of LuaJIT is maintained within Tarantool source tree. +# It's located in third_party/luajit. # # LUAJIT_FOUND # LUAJIT_LIBRARIES # LUAJIT_INCLUDE_DIRS # +# This stuff is extremely fragile, proceed with caution. -# -# Bundled LuaJIT paths. -# -set (LUAJIT_BUNDLED_PREFIX "${PROJECT_BINARY_DIR}/third_party/luajit/src") -set (LUAJIT_BUNDLED_LIB "${LUAJIT_BUNDLED_PREFIX}/libluajit.a") - -macro (luajit_use_bundled) - set (LUAJIT_PREFIX "${LUAJIT_BUNDLED_PREFIX}") - set (LUAJIT_INCLUDE "${PROJECT_SOURCE_DIR}/third_party/luajit/src") - set (LUAJIT_LIB "${LUAJIT_BUNDLED_LIB}") - set (ENABLE_BUNDLED_LUAJIT True) -endmacro() - -# -# LuaJIT testing routine -# (see cmake/luatest.cpp for a description). -# -macro (luajit_test) - file (READ "${CMAKE_SOURCE_DIR}/cmake/luatest.cpp" LUAJIT_TEST) - set (CMAKE_REQUIRED_LIBRARIES "${LUAJIT_LIB}") - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - set (CMAKE_REQUIRED_LIBRARIES "-ldl ${CMAKE_REQUIRED_LIBRARIES}") - endif() - set (CMAKE_REQUIRED_INCLUDES "${LUAJIT_INCLUDE}") - CHECK_CXX_SOURCE_RUNS ("${LUAJIT_TEST}" LUAJIT_RUNS) - unset (LUAJIT_TEST) - unset (CMAKE_REQUIRED_LIBRARIES) - unset (CMAKE_REQUIRED_INCLUDES) -endmacro() - -# -# Check if there is a system LuaJIT availaible and -# usable with the server (determined by a compiled test). -# -macro (luajit_try_system) - find_path (LUAJIT_INCLUDE lj_obj.h PATH_SUFFIXES luajit-2.0 luajit) - find_library (LUAJIT_LIB NAMES luajit luajit-5.1 PATH_SUFFIXES x86_64-linux-gnu) - if (LUAJIT_INCLUDE AND LUAJIT_LIB) - message (STATUS "include: ${LUAJIT_INCLUDE}, lib: ${LUAJIT_LIB}") - message (STATUS "Found a system-wide LuaJIT.") - luajit_test() - if ("${LUAJIT_RUNS}" STREQUAL "1") - message (STATUS "System-wide LuaJIT at ${LUAJIT_LIB} is suitable for use.") - else() - message (WARNING "System-wide LuaJIT at ${LUAJIT_LIB} is NOT suitable for use, using the bundled one.") - luajit_use_bundled() - endif() - else() - message (FATAL_ERROR "Not found a system LuaJIT") - #luajit_use_bundled() - endif() -endmacro() - -# -# Check if there is a usable LuaJIT at the given prefix path. -# -macro (luajit_try_prefix) - find_path (LUAJIT_INCLUDE "lua.h" ${LUAJIT_PREFIX} NO_DEFAULT_PATH) - find_library (LUAJIT_LIB "luajit" ${LUAJIT_PREFIX} NO_DEFAULT_PATH) - if (LUAJIT_INCLUDE AND LUAJIT_LIB) - include_directories("${LUAJIT_INCLUDE}") - luajit_test() - if (LUAJIT_RUNS) - message (STATUS "LuaJIT at ${LUAJIT_PREFIX} is suitable for use.") - else() - message (FATAL_ERROR "LuaJIT at ${LUAJIT_PREFIX} is NOT suitable for use.") - endif() - else() - message (FATAL_ERROR "Couldn't find LuaJIT in '${LUAJIT_PREFIX}'") +macro(TestAndAppendFLag flags flag) + string(REGEX REPLACE "-" "_" TESTFLAG ${flag}) + string(TOUPPER ${TESTFLAG} TESTFLAG) + # XXX: can't use string(PREPEND ...) on ancient versions. + set(TESTFLAG "CC_HAS${TESTFLAG}") + if(${${TESTFLAG}}) + set(${flags} "${${flags}} ${flag}") endif() endmacro() -# -# LuaJIT options. -# -option(ENABLE_BUNDLED_LUAJIT "Enable building of the bundled LuaJIT" ON) -option(LUAJIT_PREFIX "Build with LuaJIT at the given path" "") +# Preserve the current CFLAGS and to not spoil the original ones with LuaJIT +# specific flags and defines. +set(CMAKE_C_FLAGS_BCKP ${CMAKE_C_FLAGS}) + +TestAndAppendFLag(CMAKE_C_FLAGS -Wno-parentheses-equality) +TestAndAppendFLag(CMAKE_C_FLAGS -Wno-tautological-compare) +TestAndAppendFLag(CMAKE_C_FLAGS -Wno-misleading-indentation) +TestAndAppendFLag(CMAKE_C_FLAGS -Wno-varargs) +TestAndAppendFLag(CMAKE_C_FLAGS -Wno-implicit-fallthrough) + +set(BUILDMODE static CACHE STRING + "Build mode: build only static lib" FORCE) +set(LUAJIT_ENABLE_GC64 ${LUAJIT_ENABLE_GC64} CACHE BOOL + "GC64 mode for x64" FORCE) +set(LUAJIT_SMART_STRINGS ON CACHE BOOL + "Harder string hashing function" FORCE) +set(LUAJIT_TEST_BINARY $ CACHE STRING + "Lua implementation to be used for tests (tarantool)" FORCE) +set(LUAJIT_USE_TEST OFF CACHE BOOL + "Generate target" FORCE) + +# Enable internal LuaJIT assertions for Tarantool Debug build. +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(LUAJIT_USE_APICHECK ON CACHE BOOL + "Assertions for the Lua/C API" FORCE) + set(LUAJIT_USE_ASSERT ON CACHE BOOL + "Assertions for the whole LuaJIT VM" FORCE) +endif() -if (LUAJIT_PREFIX AND ENABLE_BUNDLED_LUAJIT) - message (FATAL_ERROR "Options LUAJIT_PREFIX and ENABLE_BUNDLED_LUAJIT " - "are not compatible with each other.") +# Valgrind can be used only with the system allocator. For more +# info see LuaJIT root CMakeLists.txt. +if(ENABLE_VALGRIND) + set(LUAJIT_USE_SYSMALLOC ON CACHE BOOL + "System provided memory allocator (realloc)" FORCE) + set(LUAJIT_USE_VALGRIND ON CACHE BOOL + "Valgrind support" FORCE) endif() -if (LUAJIT_PREFIX) - # trying to build with specified LuaJIT. - luajit_try_prefix() -elseif (NOT ENABLE_BUNDLED_LUAJIT) - # trying to build with system LuaJIT, macro can turn on - # building of LuaJIT bundled with the server source. - luajit_try_system() -else() - luajit_use_bundled() +# FIXME: ASAN support is badly implemented in LuaJIT and there is +# not a specific build options for this. At the same time there +# are several places wrapped with LUAJIT_USE_ASAN define. +# Just enable it here if needed and patiently wait until ASAN +# support is implemented properly in LuaJIT. +if(ENABLE_ASAN) + add_definitions(-DLUAJIT_USE_ASAN=1) endif() -unset (LUAJIT_RUNS) -#include_directories("${LUAJIT_INCLUDE}") +if(TARGET_OS_DARWIN) + # Necessary to make LuaJIT (and Tarantool) work on Darwin, see + # http://luajit.org/install.html. + set(CMAKE_EXE_LINKER_FLAGS + "${CMAKE_EXE_LINKER_FLAGS} -pagezero_size 10000 -image_base 100000000") +endif() -macro(luajit_build) - set (luajit_cc ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}) - set (luajit_hostcc ${CMAKE_HOST_C_COMPILER}) - # Cmake rules concerning strings and lists of strings are weird. - # set (foo "1 2 3") defines a string, while - # set (foo 1 2 3) defines a list. - # Use separate_arguments() to turn a string into a list (splits at ws). - # It appears that variable expansion rules are context-dependent. - # With the current arrangement add_custom_command() - # does the right thing. We can even handle pathnames with - # spaces though a path with an embeded semicolon or a quotation mark - # will most certainly wreak havok. - # - # This stuff is extremely fragile, proceed with caution. - set (luajit_cflags ${CMAKE_C_FLAGS}) - set (luajit_ldflags ${CMAKE_EXE_LINKER_FLAGS}) - separate_arguments(luajit_cflags) - separate_arguments(luajit_ldflags) - if(CC_HAS_WNO_PARENTHESES_EQUALITY) - set(luajit_cflags ${luajit_cflags} -Wno-parentheses-equality) - endif() - if(CC_HAS_WNO_TAUTOLOGICAL_COMPARE) - set(luajit_cflags ${luajit_cflags} -Wno-tautological-compare) - endif() - if(CC_HAS_WNO_MISLEADING_INDENTATION) - set(luajit_cflags ${luajit_cflags} -Wno-misleading-indentation) - endif() - if(CC_HAS_WNO_VARARGS) - set(luajit_cflags ${luajit_cflags} -Wno-varargs) - endif() - if (CC_HAS_WNO_IMPLICIT_FALLTHROUGH) - set(luajit_cflags ${luajit_cflags} -Wno-implicit-fallthrough) - endif() +# Define the locations for LuaJIT sources and artefacts. +set(LUAJIT_SOURCE_ROOT ${PROJECT_SOURCE_DIR}/third_party/luajit) +set(LUAJIT_BINARY_ROOT ${PROJECT_BINARY_DIR}/third_party/luajit) - if (LUAJIT_ENABLE_GC64) - add_definitions(-DLUAJIT_ENABLE_GC64=1) - elseif(TARGET_OS_DARWIN) - # Necessary to make LuaJIT work on Darwin, see - # http://luajit.org/install.html - set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} - "-pagezero_size 10000 -image_base 100000000") - endif() +add_subdirectory(${LUAJIT_SOURCE_ROOT} ${LUAJIT_BINARY_ROOT} EXCLUDE_FROM_ALL) - # We are consciously ommiting debug info in RelWithDebInfo mode - if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") - set (luajit_ccopt -O0) - if (CC_HAS_GGDB) - set (luajit_ccdebug -g -ggdb) - else () - set (luajit_ccdebug -g) - endif () - add_definitions(-DLUA_USE_APICHECK=1) - add_definitions(-DLUA_USE_ASSERT=1) - else () - set (luajit_ccopt -O2) - set (luajit_ccdbebug "") - endif() - if (${CMAKE_SYSTEM_NAME} STREQUAL Darwin) - # Pass sysroot - prepended in front of system header/lib dirs, - # i.e. /usr/include, /usr/lib. - # Needed for XCode users without command line tools installed, - # they have headers/libs deep inside /Applications/Xcode.app/... - if (NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "") - set (luajit_cflags ${luajit_cflags} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}) - set (luajit_ldflags ${luajit_ldlags} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}) - set (luajit_hostcc ${luajit_hostcc} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}) - endif() - # Pass deployment target - if ("${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "") - # Default to 10.6 since @rpath support is NOT available in - # earlier versions, needed by AddressSanitizer. - set (luajit_osx_deployment_target 10.6) - else() - set (luajit_osx_deployment_target ${CMAKE_OSX_DEPLOYMENT_TARGET}) - endif() - set(luajit_ldflags - ${luajit_ldflags} -Wl,-macosx_version_min,${luajit_osx_deployment_target}) - endif() - if (ENABLE_GCOV) - set (luajit_ccdebug ${luajit_ccdebug} -fprofile-arcs -ftest-coverage) - endif() - if (ENABLE_VALGRIND) - add_definitions(-DLUAJIT_USE_SYSMALLOC=1) - add_definitions(-DLUAJIT_USE_VALGRIND=1) - set (luajit_xcflags ${luajit_xcflags} - -I${PROJECT_SOURCE_DIR}/src/lib/small/third_party) - endif() - # AddressSanitizer - CFLAGS were set globaly - if (ENABLE_ASAN) - add_definitions(-DLUAJIT_USE_ASAN=1) - set (luajit_ldflags ${luajit_ldflags} -fsanitize=address) - endif() - add_definitions(-DLUAJIT_SMART_STRINGS=1) - # Add all COMPILE_DEFINITIONS to xcflags - get_property(defs DIRECTORY PROPERTY COMPILE_DEFINITIONS) - foreach(def ${defs}) - set(luajit_xcflags ${luajit_xcflags} -D${def}) - endforeach() +set(LUAJIT_PREFIX ${LUAJIT_BINARY_ROOT}/src) +set(LUAJIT_INCLUDE ${LUAJIT_PREFIX}) +set(LUAJIT_LIB ${LUAJIT_PREFIX}/libluajit.a) - # Pass the same toolchain that is used for building of - # tarantool itself, because tools from different toolchains - # can be incompatible. A compiler and a linker are already set - # above. - set (luajit_ld ${CMAKE_LINKER}) - set (luajit_ar ${CMAKE_AR} rcus) - # Enablibg LTO for luajit if DENABLE_LTO set. - if (ENABLE_LTO) - message(STATUS "Enable LTO for luajit") - set (luajit_ldflags ${luajit_ldflags} ${LDFLAGS_LTO}) - message(STATUS "ld: " ${luajit_ldflags}) - set (luajit_cflags ${luajit_cflags} ${CFLAGS_LTO}) - message(STATUS "cflags: " ${luajit_cflags}) - set (luajit_ar ${AR_LTO} rcus) - message(STATUS "ar: " ${luajit_ar}) - endif() - set (luajit_strip ${CMAKE_STRIP}) +add_dependencies(build_bundled_libs libluajit) - set (luajit_buildoptions - BUILDMODE=static - HOST_CC="${luajit_hostcc}" - TARGET_CC="${luajit_cc}" - TARGET_CFLAGS="${luajit_cflags}" - TARGET_LD="${luajit_ld}" - TARGET_LDFLAGS="${luajit_ldflags}" - TARGET_AR="${luajit_ar}" - TARGET_STRIP="${luajit_strip}" - TARGET_SYS="${CMAKE_SYSTEM_NAME}" - CCOPT="${luajit_ccopt}" - CCDEBUG="${luajit_ccdebug}" - XCFLAGS="${luajit_xcflags}" - Q='' - # We need to set MACOSX_DEPLOYMENT_TARGET to at least 10.6, - # because 10.4 SDK (which is set by default in LuaJIT's - # Makefile) is not longer included in Mac OS X Mojave 10.14. - # See also https://github.com/LuaJIT/LuaJIT/issues/484 - MACOSX_DEPLOYMENT_TARGET="${luajit_osx_deployment_target}") - if (${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) - add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/third_party/luajit/src/libluajit.a - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/third_party/luajit - COMMAND $(MAKE) ${luajit_buildoptions} clean - COMMAND $(MAKE) -C src ${luajit_buildoptions} jit/vmdef.lua libluajit.a - DEPENDS ${CMAKE_SOURCE_DIR}/CMakeCache.txt - ) - else() - add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/third_party/luajit - COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/third_party/luajit" - ) - add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/third_party/luajit/src/libluajit.a - 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 $(MAKE) ${luajit_buildoptions} clean - COMMAND $(MAKE) -C src ${luajit_buildoptions} jit/vmdef.lua libluajit.a - DEPENDS ${PROJECT_BINARY_DIR}/CMakeCache.txt ${PROJECT_BINARY_DIR}/third_party/luajit - ) - endif() - add_custom_target(libluajit - DEPENDS ${PROJECT_BINARY_DIR}/third_party/luajit/src/libluajit.a - ) - add_dependencies(build_bundled_libs libluajit) - unset (luajit_buildoptions) - set (inc ${PROJECT_SOURCE_DIR}/third_party/luajit/src) - install (FILES ${inc}/lua.h ${inc}/lualib.h ${inc}/lauxlib.h - ${inc}/luaconf.h ${inc}/lua.hpp ${inc}/luajit.h ${inc}/lmisclib.h - DESTINATION ${MODULE_INCLUDEDIR}) -endmacro() - -# -# Building shipped luajit only if there is no -# usable system one (see cmake/luajit.cmake) or by demand. -# -if (ENABLE_BUNDLED_LUAJIT) - luajit_build() -endif() +install( + FILES + ${LUAJIT_SOURCE_ROOT}/src/lua.h + ${LUAJIT_SOURCE_ROOT}/src/lualib.h + ${LUAJIT_SOURCE_ROOT}/src/lauxlib.h + ${LUAJIT_SOURCE_ROOT}/src/luaconf.h + ${LUAJIT_SOURCE_ROOT}/src/lua.hpp + ${LUAJIT_SOURCE_ROOT}/src/luajit.h + ${LUAJIT_SOURCE_ROOT}/src/lmisclib.h + DESTINATION ${MODULE_INCLUDEDIR} +) set(LuaJIT_FIND_REQUIRED TRUE) find_package_handle_standard_args(LuaJIT REQUIRED_VARS LUAJIT_INCLUDE LUAJIT_LIB) set(LUAJIT_INCLUDE_DIRS ${LUAJIT_INCLUDE}) set(LUAJIT_LIBRARIES ${LUAJIT_LIB}) + +# XXX: Since Tarantool use LuaJIT internals to implement all +# required interfaces, several defines and flags need to be set +# for Tarantool too. +# FIXME: Hope everything below will have gone in a future. + +# Include LuaJIT source directory to use the internal headers. +include_directories(${LUAJIT_SOURCE_ROOT}/src) + +# Since LUAJIT_SMART_STRINGS is enabled for LuaJIT bundle, it +# should be unconditionally enabled for Tarantool too. Otherwise, +# all modules using LuaJIT internal headers are misaligned. +add_definitions(-DLUAJIT_SMART_STRINGS=1) +# The same is done for LUAJIT_ENABLE_GC64 but under the condition. +if(LUAJIT_ENABLE_GC64) + add_definitions(-DLUAJIT_ENABLE_GC64) +endif() + +# Restore the preserved CFLAGS. +set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS_BCKP}) diff --git a/cmake/luatest.cpp b/cmake/luatest.cpp deleted file mode 100644 index e9c951933..000000000 --- a/cmake/luatest.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2010-2015, Tarantool AUTHORS, please see AUTHORS file. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Find out LuaJIT behavior on the current platform. - * - * LuaJIT uses different stack unwinding mechanisms on 32-bit x86 - * and 64-bit x86-64 hardware: on a 32-bit system it can use - * its own * longjmp-style "internal stack unwinding". - * Among other things, this mechanism doesn't support exception - * propagation from Lua panic function (lua_atpanic()), and - * this is exactly what Tarantool does: throws an exception - * in lua_atpanic(). - * - * Which mechanism to use is determined at library - * compile time, by a set of flags - * (-fexceptions -funwind-tables -DLUAJIT_UNWIND_EXTERNAL), - * hence, when configuring, we can't just check the library file - * to find out whether or not it will work. - * Instead, we compile and run this test. - * - * http://lua-users.org/lists/lua-l/2010-04/msg00470.html - */ - -#include -#include - -static int panic = 0; - -static int lua_panic_cb(lua_State *L) { - if (!panic++) - throw 0; - abort(); - return 0; -} - -int -main(int argc, char * argv[]) -{ - lua_State *L = luaL_newstate(); - if (L == NULL) - return 1; - lua_atpanic(L, lua_panic_cb); - try { - lua_pushstring(L, "uncallable"); - lua_call(L, 0, LUA_MULTRET); - } catch (...) { - /* If we're lucky, we should get here. */ - } - lua_close(L); - return 0; -} diff --git a/debian/control b/debian/control index ce810ee67..d2390e95c 100644 --- a/debian/control +++ b/debian/control @@ -20,6 +20,8 @@ Build-Depends: cdbs (>= 0.4.100), debhelper (>= 9), dpkg-dev (>= 1.16.1~), libicu-dev, # libcurl build dependencies zlib1g-dev, +# Install prove to run LuaJIT tests. + libtest-harness-perl, Section: database Standards-Version: 3.9.8 Homepage: http://tarantool.org/ diff --git a/rpm/tarantool.spec b/rpm/tarantool.spec index ffd161862..939442f10 100644 --- a/rpm/tarantool.spec +++ b/rpm/tarantool.spec @@ -108,6 +108,8 @@ BuildRequires: python-gevent >= 1.0 BuildRequires: python-yaml >= 3.0.9 %endif %endif +# Install prove to run LuaJIT tests. +BuildRequires: perl-Test-Harness Name: tarantool # ${major}.${major}.${minor}.${patch}, e.g. 1.6.8.175 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a712bc29..b12bce58b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,21 +52,21 @@ lua_source(lua_sources lua/httpc.lua) lua_source(lua_sources lua/iconv.lua) lua_source(lua_sources lua/swim.lua) # LuaJIT jit.* library -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/bc.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/bcsave.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/dis_x86.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/dis_x64.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/dump.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/vmdef.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/v.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/p.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/zone.lua") +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/src/jit/bc.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/src/jit/bcsave.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/src/jit/dis_x86.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/src/jit/dis_x64.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/src/jit/dump.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/src/jit/v.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/src/jit/p.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/src/jit/zone.lua) +lua_source(lua_sources ${LUAJIT_BINARY_ROOT}/src/jit/vmdef.lua) # LuaJIT tools.* library -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/tools/memprof.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/tools/memprof/humanize.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/tools/memprof/parse.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/tools/utils/bufread.lua") -lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/tools/utils/symtab.lua") +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/tools/memprof.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/tools/memprof/humanize.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/tools/memprof/parse.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/tools/utils/bufread.lua) +lua_source(lua_sources ${LUAJIT_SOURCE_ROOT}/tools/utils/symtab.lua) add_custom_target(generate_lua_sources WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/box diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index baa704037..d40b92237 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,14 +12,6 @@ function(build_module module files) endif(TARGET_OS_DARWIN) endfunction() -function(build_lualib lib sources) - add_library(${lib} SHARED ${sources}) - set_target_properties(${lib} PROPERTIES PREFIX "") - if(TARGET_OS_DARWIN) - set_target_properties(${lib} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") - endif(TARGET_OS_DARWIN) -endfunction() - add_compile_flags("C;CXX" "-Wno-unused-parameter") @@ -43,10 +35,6 @@ if(POLICY CMP0037) endif() endif(POLICY CMP0037) -execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - ${PROJECT_SOURCE_DIR}/third_party/luajit/test - ${CMAKE_CURRENT_BINARY_DIR}/luajit-tap) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/small COMMAND ${CMAKE_COMMAND} -E create_symlink ${PROJECT_SOURCE_DIR}/src/lib/small/test/ @@ -57,14 +45,14 @@ add_custom_target(symlink_small_tests ALL add_custom_target(test DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/small - ${CMAKE_CURRENT_BINARY_DIR}/luajit-tap + LuaJIT-test COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py --builddir=${PROJECT_BINARY_DIR} --vardir=${PROJECT_BINARY_DIR}/test/var) add_custom_target(test-force DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/small - ${CMAKE_CURRENT_BINARY_DIR}/luajit-tap + LuaJIT-test COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py --builddir=${PROJECT_BINARY_DIR} --vardir=${PROJECT_BINARY_DIR}/test/var @@ -78,8 +66,6 @@ if(ENABLE_FUZZER) add_subdirectory(fuzz) endif() add_subdirectory(unit) -add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/luajit/test - ${PROJECT_BINARY_DIR}/third_party/luajit/test) # Disable connector_c for 1.6 #add_subdirectory(connector_c) diff --git a/third_party/luajit b/third_party/luajit index c0c2e62a5..2350dd7ed 160000 --- a/third_party/luajit +++ b/third_party/luajit @@ -1 +1 @@ -Subproject commit c0c2e62a5404b51ba740ed28762e65b2ef56bcf9 +Subproject commit 2350dd7ed112c2c7b2f96c6ef8701eeac62bf9d7 -- 2.25.0