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/docs/en/development/build.md b/docs/en/development/build.md index 97b477d55a5..be45c1ed5f7 100644 --- a/docs/en/development/build.md +++ b/docs/en/development/build.md @@ -155,6 +155,10 @@ Normally ClickHouse is statically linked into a single static `clickhouse` binar -DUSE_STATIC_LIBRARIES=0 -DSPLIT_SHARED_LIBRARIES=1 -DCLICKHOUSE_SPLIT_BINARY=1 ``` -Note that in this configuration there is no single `clickhouse` binary, and you have to run `clickhouse-server`, `clickhouse-client` etc. +Note that the split build has several drawbacks: +* There is no single `clickhouse` binary, and you have to run `clickhouse-server`, `clickhouse-client`, etc. +* Risk of segfault if you run any of the programs while rebuilding the project. +* You cannot run the integration tests since they only work a single complete binary. +* You can't easily copy the binaries elsewhere. Instead of moving a single binary you'll need to copy all binaries and libraries. [Original article](https://clickhouse.tech/docs/en/development/build/) 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})