From 61c4d94f1e9158f307a10ca54a5eb0927f697cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Wed, 11 Aug 2021 11:21:39 +0200 Subject: [PATCH] Add explicit dependency between roaring and clickhouse_common_io Fixes roaring memory tracker for split builds --- contrib/croaring-cmake/CMakeLists.txt | 9 +++------ src/CMakeLists.txt | 5 +++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/contrib/croaring-cmake/CMakeLists.txt b/contrib/croaring-cmake/CMakeLists.txt index f0cb378864b..84cdccedbd3 100644 --- a/contrib/croaring-cmake/CMakeLists.txt +++ b/contrib/croaring-cmake/CMakeLists.txt @@ -26,17 +26,14 @@ target_include_directories(roaring SYSTEM BEFORE PUBLIC "${LIBRARY_DIR}/include" target_include_directories(roaring SYSTEM BEFORE PUBLIC "${LIBRARY_DIR}/cpp") # We redirect malloc/free family of functions to different functions that will track memory in ClickHouse. -# It will make this library depend on linking to 'clickhouse_common_io' library that is not done explicitly via 'target_link_libraries'. -# And we check that all libraries dependencies are satisfied and all symbols are resolved if we do build with shared libraries. -# That's why we enable it only in static build. # Also note that we exploit implicit function declarations. -if (USE_STATIC_LIBRARIES) - target_compile_definitions(roaring PRIVATE +target_compile_definitions(roaring PRIVATE -Dmalloc=clickhouse_malloc -Dcalloc=clickhouse_calloc -Drealloc=clickhouse_realloc -Dreallocarray=clickhouse_reallocarray -Dfree=clickhouse_free -Dposix_memalign=clickhouse_posix_memalign) -endif () + +target_link_libraries(roaring PUBLIC clickhouse_common_io) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6c10d3e2f2b..796c9eb4d2c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -299,10 +299,11 @@ target_link_libraries(clickhouse_common_io ${ZLIB_LIBRARIES} pcg_random Poco::Foundation - roaring ) - +# Make dbms depend on roaring instead of clickhouse_common_io so that roaring itself can depend on clickhouse_common_io +# That way we we can redirect malloc/free functions avoiding circular dependencies +dbms_target_link_libraries(PUBLIC roaring) if (USE_RDKAFKA) dbms_target_link_libraries(PRIVATE ${CPPKAFKA_LIBRARY} ${RDKAFKA_LIBRARY})