Remove unbundled zlib support

This commit is contained in:
Azat Khuzhin 2022-01-16 13:34:54 +03:00
parent 5dee76cda7
commit ca8525a733
20 changed files with 27 additions and 99 deletions

View File

@ -494,7 +494,6 @@ include (cmake/find/ssl.cmake)
include (cmake/find/ldap.cmake) # after ssl
include (cmake/find/icu.cmake)
include (cmake/find/xz.cmake)
include (cmake/find/zlib.cmake)
include (cmake/find/ltdl.cmake) # for odbc
# openssl, zlib before poco
include (cmake/find/sparsehash.cmake)

View File

@ -74,6 +74,6 @@ LLVMDemangle
# else()
# set (result "LLVM")
# endif ()
# list (APPEND result ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES})
# list (APPEND result ${CMAKE_DL_LIBS} ch_contrib::zlib)
# set (${REQUIRED_LLVM_LIBRARIES} ${result} PARENT_SCOPE)
#endfunction()

View File

@ -31,24 +31,19 @@ if (NOT USE_INTERNAL_ROCKSDB_LIBRARY)
if (NOT SNAPPY_LIBRARY)
include(cmake/find/snappy.cmake)
endif()
if (NOT ZLIB_LIBRARY)
include(cmake/find/zlib.cmake)
endif()
find_package(BZip2)
find_library(LZ4_LIBRARY lz4)
find_library(GFLAGS_LIBRARY gflags)
if(SNAPPY_LIBRARY AND ZLIB_LIBRARY AND LZ4_LIBRARY AND BZIP2_FOUND AND GFLAGS_LIBRARY)
if(SNAPPY_LIBRARY AND LZ4_LIBRARY AND BZIP2_FOUND AND GFLAGS_LIBRARY)
list (APPEND ROCKSDB_LIBRARY ${SNAPPY_LIBRARY})
list (APPEND ROCKSDB_LIBRARY ${ZLIB_LIBRARY})
list (APPEND ROCKSDB_LIBRARY ${LZ4_LIBRARY})
list (APPEND ROCKSDB_LIBRARY ${BZIP2_LIBRARY})
list (APPEND ROCKSDB_LIBRARY ${GFLAGS_LIBRARY})
else()
message (${RECONFIGURE_MESSAGE_LEVEL}
"Can't find system rocksdb: snappy=${SNAPPY_LIBRARY} ;"
" zlib=${ZLIB_LIBRARY} ;"
" lz4=${LZ4_LIBRARY} ;"
" bz2=${BZIP2_LIBRARY} ;"
" gflags=${GFLAGS_LIBRARY} ;")

View File

@ -1,42 +0,0 @@
option (USE_INTERNAL_ZLIB_LIBRARY "Set to FALSE to use system zlib library instead of bundled" ON)
if (NOT MSVC)
set (INTERNAL_ZLIB_NAME "zlib-ng" CACHE INTERNAL "")
else ()
set (INTERNAL_ZLIB_NAME "zlib" CACHE INTERNAL "")
if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/${INTERNAL_ZLIB_NAME}")
message (WARNING "Will use standard zlib, please clone manually:\n git clone https://github.com/madler/zlib.git ${ClickHouse_SOURCE_DIR}/contrib/${INTERNAL_ZLIB_NAME}")
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't use internal zlib library")
endif ()
endif ()
if(NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/${INTERNAL_ZLIB_NAME}/zlib.h")
if(USE_INTERNAL_ZLIB_LIBRARY)
message(WARNING "submodule contrib/${INTERNAL_ZLIB_NAME} is missing. to fix try run: \n git submodule update --init")
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find internal zlib library")
endif()
set(USE_INTERNAL_ZLIB_LIBRARY 0)
set(MISSING_INTERNAL_ZLIB_LIBRARY 1)
endif()
if (NOT USE_INTERNAL_ZLIB_LIBRARY)
find_package (ZLIB)
if (NOT ZLIB_FOUND)
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find system zlib library")
else()
set (ZLIB_NAME "libz")
endif()
endif ()
if (NOT ZLIB_FOUND AND NOT MISSING_INTERNAL_ZLIB_LIBRARY)
set (USE_INTERNAL_ZLIB_LIBRARY 1)
set (ZLIB_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/${INTERNAL_ZLIB_NAME}" "${ClickHouse_BINARY_DIR}/contrib/${INTERNAL_ZLIB_NAME}" CACHE INTERNAL "") # generated zconf.h
set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) # for poco
set (ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIR}) # for protobuf
set (ZLIB_FOUND 1) # for poco
set (ZLIB_LIBRARIES zlib CACHE INTERNAL "")
set (ZLIB_LIBRARY_NAME ${ZLIB_LIBRARIES}) # for cassandra
set (ZLIB_NAME "${INTERNAL_ZLIB_NAME}")
endif ()
message (STATUS "Using ${ZLIB_NAME}: ${ZLIB_INCLUDE_DIR} : ${ZLIB_LIBRARIES}")

View File

@ -57,6 +57,7 @@ endif()
add_subdirectory (poco-cmake)
add_subdirectory (croaring-cmake)
add_subdirectory (zstd-cmake)
add_subdirectory (zlib-ng-cmake)
# TODO: refactor the contrib libraries below this comment.
@ -76,14 +77,6 @@ if (USE_INTERNAL_FARMHASH_LIBRARY)
add_subdirectory (libfarmhash)
endif ()
if (USE_INTERNAL_ZLIB_LIBRARY)
if (INTERNAL_ZLIB_NAME STREQUAL "zlib-ng")
add_subdirectory (zlib-ng-cmake)
else ()
add_subdirectory (${INTERNAL_ZLIB_NAME})
endif ()
endif ()
if (USE_INTERNAL_H3_LIBRARY)
add_subdirectory(h3-cmake)
endif ()
@ -105,7 +98,6 @@ endif ()
if (USE_INTERNAL_RDKAFKA_LIBRARY)
add_subdirectory (librdkafka-cmake)
target_include_directories(rdkafka BEFORE PRIVATE ${ZLIB_INCLUDE_DIR})
if(OPENSSL_INCLUDE_DIR)
target_include_directories(rdkafka BEFORE PRIVATE ${OPENSSL_INCLUDE_DIR})
endif()

View File

@ -307,10 +307,6 @@ if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIBRARY)
set(ARROW_WITH_SNAPPY 1)
endif ()
if (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARIES)
set(ARROW_WITH_ZLIB 1)
endif ()
add_definitions(-DARROW_WITH_LZ4)
SET(ARROW_SRCS "${LIBRARY_DIR}/util/compression_lz4.cc" ${ARROW_SRCS})
@ -319,10 +315,8 @@ if (ARROW_WITH_SNAPPY)
SET(ARROW_SRCS "${LIBRARY_DIR}/util/compression_snappy.cc" ${ARROW_SRCS})
endif ()
if (ARROW_WITH_ZLIB)
add_definitions(-DARROW_WITH_ZLIB)
SET(ARROW_SRCS "${LIBRARY_DIR}/util/compression_zlib.cc" ${ARROW_SRCS})
endif ()
add_definitions(-DARROW_WITH_ZLIB)
SET(ARROW_SRCS "${LIBRARY_DIR}/util/compression_zlib.cc" ${ARROW_SRCS})
if (ARROW_WITH_ZSTD)
add_definitions(-DARROW_WITH_ZSTD)
@ -348,9 +342,7 @@ target_link_libraries(${ARROW_LIBRARY} PRIVATE lz4)
if (ARROW_WITH_SNAPPY)
target_link_libraries(${ARROW_LIBRARY} PRIVATE ${SNAPPY_LIBRARY})
endif ()
if (ARROW_WITH_ZLIB)
target_link_libraries(${ARROW_LIBRARY} PRIVATE ${ZLIB_LIBRARIES})
endif ()
target_link_libraries(${ARROW_LIBRARY} PRIVATE ch_contrib::zlib)
target_link_libraries(${ARROW_LIBRARY} PRIVATE ch_contrib::zstd)
target_include_directories(${ARROW_LIBRARY} SYSTEM PRIVATE ${ORC_INCLUDE_DIR})

View File

@ -101,7 +101,7 @@ if (NOT EXTERNAL_BOOST_FOUND)
add_library (_boost_iostreams ${SRCS_IOSTREAMS})
add_library (boost::iostreams ALIAS _boost_iostreams)
target_include_directories (_boost_iostreams PRIVATE ${LIBRARY_DIR})
target_link_libraries (_boost_iostreams PRIVATE ${ZLIB_LIBRARIES})
target_link_libraries (_boost_iostreams PRIVATE ch_contrib::zlib)
# program_options

View File

@ -50,7 +50,7 @@ add_library(minizip OBJECT
${CASS_SRC_DIR}/third_party/minizip/zip.c
${CASS_SRC_DIR}/third_party/minizip/unzip.c)
target_link_libraries(minizip zlib)
target_link_libraries(minizip ch_contrib::zlib)
target_compile_definitions(minizip PRIVATE "-Dz_crc_t=unsigned long")
list(APPEND INCLUDE_DIRS
@ -115,7 +115,7 @@ add_library(cassandra
$<TARGET_OBJECTS:http-parser>
$<TARGET_OBJECTS:minizip>)
target_link_libraries(cassandra zlib)
target_link_libraries(cassandra ch_contrib::zlib)
add_library(cassandra_static ALIAS cassandra)
target_include_directories(cassandra PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${INCLUDE_DIRS})
target_compile_definitions(cassandra PRIVATE CASS_BUILDING)

View File

@ -10,12 +10,9 @@ set(_gRPC_RE2_INCLUDE_DIR "${RE2_INCLUDE_DIR}")
set(_gRPC_RE2_LIBRARIES "${RE2_LIBRARY}")
# Use zlib from ClickHouse contrib, not from gRPC third_party.
if(NOT ZLIB_INCLUDE_DIRS)
message(FATAL_ERROR " grpc: The location of the \"zlib\" library is unknown")
endif()
set(gRPC_ZLIB_PROVIDER "clickhouse" CACHE STRING "" FORCE)
set(_gRPC_ZLIB_INCLUDE_DIR "${ZLIB_INCLUDE_DIRS}")
set(_gRPC_ZLIB_LIBRARIES "${ZLIB_LIBRARIES}")
set(_gRPC_ZLIB_INCLUDE_DIR "")
set(_gRPC_ZLIB_LIBRARIES ch_contrib::zlib)
# Use protobuf from ClickHouse contrib, not from gRPC third_party.
if(NOT Protobuf_INCLUDE_DIR OR NOT Protobuf_LIBRARY)

View File

@ -117,7 +117,7 @@ target_compile_options(rdkafka PRIVATE -fno-sanitize=undefined)
target_include_directories(rdkafka SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") # for "librdkafka/rdkafka.h"
target_include_directories(rdkafka SYSTEM PUBLIC ${RDKAFKA_SOURCE_DIR}) # Because weird logic with "include_next" is used.
target_include_directories(rdkafka SYSTEM PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/auxdir") # for "../config.h"
target_link_libraries(rdkafka PRIVATE lz4 ${ZLIB_LIBRARIES} ch_contrib::zstd)
target_link_libraries(rdkafka PRIVATE lz4 ch_contrib::zlib ch_contrib::zstd)
if(OPENSSL_SSL_LIBRARY AND OPENSSL_CRYPTO_LIBRARY)
target_link_libraries(rdkafka PRIVATE ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
endif()

View File

@ -52,11 +52,10 @@ set(SRCS
)
add_library(libxml2 ${SRCS})
target_link_libraries(libxml2 PRIVATE ${ZLIB_LIBRARIES})
target_link_libraries(libxml2 PRIVATE ch_contrib::zlib)
if(M_LIBRARY)
target_link_libraries(libxml2 PRIVATE ${M_LIBRARY})
endif()
target_include_directories(libxml2 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/linux_x86_64/include")
target_include_directories(libxml2 PUBLIC "${LIBXML2_SOURCE_DIR}/include")
target_include_directories(libxml2 SYSTEM BEFORE PRIVATE ${ZLIB_INCLUDE_DIR})

View File

@ -80,7 +80,7 @@ set(SIZEOF_SIZE_T 8)
set(SOCKET_SIZE_TYPE socklen_t)
set(SYSTEM_LIBS ${SYSTEM_LIBS} zlib)
set(SYSTEM_LIBS ${SYSTEM_LIBS} ch_contrib::zlib)
if(CMAKE_HAVE_PTHREAD_H)
set(CMAKE_REQUIRED_INCLUDES pthread.h)
@ -222,10 +222,6 @@ if(ICONV_INCLUDE_DIR)
endif()
add_definitions(-DLIBICONV_PLUG)
if(ZLIB_FOUND AND WITH_EXTERNAL_ZLIB)
include_directories(${ZLIB_INCLUDE_DIR})
endif()
if(WITH_DYNCOL)
set(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ${CC_SOURCE_DIR}/libmariadb/mariadb_dyncol.c)
endif()

View File

@ -223,7 +223,7 @@ if (USE_INTERNAL_POCO_LIBRARY)
POCO_OS_FAMILY_UNIX
)
target_include_directories (_poco_foundation SYSTEM PUBLIC "${LIBRARY_DIR}/Foundation/include")
target_link_libraries (_poco_foundation PRIVATE Poco::Foundation::PCRE ${ZLIB_LIBRARIES} lz4)
target_link_libraries (_poco_foundation PRIVATE Poco::Foundation::PCRE ch_contrib::zlib lz4)
else ()
add_library (Poco::Foundation UNKNOWN IMPORTED GLOBAL)

View File

@ -8,7 +8,6 @@ add_definitions(-DHAVE_PTHREAD)
add_definitions(-DHAVE_ZLIB)
include_directories(
${ZLIB_INCLUDE_DIRECTORIES}
${protobuf_binary_dir}
${protobuf_source_dir}/src)
@ -114,7 +113,7 @@ if (ENABLE_FUZZING)
target_compile_options(libprotobuf PRIVATE "-fsanitize-recover=all")
endif()
target_link_libraries(libprotobuf pthread)
target_link_libraries(libprotobuf ${ZLIB_LIBRARIES})
target_link_libraries(libprotobuf ch_contrib::zlib)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
target_link_libraries(libprotobuf log)
endif()

View File

@ -51,7 +51,7 @@ else()
if(WITH_ZLIB)
add_definitions(-DZLIB)
list(APPEND THIRDPARTY_LIBS zlib)
list(APPEND THIRDPARTY_LIBS ch_contrib::zlib)
endif()
if(WITH_LZ4)

View File

@ -130,8 +130,9 @@ set(ZLIB_SRCS
set(ZLIB_ALL_SRCS ${ZLIB_SRCS} ${ZLIB_ARCH_SRCS})
add_library(zlib ${ZLIB_ALL_SRCS})
add_library(zlibstatic ALIAS zlib)
add_library(_zlib ${ZLIB_ALL_SRCS})
add_library(zlibstatic ALIAS _zlib)
add_library(ch_contrib::zlib ALIAS _zlib)
# https://github.com/zlib-ng/zlib-ng/pull/733
# This is disabed by default
@ -153,9 +154,9 @@ configure_file(${SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
configure_file(${CMAKE_CURRENT_BINARY_DIR}/zconf.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
# We should use same defines when including zlib.h as used when zlib compiled
target_compile_definitions (zlib PUBLIC ZLIB_COMPAT WITH_GZFILEOP)
target_compile_definitions (_zlib PUBLIC ZLIB_COMPAT WITH_GZFILEOP)
if (ARCH_AMD64 OR ARCH_AARCH64)
target_compile_definitions (zlib PUBLIC X86_64 UNALIGNED_OK)
target_compile_definitions (_zlib PUBLIC X86_64 UNALIGNED_OK)
endif ()
target_include_directories(zlib SYSTEM PUBLIC ${SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(_zlib SYSTEM BEFORE PUBLIC ${SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -329,7 +329,7 @@ target_link_libraries(clickhouse_common_io
boost::program_options
boost::system
${CITYHASH_LIBRARIES}
${ZLIB_LIBRARIES}
ch_contrib::zlib
pcg_random
Poco::Foundation
)

View File

@ -16,7 +16,7 @@ target_include_directories (mysqlxx PUBLIC .)
target_link_libraries (mysqlxx
clickhouse_common_io
${MYSQLCLIENT_LIBRARIES}
${ZLIB_LIBRARIES}
ch_contrib::zlib
)
if (ENABLE_TESTS)

View File

@ -25,7 +25,7 @@ target_link_libraries(clickhouse_functions
murmurhash
PRIVATE
${ZLIB_LIBRARIES}
ch_contrib::zlib
boost::filesystem
divide_impl
)

View File

@ -65,7 +65,7 @@ add_executable (parse_date_time_best_effort parse_date_time_best_effort.cpp)
target_link_libraries (parse_date_time_best_effort PRIVATE clickhouse_common_io)
add_executable (zlib_ng_bug zlib_ng_bug.cpp)
target_link_libraries (zlib_ng_bug PRIVATE ${ZLIB_LIBRARIES})
target_link_libraries (zlib_ng_bug PRIVATE ch_contrib::zlib)
add_executable (dragonbox_test dragonbox_test.cpp)
target_link_libraries (dragonbox_test PRIVATE dragonbox_to_chars)