Skip to content

Commit

Permalink
[CBRD-25386] Modified so that TBB is statically linked only to 'libcu…
Browse files Browse the repository at this point in the history
…brid.so'
  • Loading branch information
H2SU committed Oct 28, 2024
1 parent 255ba8d commit 684200c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
17 changes: 14 additions & 3 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,11 @@ if(WITH_LIBTBB STREQUAL "EXTERNAL")
INSTALL_COMMAND make -j install
"${LIBTBB_BYPRODUCTS}"
)
list(APPEND EP_TARGETS ${LIBTBB_TARGET})
list(APPEND EP_INCLUDES ${LIBTBB_INCLUDES})
list(APPEND EP_LIBS ${LIBTBB_LIBS})

# Append include directories and libraries for libcubrid.so only
list(APPEND TBB_TARGETS ${LIBTBB_TARGET})
list(APPEND TBB_INCLUDES ${LIBTBB_INCLUDES})
list(APPEND TBB_LIBS ${LIBTBB_LIBS})
endif(UNIX)
endif()

Expand All @@ -486,6 +488,15 @@ set (EP_TARGETS ${EP_TARGETS} PARENT_SCOPE)
set (EP_LIBS ${EP_LIBS} PARENT_SCOPE)
set (EP_INCLUDES ${EP_INCLUDES} PARENT_SCOPE)

# [TODO]
# EP_TARGETS, EP_LIBS, and EP_INCLUDES are linked everywhere.
# Howerver, TBB is only used on the server side, so it should only be linked to libcubrid.so.
# Therefore, we separated it into a TBB list to ensure it links exclusively to libcubrid.so.
# In the future, please separate any directories and libraries that are exclusively used on the server side into EP_SERVER_XXX.
set (TBB_TARGETS ${TBB_TARGETS} PARENT_SCOPE)
set (TBB_INCLUDES ${TBB_INCLUDES} PARENT_SCOPE)
set (TBB_LIBS ${TBB_LIBS} PARENT_SCOPE)

# Expose targets for sa - FIXME better solutions
include (3rdparty_util)

Expand Down
6 changes: 6 additions & 0 deletions cubrid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@ if(WIN32)
set_target_properties(cubrid PROPERTIES LINK_FLAGS "/DEF:\"${CMAKE_SOURCE_DIR}/win/libcubrid/libcubrid.def\"" LINK_FLAGS_RELEASE "/NODEFAULTLIB:libcmt.lib" LINK_FLAGS_DEBUG "/NODEFAULTLIB:msvcrt.lib")
endif(WIN32)
target_include_directories(cubrid PRIVATE ${JAVA_INC} ${EP_INCLUDES} ${FLEX_INCLUDE_DIRS})

# Add TBB
target_include_directories(cubrid PUBLIC ${TBB_INCLUDES})
target_link_libraries(cubrid LINK_PRIVATE ${TBB_LIBS})
add_dependencies(cubrid ${TBB_TARGETS})

if(UNIX)
target_link_libraries(cubrid LINK_PRIVATE -Wl,-whole-archive ${EP_LIBS} -Wl,-no-whole-archive)
target_link_libraries(cubrid LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
Expand Down
4 changes: 4 additions & 0 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ if(UNIX)
target_include_directories(unittests_lf PRIVATE ${EP_INCLUDES})
target_link_libraries(unittests_lf LINK_PRIVATE cubridcs)

# Add TBB
target_link_libraries(unittests_lf LINK_PRIVATE ${TBB_LIBS})
target_include_directories(unittests_lf PUBLIC ${TBB_INCLUDES})
add_dependencies(unittests_lf ${TBB_TARGETS})

set(UNITTESTS_AREA_SOURCES
${BASE_DIR}/memory_monitor_api.cpp
Expand Down

0 comments on commit 684200c

Please sign in to comment.