From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@dev.tarantool.org, tsafin@tarantool.org Subject: [Tarantool-patches] [PATCH 1/2] sql: don't build sql as a separate library Date: Sun, 14 Jun 2020 18:24:30 +0200 [thread overview] Message-ID: <6f1f207fe2bfb48531175979d135df25a6f99ef3.1592151487.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1592151487.git.v.shpilevoy@tarantool.org> SQL heavily depends on box, and box on SQL. So they can't be separate libraries. The build started failing with undefined box symbols in SQL, when code of the latter has slightly changed in one of the recent commits. The build failed only with UB sanitizer enabled, but 'VERBOSE=1 make' showed that both with UB and without UB the build command was the same (not counting -fsanitize flags). So the sanitizer has nothing to do with it. The patch makes SQL sources being built as a part of box library. Closes #5067 --- src/CMakeLists.txt | 2 +- src/box/CMakeLists.txt | 101 ++++++++++++++++++++++++++++++++-- src/box/sql/CMakeLists.txt | 109 ------------------------------------- 3 files changed, 98 insertions(+), 114 deletions(-) delete mode 100644 src/box/sql/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7099e9bef..68d69eded 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -266,7 +266,7 @@ add_executable( ${LIBUTIL_FREEBSD_SRC}/flopen.c ${LIBUTIL_FREEBSD_SRC}/pidfile.c) -add_dependencies(tarantool build_bundled_libs sql) +add_dependencies(tarantool build_bundled_libs) target_link_libraries(tarantool box ${common_libraries}) if (TARGET_OS_FREEBSD AND NOT TARGET_OS_DEBIAN_FREEBSD) diff --git a/src/box/CMakeLists.txt b/src/box/CMakeLists.txt index 230e7427d..37a3c3b50 100644 --- a/src/box/CMakeLists.txt +++ b/src/box/CMakeLists.txt @@ -1,12 +1,11 @@ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/box/lua) +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/box/sql) # Sometimes 'spying' code is not acceptable even if it would be # disabled by default. That option allows to remove the feedback # daemon from the build completely. option(ENABLE_FEEDBACK_DAEMON "Feedback daemon which reports debug data to the Tarantool team" ON) -add_subdirectory(sql) - set(lua_sources) lua_source(lua_sources lua/load_cfg.lua) lua_source(lua_sources lua/schema.lua) @@ -25,6 +24,52 @@ lua_source(lua_sources lua/merger.lua) set(bin_sources) bin_source(bin_sources bootstrap.snap bootstrap.h) +set(sql_sources + sql/opcodes.c + sql/parse.c + sql/alter.c + sql/analyze.c + sql/cursor.c + sql/build.c + sql/callback.c + sql/date.c + sql/delete.c + sql/expr.c + sql/fk_constraint.c + sql/func.c + sql/global.c + sql/hash.c + sql/insert.c + sql/legacy.c + sql/main.c + sql/malloc.c + sql/os.c + sql/os_unix.c + sql/parse_def.c + sql/pragma.c + sql/prepare.c + sql/printf.c + sql/random.c + sql/resolve.c + sql/select.c + sql/tokenize.c + sql/treeview.c + sql/trigger.c + sql/utf.c + sql/update.c + sql/util.c + sql/vdbe.c + sql/vdbeapi.c + sql/vdbeaux.c + sql/vdbemem.c + sql/vdbesort.c + sql/vdbetrace.c + sql/walker.c + sql/where.c + sql/wherecode.c + sql/whereexpr.c +) + add_custom_target(box_generate_lua_sources WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/box DEPENDS ${lua_sources}) @@ -143,6 +188,7 @@ add_library(box STATIC wal.c call.c merger.c + ${sql_sources} ${lua_sources} lua/init.c lua/call.c @@ -167,6 +213,53 @@ add_library(box STATIC lua/merger.c ${bin_sources}) +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-DSQL_DEBUG=1) +endif() +add_definitions(-DSQL_OMIT_AUTOMATIC_INDEX=1 -DSQL_TEST=1) + +set(EXT_SRC_DIR ${CMAKE_SOURCE_DIR}/extra) +set(EXT_BIN_DIR ${CMAKE_BINARY_DIR}/extra) +set(SQL_SRC_DIR ${CMAKE_SOURCE_DIR}/src/box/sql) +set(SQL_BIN_DIR ${CMAKE_BINARY_DIR}/src/box/sql) + +include_directories(${SQL_SRC_DIR}) +include_directories(${SQL_BIN_DIR}) + +add_custom_target(generate_sql_files DEPENDS + sql/parse.h + sql/keywordhash.h + sql/parse.y + sql/parse.c + sql/opcodes.c) + +add_custom_command(OUTPUT ${SQL_BIN_DIR}/keywordhash.h + COMMAND ${EXT_BIN_DIR}/mkkeywordhash > keywordhash.h.tmp + COMMAND ${CMAKE_COMMAND} -E copy_if_different keywordhash.h.tmp keywordhash.h + COMMAND ${CMAKE_COMMAND} -E remove keywordhash.h.tmp + WORKING_DIRECTORY "${SQL_BIN_DIR}" + DEPENDS mkkeywordhash) + +add_custom_command(OUTPUT ${SQL_BIN_DIR}/parse.h ${SQL_BIN_DIR}/parse.c + COMMAND ${EXT_BIN_DIR}/lemon -T${EXT_SRC_DIR}/lempar.c ${SQL_SRC_DIR}/parse.y + COMMAND ${CMAKE_COMMAND} -E copy parse.h parse.h.tmp + COMMAND ${EXT_SRC_DIR}/addopcodes.sh parse.h.tmp > parse.h + COMMAND ${CMAKE_COMMAND} -E remove parse.h.tmp parse.out + WORKING_DIRECTORY "${SQL_BIN_DIR}" + DEPENDS lemon ${SQL_SRC_DIR}/parse.y) + +add_custom_command(OUTPUT ${SQL_BIN_DIR}/opcodes.h + COMMAND cat parse.h ${SQL_SRC_DIR}/vdbe.c | ${EXT_SRC_DIR}/mkopcodeh.sh > opcodes.h + WORKING_DIRECTORY "${SQL_BIN_DIR}" + DEPENDS ${SQL_SRC_DIR}/vdbe.c ${EXT_SRC_DIR}/mkopcodeh.sh ${SQL_BIN_DIR}/parse.h) + +add_custom_command(OUTPUT ${SQL_BIN_DIR}/opcodes.c + COMMAND ${EXT_SRC_DIR}/mkopcodec.sh opcodes.h > opcodes.c + WORKING_DIRECTORY "${SQL_BIN_DIR}" + DEPENDS ${SQL_SRC_DIR}/vdbe.c ${EXT_SRC_DIR}/mkopcodec.sh ${SQL_BIN_DIR}/parse.h + ${SQL_BIN_DIR}/opcodes.h) + target_link_libraries(box box_error tuple stat xrow xlog vclock crc32 scramble - sql ${common_libraries}) -add_dependencies(box build_bundled_libs) + ${common_libraries}) + +add_dependencies(box build_bundled_libs generate_sql_files) diff --git a/src/box/sql/CMakeLists.txt b/src/box/sql/CMakeLists.txt deleted file mode 100644 index 1f2a6640f..000000000 --- a/src/box/sql/CMakeLists.txt +++ /dev/null @@ -1,109 +0,0 @@ -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - add_definitions(-DSQL_DEBUG=1) -endif() - -set(EXT_SRC_DIR ${CMAKE_SOURCE_DIR}/extra) -set(EXT_BIN_DIR ${CMAKE_BINARY_DIR}/extra) -set(SQL_SRC_DIR ${CMAKE_SOURCE_DIR}/src/box/sql) -set(SQL_BIN_DIR ${CMAKE_BINARY_DIR}/src/box/sql) - -include_directories(${SQL_SRC_DIR}) -include_directories(${SQL_BIN_DIR}) - -add_definitions(-DSQL_OMIT_AUTOMATIC_INDEX) - -set(TEST_DEFINITIONS - SQL_NO_SYNC=1 - SQL_TEST=1 - SQL_PRIVATE= - SQL_CORE=1 -) - -add_library(sql STATIC - # Generated files - opcodes.c - parse.c - alter.c - analyze.c - cursor.c - build.c - callback.c - date.c - delete.c - expr.c - fk_constraint.c - func.c - global.c - hash.c - insert.c - legacy.c - main.c - malloc.c - os.c - os_unix.c - parse_def.c - pragma.c - prepare.c - printf.c - random.c - resolve.c - select.c - tokenize.c - treeview.c - trigger.c - utf.c - update.c - util.c - vdbe.c - vdbeapi.c - vdbeaux.c - vdbemem.c - vdbesort.c - vdbetrace.c - walker.c - where.c - wherecode.c - whereexpr.c -) -set_target_properties(sql PROPERTIES COMPILE_DEFINITIONS - "${TEST_DEFINITIONS}") -target_link_libraries(sql ${ICU_LIBRARIES}) - -add_custom_target(generate_sql_files DEPENDS - parse.h - keywordhash.h - parse.y - parse.c - opcodes.c) - -add_custom_command(OUTPUT ${SQL_BIN_DIR}/keywordhash.h - COMMAND ${EXT_BIN_DIR}/mkkeywordhash > keywordhash.h.tmp - COMMAND ${CMAKE_COMMAND} -E copy_if_different keywordhash.h.tmp keywordhash.h - COMMAND ${CMAKE_COMMAND} -E remove keywordhash.h.tmp - WORKING_DIRECTORY "${SQL_BIN_DIR}" - DEPENDS mkkeywordhash) - -add_custom_command(OUTPUT ${SQL_BIN_DIR}/parse.h ${SQL_BIN_DIR}/parse.c - COMMAND ${EXT_BIN_DIR}/lemon -T${EXT_SRC_DIR}/lempar.c ${SQL_SRC_DIR}/parse.y - COMMAND ${CMAKE_COMMAND} -E copy parse.h parse.h.tmp - COMMAND ${EXT_SRC_DIR}/addopcodes.sh parse.h.tmp > parse.h - COMMAND ${CMAKE_COMMAND} -E remove parse.h.tmp parse.out - WORKING_DIRECTORY "${SQL_BIN_DIR}" - DEPENDS lemon ${SQL_SRC_DIR}/parse.y) - -add_custom_command(OUTPUT ${SQL_BIN_DIR}/opcodes.h - COMMAND cat parse.h ${SQL_SRC_DIR}/vdbe.c | ${EXT_SRC_DIR}/mkopcodeh.sh > opcodes.h - WORKING_DIRECTORY "${SQL_BIN_DIR}" - DEPENDS ${SQL_SRC_DIR}/vdbe.c ${EXT_SRC_DIR}/mkopcodeh.sh ${SQL_BIN_DIR}/parse.h) - -add_custom_command(OUTPUT ${SQL_BIN_DIR}/opcodes.c - COMMAND ${EXT_SRC_DIR}/mkopcodec.sh opcodes.h > opcodes.c - WORKING_DIRECTORY "${SQL_BIN_DIR}" - DEPENDS ${SQL_SRC_DIR}/vdbe.c ${EXT_SRC_DIR}/mkopcodec.sh ${SQL_BIN_DIR}/parse.h - ${SQL_BIN_DIR}/opcodes.h) - -add_dependencies(sql generate_sql_files) - -if (APPLE) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined suppress -flat_namespace") -endif(APPLE) -- 2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-06-14 16:24 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-14 16:24 [Tarantool-patches] [PATCH 0/2] ASAN build Vladislav Shpilevoy 2020-06-14 16:24 ` Vladislav Shpilevoy [this message] 2020-06-15 15:42 ` [Tarantool-patches] [PATCH 1/2] sql: don't build sql as a separate library Timur Safin 2020-06-14 16:24 ` [Tarantool-patches] [PATCH 2/2] cmake: split UB sanitations into separate flags Vladislav Shpilevoy 2020-06-15 15:41 ` Timur Safin 2020-06-15 22:19 ` Vladislav Shpilevoy 2020-06-15 14:01 ` [Tarantool-patches] [PATCH 0/2] ASAN build Alexander Turenko 2020-06-15 22:21 ` Vladislav Shpilevoy 2020-06-15 23:04 ` Alexander Turenko 2020-06-15 23:15 ` Vladislav Shpilevoy 2020-06-15 15:43 ` Timur Safin 2020-06-16 8:56 ` Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=6f1f207fe2bfb48531175979d135df25a6f99ef3.1592151487.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=tsafin@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 1/2] sql: don'\''t build sql as a separate library' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox