diff --git a/base/glibc-compatibility/memcpy/memcpy.h b/base/glibc-compatibility/memcpy/memcpy.h index 211d144cecb..9bee26a3722 100644 --- a/base/glibc-compatibility/memcpy/memcpy.h +++ b/base/glibc-compatibility/memcpy/memcpy.h @@ -1,4 +1,4 @@ -#include +#include #include diff --git a/cmake/linux/toolchain-x86_64.cmake b/cmake/linux/toolchain-x86_64.cmake new file mode 100644 index 00000000000..6773bdbd64d --- /dev/null +++ b/cmake/linux/toolchain-x86_64.cmake @@ -0,0 +1,29 @@ +set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set (CMAKE_SYSTEM_NAME "Linux") +set (CMAKE_SYSTEM_PROCESSOR "x86_64") +set (CMAKE_C_COMPILER_TARGET "x86_64-linux-gnu") +set (CMAKE_CXX_COMPILER_TARGET "x86_64-linux-gnu") +set (CMAKE_ASM_COMPILER_TARGET "x86_64-linux-gnu") + +set (TOOLCHAIN_PATH "${CMAKE_CURRENT_LIST_DIR}/../../contrib/sysroot/linux-x86_64") + +set (CMAKE_SYSROOT "${TOOLCHAIN_PATH}/x86_64-linux-gnu/libc") + +set (CMAKE_AR "llvm-ar" CACHE FILEPATH "" FORCE) +set (CMAKE_RANLIB "llvm-ranlib" CACHE FILEPATH "" FORCE) + +set (CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS} --gcc-toolchain=${TOOLCHAIN_PATH}") +set (CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS} --gcc-toolchain=${TOOLCHAIN_PATH}") +set (CMAKE_ASM_FLAGS_INIT "${CMAKE_ASM_FLAGS} --gcc-toolchain=${TOOLCHAIN_PATH}") + +set (LINKER_NAME "ld.lld" CACHE STRING "" FORCE) + +set (CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld") +set (CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld") + +set (HAS_PRE_1970_EXITCODE "0" CACHE STRING "Result from TRY_RUN" FORCE) +set (HAS_PRE_1970_EXITCODE__TRYRUN_OUTPUT "" CACHE STRING "Output from TRY_RUN" FORCE) + +set (HAS_POST_2038_EXITCODE "0" CACHE STRING "Result from TRY_RUN" FORCE) +set (HAS_POST_2038_EXITCODE__TRYRUN_OUTPUT "" CACHE STRING "Output from TRY_RUN" FORCE) diff --git a/cmake/tools.cmake b/cmake/tools.cmake index f94f4b289a3..4b2db0dedab 100644 --- a/cmake/tools.cmake +++ b/cmake/tools.cmake @@ -89,4 +89,3 @@ if (LINKER_NAME) message(STATUS "Using custom linker by name: ${LINKER_NAME}") endif () - diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 140cc0846ec..4d817c4c6e2 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -163,7 +163,7 @@ endif () if(USE_INTERNAL_SNAPPY_LIBRARY) set(SNAPPY_BUILD_TESTS 0 CACHE INTERNAL "") - add_subdirectory(snappy) + add_subdirectory(snappy-cmake) set (SNAPPY_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/snappy") endif() @@ -215,6 +215,7 @@ function(add_llvm) # Do not adjust RPATH in llvm, since then it will not be able to find libcxx/libcxxabi/libunwind set (CMAKE_INSTALL_RPATH "ON") + set (LLVM_COMPILER_CHECKED 1 CACHE INTERNAL "") set (LLVM_ENABLE_EH 1 CACHE INTERNAL "") set (LLVM_ENABLE_RTTI 1 CACHE INTERNAL "") set (LLVM_ENABLE_PIC 0 CACHE INTERNAL "") diff --git a/contrib/arrow-cmake/CMakeLists.txt b/contrib/arrow-cmake/CMakeLists.txt index 427379dc9b2..841c280d192 100644 --- a/contrib/arrow-cmake/CMakeLists.txt +++ b/contrib/arrow-cmake/CMakeLists.txt @@ -54,7 +54,7 @@ target_link_libraries (${THRIFT_LIBRARY} PRIVATE boost::headers_only) set(ORC_SOURCE_DIR "${ClickHouse_SOURCE_DIR}/contrib/orc/c++") set(ORC_INCLUDE_DIR "${ORC_SOURCE_DIR}/include") set(ORC_SOURCE_SRC_DIR "${ORC_SOURCE_DIR}/src") -set(ORC_SOURCE_WRAP_DIR "${ORC_SOURCE_DIR}/wrap") +# set(ORC_SOURCE_WRAP_DIR "${ORC_SOURCE_DIR}/wrap") set(ORC_BUILD_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/../orc/c++/src") set(ORC_BUILD_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/../orc/c++/include") @@ -101,7 +101,14 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") set(CXX11_FLAGS "-std=c++0x") endif () -include("${ClickHouse_SOURCE_DIR}/contrib/orc/cmake_modules/CheckSourceCompiles.cmake") +set (ORC_CXX_HAS_INITIALIZER_LIST 1) +set (ORC_CXX_HAS_NOEXCEPT 1) +set (ORC_CXX_HAS_NULLPTR 1) +set (ORC_CXX_HAS_OVERRIDE 1) +set (ORC_CXX_HAS_UNIQUE_PTR 1) +set (ORC_CXX_HAS_CSTDINT 1) +set (ORC_CXX_HAS_THREAD_LOCAL 1) + include(orc_check.cmake) configure_file("${ORC_INCLUDE_DIR}/orc/orc-config.hh.in" "${ORC_BUILD_INCLUDE_DIR}/orc/orc-config.hh") configure_file("${ORC_SOURCE_SRC_DIR}/Adaptor.hh.in" "${ORC_BUILD_INCLUDE_DIR}/Adaptor.hh") diff --git a/contrib/arrow-cmake/orc_check.cmake b/contrib/arrow-cmake/orc_check.cmake index ad3b72e44cf..523e1cf1d86 100644 --- a/contrib/arrow-cmake/orc_check.cmake +++ b/contrib/arrow-cmake/orc_check.cmake @@ -1,130 +1,14 @@ -# Not changed part of contrib/orc/c++/src/CMakeLists.txt +set (HAS_PREAD 1) +set (HAS_STRPTIME 1) +set (HAS_STOLL 1) +set (INT64_IS_LL 1) +set (HAS_DIAGNOSTIC_PUSH 1) +set (HAS_STD_ISNAN 1) +set (HAS_STD_MUTEX 1) +set (NEEDS_REDUNDANT_MOVE 1) +set (HAS_PRE_1970 1) +set (HAS_POST_2038 1) +set (NEEDS_Z_PREFIX 0) -INCLUDE(CheckCXXSourceCompiles) - -CHECK_CXX_SOURCE_COMPILES(" - #include - #include - int main(int,char*[]){ - int f = open(\"/x/y\", O_RDONLY); - char buf[100]; - return pread(f, buf, 100, 1000) == 0; - }" - HAS_PREAD -) - -CHECK_CXX_SOURCE_COMPILES(" - #include - int main(int,char*[]){ - struct tm time2020; - return !strptime(\"2020-02-02 12:34:56\", \"%Y-%m-%d %H:%M:%S\", &time2020); - }" - HAS_STRPTIME -) - -CHECK_CXX_SOURCE_COMPILES(" - #include - int main(int,char* argv[]){ - return static_cast(std::stoll(argv[0])); - }" - HAS_STOLL -) - -CHECK_CXX_SOURCE_COMPILES(" - #include - #include - int main(int,char*[]){ - int64_t x = 1; printf(\"%lld\",x); - }" - INT64_IS_LL -) - -CHECK_CXX_SOURCE_COMPILES(" - #ifdef __clang__ - #pragma clang diagnostic push - #pragma clang diagnostic ignored \"-Wdeprecated\" - #pragma clang diagnostic pop - #elif defined(__GNUC__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored \"-Wdeprecated\" - #pragma GCC diagnostic pop - #elif defined(_MSC_VER) - #pragma warning( push ) - #pragma warning( disable : 4996 ) - #pragma warning( pop ) - #else - unknownCompiler! - #endif - int main(int, char *[]) {}" - HAS_DIAGNOSTIC_PUSH -) - -CHECK_CXX_SOURCE_COMPILES(" - #include - int main(int, char *[]) { - return std::isnan(1.0f); - }" - HAS_STD_ISNAN -) - -CHECK_CXX_SOURCE_COMPILES(" - #include - int main(int, char *[]) { - std::mutex test_mutex; - std::lock_guard lock_mutex(test_mutex); - }" - HAS_STD_MUTEX -) - -CHECK_CXX_SOURCE_COMPILES(" - #include - std::string func() { - std::string var = \"test\"; - return std::move(var); - } - int main(int, char *[]) {}" - NEEDS_REDUNDANT_MOVE -) - -INCLUDE(CheckCXXSourceRuns) - -CHECK_CXX_SOURCE_RUNS(" - #include - int main(int, char *[]) { - time_t t = -14210715; // 1969-07-20 12:34:45 - struct tm *ptm = gmtime(&t); - return !(ptm && ptm->tm_year == 69); - }" - HAS_PRE_1970 -) - -CHECK_CXX_SOURCE_RUNS(" - #include - #include - int main(int, char *[]) { - setenv(\"TZ\", \"America/Los_Angeles\", 1); - tzset(); - struct tm time2037; - struct tm time2038; - strptime(\"2037-05-05 12:34:56\", \"%Y-%m-%d %H:%M:%S\", &time2037); - strptime(\"2038-05-05 12:34:56\", \"%Y-%m-%d %H:%M:%S\", &time2038); - return mktime(&time2038) - mktime(&time2037) != 31536000; - }" - HAS_POST_2038 -) - -set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR}) -set(CMAKE_REQUIRED_LIBRARIES zlib) -CHECK_CXX_SOURCE_COMPILES(" - #define Z_PREFIX - #include - z_stream strm; - int main(int, char *[]) { - deflateReset(&strm); - }" - NEEDS_Z_PREFIX -) - -# See https://cmake.org/cmake/help/v3.14/policy/CMP0075.html. Without unsetting it breaks thrift. set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_LIBRARIES) diff --git a/contrib/grpc-cmake/protobuf_generate_grpc.cmake b/contrib/grpc-cmake/protobuf_generate_grpc.cmake index 08d2976c26a..726428a7597 100644 --- a/contrib/grpc-cmake/protobuf_generate_grpc.cmake +++ b/contrib/grpc-cmake/protobuf_generate_grpc.cmake @@ -187,7 +187,7 @@ function(protobuf_generate_grpc) add_custom_command( OUTPUT ${_generated_srcs} - COMMAND protobuf::protoc + COMMAND $ ARGS --${protobuf_generate_grpc_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_grpc_PROTOC_OUT_DIR} --grpc_out ${_dll_export_decl}${protobuf_generate_grpc_PROTOC_OUT_DIR} --plugin=protoc-gen-grpc=$ @@ -204,4 +204,4 @@ function(protobuf_generate_grpc) if(protobuf_generate_grpc_TARGET) target_sources(${protobuf_generate_grpc_TARGET} PRIVATE ${_generated_srcs_all}) endif() -endfunction() \ No newline at end of file +endfunction() diff --git a/contrib/krb5-cmake/CMakeLists.txt b/contrib/krb5-cmake/CMakeLists.txt index 7c750ca12b6..d6c3c23b14e 100644 --- a/contrib/krb5-cmake/CMakeLists.txt +++ b/contrib/krb5-cmake/CMakeLists.txt @@ -1,6 +1,6 @@ find_program(AWK_PROGRAM awk) if(NOT AWK_PROGRAM) - message(FATAL_ERROR "You need the awk program to build ClickHouse with krb5 enabled.") + message(FATAL_ERROR "You need the awk program to build ClickHouse with krb5 enabled.") endif() set(KRB5_SOURCE_DIR "${ClickHouse_SOURCE_DIR}/contrib/krb5/src") diff --git a/contrib/libhdfs3-cmake/CMake/CMakeTestCompileNestedException.cpp b/contrib/libhdfs3-cmake/CMake/CMakeTestCompileNestedException.cpp deleted file mode 100644 index 66918ca516e..00000000000 --- a/contrib/libhdfs3-cmake/CMake/CMakeTestCompileNestedException.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -int main() { - try { - throw 2; - } catch (int) { - std::throw_with_nested(std::runtime_error("test")); - } -} diff --git a/contrib/libhdfs3-cmake/CMake/CMakeTestCompileSteadyClock.cpp b/contrib/libhdfs3-cmake/CMake/CMakeTestCompileSteadyClock.cpp deleted file mode 100644 index afcbe1b83b2..00000000000 --- a/contrib/libhdfs3-cmake/CMake/CMakeTestCompileSteadyClock.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -using std::chrono::steady_clock; - -void foo(const steady_clock &clock) { - return; -} diff --git a/contrib/libhdfs3-cmake/CMake/CMakeTestCompileStrerror.cpp b/contrib/libhdfs3-cmake/CMake/CMakeTestCompileStrerror.c similarity index 100% rename from contrib/libhdfs3-cmake/CMake/CMakeTestCompileStrerror.cpp rename to contrib/libhdfs3-cmake/CMake/CMakeTestCompileStrerror.c diff --git a/contrib/libhdfs3-cmake/CMake/Options.cmake b/contrib/libhdfs3-cmake/CMake/Options.cmake index 04ab823eedc..402aceac2fa 100644 --- a/contrib/libhdfs3-cmake/CMake/Options.cmake +++ b/contrib/libhdfs3-cmake/CMake/Options.cmake @@ -1,4 +1,4 @@ -OPTION(ENABLE_SSE "enable SSE4.2 buildin function" ON) +OPTION(ENABLE_SSE "enable SSE4.2 builtin function" ON) INCLUDE (CheckFunctionExists) CHECK_FUNCTION_EXISTS(dladdr HAVE_DLADDR) @@ -21,30 +21,21 @@ ADD_DEFINITIONS(-D_GNU_SOURCE) ADD_DEFINITIONS(-D_GLIBCXX_USE_NANOSLEEP) TRY_COMPILE(STRERROR_R_RETURN_INT - ${CMAKE_CURRENT_BINARY_DIR} - "${HDFS3_ROOT_DIR}/CMake/CMakeTestCompileStrerror.cpp" + ${CMAKE_CURRENT_BINARY_DIR} + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeTestCompileStrerror.c" CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'" - OUTPUT_VARIABLE OUTPUT) + OUTPUT_VARIABLE OUTPUT) MESSAGE(STATUS "Checking whether strerror_r returns an int") IF(STRERROR_R_RETURN_INT) - MESSAGE(STATUS "Checking whether strerror_r returns an int -- yes") + MESSAGE(STATUS "Checking whether strerror_r returns an int -- yes") ELSE(STRERROR_R_RETURN_INT) - MESSAGE(STATUS "Checking whether strerror_r returns an int -- no") + MESSAGE(STATUS "Checking whether strerror_r returns an int -- no") ENDIF(STRERROR_R_RETURN_INT) -TRY_COMPILE(HAVE_STEADY_CLOCK - ${CMAKE_CURRENT_BINARY_DIR} - "${HDFS3_ROOT_DIR}/CMake/CMakeTestCompileSteadyClock.cpp" - CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'" - OUTPUT_VARIABLE OUTPUT) - -TRY_COMPILE(HAVE_NESTED_EXCEPTION - ${CMAKE_CURRENT_BINARY_DIR} - "${HDFS3_ROOT_DIR}/CMake/CMakeTestCompileNestedException.cpp" - CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'" - OUTPUT_VARIABLE OUTPUT) +set(HAVE_STEADY_CLOCK 1) +set(HAVE_NESTED_EXCEPTION 1) SET(HAVE_BOOST_CHRONO 0) SET(HAVE_BOOST_ATOMIC 0) diff --git a/contrib/protobuf-cmake/protobuf_generate.cmake b/contrib/protobuf-cmake/protobuf_generate.cmake index fc1dfd9cc11..c444162dd1e 100644 --- a/contrib/protobuf-cmake/protobuf_generate.cmake +++ b/contrib/protobuf-cmake/protobuf_generate.cmake @@ -181,11 +181,11 @@ function(protobuf_generate) add_custom_command( OUTPUT ${_generated_srcs} - COMMAND protobuf::protoc + COMMAND $ ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_dll_desc_out} ${_protobuf_include_path} ${_abs_file} DEPENDS ${_abs_file} protobuf::protoc COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}" - VERBATIM ) + VERBATIM) endforeach() set_source_files_properties(${_generated_srcs_all} PROPERTIES GENERATED TRUE) diff --git a/contrib/rocksdb-cmake/CMakeLists.txt b/contrib/rocksdb-cmake/CMakeLists.txt index e7ff1f548e3..6ccbd12516e 100644 --- a/contrib/rocksdb-cmake/CMakeLists.txt +++ b/contrib/rocksdb-cmake/CMakeLists.txt @@ -106,18 +106,6 @@ if(NOT MSVC) set(CMAKE_REQUIRED_FLAGS "-msse4.2 -mpclmul") endif() -CHECK_CXX_SOURCE_COMPILES(" -#include -#include -#include -int main() { - volatile uint32_t x = _mm_crc32_u32(0, 0); - const auto a = _mm_set_epi64x(0, 0); - const auto b = _mm_set_epi64x(0, 0); - const auto c = _mm_clmulepi64_si128(a, b, 0x00); - auto d = _mm_cvtsi128_si64(c); -} -" HAVE_SSE42) unset(CMAKE_REQUIRED_FLAGS) if(HAVE_SSE42) add_definitions(-DHAVE_SSE42) @@ -126,14 +114,7 @@ elseif(FORCE_SSE42) message(FATAL_ERROR "FORCE_SSE42=ON but unable to compile with SSE4.2 enabled") endif() -CHECK_CXX_SOURCE_COMPILES(" -#if defined(_MSC_VER) && !defined(__thread) -#define __thread __declspec(thread) -#endif -int main() { - static __thread int tls; -} -" HAVE_THREAD_LOCAL) +set (HAVE_THREAD_LOCAL 1) if(HAVE_THREAD_LOCAL) add_definitions(-DROCKSDB_SUPPORT_THREAD_LOCAL) endif() @@ -174,20 +155,13 @@ endif() option(WITH_FALLOCATE "build with fallocate" ON) if(WITH_FALLOCATE) - CHECK_CXX_SOURCE_COMPILES(" -#include -#include -int main() { - int fd = open(\"/dev/null\", 0); - fallocate(fd, FALLOC_FL_KEEP_SIZE, 0, 1024); -} -" HAVE_FALLOCATE) + set (HAVE_FALLOCATE 1) if(HAVE_FALLOCATE) add_definitions(-DROCKSDB_FALLOCATE_PRESENT) endif() endif() -CHECK_CXX_SOURCE_COMPILES(" +CHECK_C_SOURCE_COMPILES(" #include int main() { int fd = open(\"/dev/null\", 0); @@ -198,7 +172,7 @@ if(HAVE_SYNC_FILE_RANGE_WRITE) add_definitions(-DROCKSDB_RANGESYNC_PRESENT) endif() -CHECK_CXX_SOURCE_COMPILES(" +CHECK_C_SOURCE_COMPILES(" #include int main() { (void) PTHREAD_MUTEX_ADAPTIVE_NP; diff --git a/contrib/snappy-cmake/CMakeLists.txt b/contrib/snappy-cmake/CMakeLists.txt new file mode 100644 index 00000000000..3f12d875d6b --- /dev/null +++ b/contrib/snappy-cmake/CMakeLists.txt @@ -0,0 +1,42 @@ +set (SOURCE_DIR "${CMAKE_SOURCE_DIR}/contrib/snappy") + +set(SNAPPY_IS_BIG_ENDIAN 0) + +include(CheckIncludeFile) +check_include_file("byteswap.h" HAVE_BYTESWAP_H) +check_include_file("sys/endian.h" HAVE_SYS_ENDIAN_H) +check_include_file("sys/mman.h" HAVE_SYS_MMAN_H) +check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H) +check_include_file("sys/time.h" HAVE_SYS_TIME_H) +check_include_file("sys/uio.h" HAVE_SYS_UIO_H) +check_include_file("unistd.h" HAVE_UNISTD_H) +check_include_file("windows.h" HAVE_WINDOWS_H) + +set (HAVE_BUILTIN_EXPECT 1) +set (HAVE_BUILTIN_CTZ 1) +set (SNAPPY_HAVE_SSSE3 HAVE_SSSE3) +set (HAVE_FUNC_MMAP 1) +set (HAVE_FUNC_SYSCONF 1) + +configure_file( + "${SOURCE_DIR}/cmake/config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/config.h") + +set(HAVE_SYS_UIO_H_01 1) + +configure_file( + "${SOURCE_DIR}/snappy-stubs-public.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/snappy-stubs-public.h") + +add_library(snappy "") +target_sources(snappy + PRIVATE + "${SOURCE_DIR}/snappy-internal.h" + "${SOURCE_DIR}/snappy-stubs-internal.h" + "${SOURCE_DIR}/snappy-c.cc" + "${SOURCE_DIR}/snappy-sinksource.cc" + "${SOURCE_DIR}/snappy-stubs-internal.cc" + "${SOURCE_DIR}/snappy.cc") + +target_include_directories(snappy PUBLIC ${SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)