Skip to content
Snippets Groups Projects
Commit 8bc16692 authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

CMake: fix LUAJIT_USE_XXX definitions

LuaJIT has some configuration flags which can be switched via
-DLUAJIT_USE_OPTION defines, e.g. USE_ASAN or USE_VALGRIND.
Before this patch these definitions were added by CMake to XCFLAGS
variable and passed to LuaJIT's Makefile. However, some of these
flags also affect the content of lj_xxx.h internal header files,
which were included by Tarantool (see utils.c) and compiled WITHOUT
proper flags. This situation might lead to inconsistent ABI between
compiled libluajit.a and Tarantool.

This patch adds all LUAJIT_USE_XXX defines to CMake's COMPILE_FLAGS
in order to enable these flags globally, then parses COMPILE_FLAGS
and adds them to LuaJIT's XCFLAGS.

Needed for #2643
parent e9f8d40b
No related branches found
No related tags found
No related merge requests found
......@@ -167,8 +167,8 @@ macro(luajit_build)
else ()
set (luajit_ccdebug -g)
endif ()
set (luajit_xcflags ${luajit_xcflags}
-DLUA_USE_APICHECK -DLUA_USE_ASSERT)
add_definitions(-DLUA_USE_APICHECK=1)
add_definitions(-DLUA_USE_ASSERT=1)
else ()
set (luajit_ccopt -O2)
set (luajit_ccdbebug "")
......@@ -198,15 +198,21 @@ macro(luajit_build)
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}
-DLUAJIT_USE_VALGRIND -DLUAJIT_USE_SYSMALLOC
-I${PROJECT_SOURCE_DIR}/src/lib/small/third_party)
endif()
# AddressSanitizer - CFLAGS were set globaly
if (ENABLE_ASAN)
set (luajit_xcflags ${luajit_xcflags} -DLUAJIT_USE_ASAN)
add_definitions(-DLUAJIT_USE_ASAN=1)
set (luajit_ldflags ${luajit_ldflags} -fsanitize=address)
endif()
# 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_buildoptions
BUILDMODE=static
HOST_CC="${luajit_hostcc}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment