From 6d5589ceb3460195a2d578f9f90a7640aa441a32 Mon Sep 17 00:00:00 2001 From: Benjamin Naecker Date: Sun, 25 Apr 2021 21:53:25 -0700 Subject: [PATCH 1/6] Adds clickhouse packaging Adds a build script for pulling clickhouse from source, applying patches, and actually building the source as we need it. This pulls version 21.5 of the server, but from an unnamed commit -- this was just the tip of the main branch when the patches were developed. --- clickhouse/build.sh | 102 +++++++++++++++++++++++++ clickhouse/patches/clickhouse-01.patch | 24 ++++++ clickhouse/patches/clickhouse-02.patch | 13 ++++ clickhouse/patches/clickhouse-03.patch | 31 ++++++++ clickhouse/patches/clickhouse-04.patch | 15 ++++ clickhouse/patches/clickhouse-05.patch | 13 ++++ clickhouse/patches/clickhouse-06.patch | 14 ++++ clickhouse/patches/clickhouse-07.patch | 10 +++ clickhouse/patches/clickhouse-08.patch | 13 ++++ clickhouse/patches/clickhouse-09.patch | 13 ++++ clickhouse/patches/clickhouse-10.patch | 18 +++++ clickhouse/patches/clickhouse-11.patch | 16 ++++ clickhouse/patches/clickhouse-12.patch | 31 ++++++++ clickhouse/patches/clickhouse-13.patch | 13 ++++ clickhouse/patches/clickhouse-14.patch | 19 +++++ clickhouse/patches/clickhouse-15.patch | 34 +++++++++ clickhouse/patches/clickhouse-16.patch | 14 ++++ clickhouse/patches/clickhouse-17.patch | 12 +++ clickhouse/patches/clickhouse-18.patch | 16 ++++ clickhouse/patches/clickhouse-19.patch | 13 ++++ clickhouse/patches/clickhouse-20.patch | 24 ++++++ clickhouse/patches/clickhouse-21.patch | 12 +++ clickhouse/patches/clickhouse-22.patch | 15 ++++ clickhouse/patches/clickhouse-23.patch | 58 ++++++++++++++ clickhouse/patches/clickhouse-24.patch | 13 ++++ clickhouse/patches/clickhouse-25.patch | 29 +++++++ clickhouse/patches/clickhouse-26.patch | 12 +++ clickhouse/patches/clickhouse-27.patch | 16 ++++ clickhouse/patches/clickhouse-28.patch | 16 ++++ clickhouse/patches/clickhouse-29.patch | 13 ++++ clickhouse/patches/clickhouse-30.patch | 30 ++++++++ clickhouse/patches/clickhouse-31.patch | 13 ++++ clickhouse/patches/clickhouse-32.patch | 13 ++++ clickhouse/patches/clickhouse-33.patch | 20 +++++ clickhouse/patches/clickhouse-34.patch | 15 ++++ clickhouse/patches/clickhouse-35.patch | 11 +++ clickhouse/patches/clickhouse-36.patch | 15 ++++ clickhouse/patches/clickhouse-37.patch | 13 ++++ clickhouse/patches/clickhouse-38.patch | 12 +++ clickhouse/patches/clickhouse-39.patch | 22 ++++++ clickhouse/patches/clickhouse-40.patch | 17 +++++ clickhouse/patches/clickhouse-41.patch | 13 ++++ clickhouse/patches/clickhouse-42.patch | 13 ++++ clickhouse/patches/clickhouse-43.patch | 60 +++++++++++++++ 44 files changed, 909 insertions(+) create mode 100755 clickhouse/build.sh create mode 100644 clickhouse/patches/clickhouse-01.patch create mode 100644 clickhouse/patches/clickhouse-02.patch create mode 100644 clickhouse/patches/clickhouse-03.patch create mode 100644 clickhouse/patches/clickhouse-04.patch create mode 100644 clickhouse/patches/clickhouse-05.patch create mode 100644 clickhouse/patches/clickhouse-06.patch create mode 100644 clickhouse/patches/clickhouse-07.patch create mode 100644 clickhouse/patches/clickhouse-08.patch create mode 100644 clickhouse/patches/clickhouse-09.patch create mode 100644 clickhouse/patches/clickhouse-10.patch create mode 100644 clickhouse/patches/clickhouse-11.patch create mode 100644 clickhouse/patches/clickhouse-12.patch create mode 100644 clickhouse/patches/clickhouse-13.patch create mode 100644 clickhouse/patches/clickhouse-14.patch create mode 100644 clickhouse/patches/clickhouse-15.patch create mode 100644 clickhouse/patches/clickhouse-16.patch create mode 100644 clickhouse/patches/clickhouse-17.patch create mode 100644 clickhouse/patches/clickhouse-18.patch create mode 100644 clickhouse/patches/clickhouse-19.patch create mode 100644 clickhouse/patches/clickhouse-20.patch create mode 100644 clickhouse/patches/clickhouse-21.patch create mode 100644 clickhouse/patches/clickhouse-22.patch create mode 100644 clickhouse/patches/clickhouse-23.patch create mode 100644 clickhouse/patches/clickhouse-24.patch create mode 100644 clickhouse/patches/clickhouse-25.patch create mode 100644 clickhouse/patches/clickhouse-26.patch create mode 100644 clickhouse/patches/clickhouse-27.patch create mode 100644 clickhouse/patches/clickhouse-28.patch create mode 100644 clickhouse/patches/clickhouse-29.patch create mode 100644 clickhouse/patches/clickhouse-30.patch create mode 100644 clickhouse/patches/clickhouse-31.patch create mode 100644 clickhouse/patches/clickhouse-32.patch create mode 100644 clickhouse/patches/clickhouse-33.patch create mode 100644 clickhouse/patches/clickhouse-34.patch create mode 100644 clickhouse/patches/clickhouse-35.patch create mode 100644 clickhouse/patches/clickhouse-36.patch create mode 100644 clickhouse/patches/clickhouse-37.patch create mode 100644 clickhouse/patches/clickhouse-38.patch create mode 100644 clickhouse/patches/clickhouse-39.patch create mode 100644 clickhouse/patches/clickhouse-40.patch create mode 100644 clickhouse/patches/clickhouse-41.patch create mode 100644 clickhouse/patches/clickhouse-42.patch create mode 100644 clickhouse/patches/clickhouse-43.patch diff --git a/clickhouse/build.sh b/clickhouse/build.sh new file mode 100755 index 0000000..3ff15f1 --- /dev/null +++ b/clickhouse/build.sh @@ -0,0 +1,102 @@ +#!/bin/bash + +set -o errexit +set -o pipefail + +function info { + printf 'INFO: %s\n' "$*" +} + +function header { + printf -- '\n' + printf -- '----------------------------------------------------------\n' + printf -- 'INFO: %s\n' "$*" + printf -- '----------------------------------------------------------\n' + printf -- '\n' +} + +function fatal { + printf 'ERROR: %s\n' "$*" >&2 + exit 1 +} + +ROOT=$(cd "$(dirname "$0")" && pwd) +PATCH_DIR="$ROOT/patches" +ARTEFACT="$ROOT/clickhouse" +WORK="$ARTEFACT/build" +VER="21.5" +COMMIT="bd49e696c432ed331e0950c3d977bc01f603f02e" + +# +# Download ClickHouse sources +# +REPO="https://github.com/clickhouse/clickhouse" +header "downloading clickhouse sources" +if [[ ! -d "$ARTEFACT" ]]; then + info "cloning clickhouse repo" + git clone "$REPO" + cd "$ARTEFACT" + + info "initializing clickhouse submodules" + git submodule update --init --recursive +fi +cd "$ARTEFACT" +info "checking out commit $COMMIT" +git reset --hard "$COMMIT" +git submodule foreach git reset --hard HEAD +git submodule update --init --recursive + +# +# Patch ClickHouse: +# +header 'patching clickhouse source' +git apply --verbose $PATCH_DIR/* + +# +# Build ClickHouse +# +header 'building clickhouse' +mkdir -p "$WORK" && cd "$WORK" +CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D__EXTENSIONS__ -m64 -I$ARTEFACT/contrib/hyperscan-cmake/x86_64/" +cmake \ + -DCMAKE_C_FLAGS="$CFLAGS" \ + -DCMAKE_CXX_FLAGS="$CFLAGS" \ + -DENABLE_LDAP=off \ + -DUSE_INTERNAL_LDAP_LIBRARY=off \ + -DENABLE_HDFS=off \ + -DUSE_INTERNAL_HDFS3_LIBRARY=off \ + -DENABLE_AMQPCPP=off \ + -DENABLE_AVRO=off \ + -DUSE_INTERNAL_AVRO_LIBRARY=off \ + -DENABLE_CAPNP=off \ + -DUSE_INTERNAL_CAPNP_LIBRARY=off \ + -DENABLE_MSGPACK=off \ + -DUSE_INTERNAL_MSGPACK_LIBRARY=off \ + -DENABLE_MYSQL=off \ + -DENABLE_S3=off \ + -DUSE_INTERNAL_AWS_S3_LIBRARY=off \ + -DENABLE_PARQUET=off \ + -DUSE_INTERNAL_PARQUET_LIBRARY=off \ + -DENABLE_ORC=off \ + -DUSE_INTERNAL_ORC_LIBRARY=off \ + -DUSE_SENTRY=off \ + -DENABLE_CLICKHOUSE_ODBC_BRIDGE=off \ + -DENABLE_CLICKHOUSE_BENCHMARK=off \ + -DENABLE_TESTS=off \ + "$ARTEFACT" + +# The build is massive. Try to parallelize until we error out, usually due to space constraints while +# linking. At that point, continue serially +ninja || (header 'parallel build failed, continuing serially' && ninja -j 1) + +# Strip the resulting binary. This part is crucial. ClickHouse's binary is 3+GiB unstripped. +/usr/bin/strip "$WORK/programs/clickhouse" +/usr/bin/tar cvfz \ + $ROOT/clickhouse-v$VER.illumos.tar.gz \ + -C "$WORK/programs" clickhouse \ + -C "$ARTEFACT/programs/server" config.xml \ + -C "$ARTEFACT/programs/server" users.xml \ + -C "$ROOT" manifest.xml + +header 'build output:' +#find "$WORK" -type f -ls diff --git a/clickhouse/patches/clickhouse-01.patch b/clickhouse/patches/clickhouse-01.patch new file mode 100644 index 0000000..e970bf1 --- /dev/null +++ b/clickhouse/patches/clickhouse-01.patch @@ -0,0 +1,24 @@ +diff --git a/base/common/getThreadId.cpp b/base/common/getThreadId.cpp +index 700c51f..be5f2df 100644 +--- a/base/common/getThreadId.cpp ++++ b/base/common/getThreadId.cpp +@@ -8,6 +8,8 @@ + #include + #elif defined(OS_FREEBSD) + #include ++#elif defined(OS_SUNOS) ++ #include + #else + #include + #include +@@ -25,6 +27,10 @@ uint64_t getThreadId() + current_tid = syscall(SYS_gettid); /// This call is always successful. - man gettid + #elif defined(OS_FREEBSD) + current_tid = pthread_getthreadid_np(); ++#elif defined(OS_SUNOS) ++ // XXX: Is this required to be globally unique on the system? Or only within a process? ++ // A method to achieve the latter could be to mask together the PID and thread ID. ++ current_tid = static_cast(pthread_self()); + #else + if (0 != pthread_threadid_np(nullptr, ¤t_tid)) + throw std::logic_error("pthread_threadid_np returned error"); diff --git a/clickhouse/patches/clickhouse-02.patch b/clickhouse/patches/clickhouse-02.patch new file mode 100644 index 0000000..290bd82 --- /dev/null +++ b/clickhouse/patches/clickhouse-02.patch @@ -0,0 +1,13 @@ +diff --git a/base/common/time.h b/base/common/time.h +index 1bf588b..dd946a4 100644 +--- a/base/common/time.h ++++ b/base/common/time.h +@@ -2,7 +2,7 @@ + + #include + +-#if defined (OS_DARWIN) ++#if defined (OS_DARWIN) || defined(OS_SUNOS) + # define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC + #elif defined (OS_FREEBSD) + # define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST diff --git a/clickhouse/patches/clickhouse-03.patch b/clickhouse/patches/clickhouse-03.patch new file mode 100644 index 0000000..0d4be8f --- /dev/null +++ b/clickhouse/patches/clickhouse-03.patch @@ -0,0 +1,31 @@ +diff --git a/base/pcg-random/pcg_random.hpp b/base/pcg-random/pcg_random.hpp +index abf83a6..b7145e2 100644 +--- a/base/pcg-random/pcg_random.hpp ++++ b/base/pcg-random/pcg_random.hpp +@@ -1643,22 +1643,22 @@ typedef setseq_base + + template +-using ext_std8 = extended; + + template +-using ext_std16 = extended; + + template +-using ext_std32 = extended; + + template +-using ext_std64 = extended; + + diff --git a/clickhouse/patches/clickhouse-04.patch b/clickhouse/patches/clickhouse-04.patch new file mode 100644 index 0000000..40bce15 --- /dev/null +++ b/clickhouse/patches/clickhouse-04.patch @@ -0,0 +1,15 @@ +diff --git a/cmake/target.cmake b/cmake/target.cmake +index 7174ca3..d1a0b8f 100644 +--- a/cmake/target.cmake ++++ b/cmake/target.cmake +@@ -12,6 +12,9 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") + set (OS_DARWIN 1) + add_definitions(-D OS_DARWIN) ++elseif (CMAKE_SYSTEM_NAME MATCHES "SunOS") ++ set (OS_SUNOS 1) ++ add_definitions(-D OS_SUNOS) + endif () + + if (CMAKE_CROSSCOMPILING) +Submodule contrib/NuRaft contains modified content diff --git a/clickhouse/patches/clickhouse-05.patch b/clickhouse/patches/clickhouse-05.patch new file mode 100644 index 0000000..eb49904 --- /dev/null +++ b/clickhouse/patches/clickhouse-05.patch @@ -0,0 +1,13 @@ +diff --git a/contrib/NuRaft/include/libnuraft/attr_unused.hxx b/contrib/NuRaft/include/libnuraft/attr_unused.hxx +index 80c91bb..611bb30 100644 +--- a/contrib/NuRaft/include/libnuraft/attr_unused.hxx ++++ b/contrib/NuRaft/include/libnuraft/attr_unused.hxx +@@ -18,7 +18,7 @@ limitations under the License. + #pragma once + + #ifndef ATTR_UNUSED +-#if defined(__linux__) || defined(__APPLE__) ++#if defined(__linux__) || defined(__APPLE__) || defined(__sun) + #define ATTR_UNUSED __attribute__((unused)) + #elif defined(WIN32) || defined(_WIN32) + #define ATTR_UNUSED diff --git a/clickhouse/patches/clickhouse-06.patch b/clickhouse/patches/clickhouse-06.patch new file mode 100644 index 0000000..f4347d2 --- /dev/null +++ b/clickhouse/patches/clickhouse-06.patch @@ -0,0 +1,14 @@ +diff --git a/contrib/NuRaft/src/crc32.hxx b/contrib/NuRaft/src/crc32.hxx +index 938cf8d..b704467 100644 +--- a/contrib/NuRaft/src/crc32.hxx ++++ b/contrib/NuRaft/src/crc32.hxx +@@ -22,7 +22,7 @@ limitations under the License. + #define _JSAHN_CRC32_H + + #include +-#if defined(__linux__) || defined(__APPLE__) ++#if defined(__linux__) || defined(__APPLE__) || defined(__sun) + #include + #endif + +Submodule contrib/abseil-cpp contains modified content diff --git a/clickhouse/patches/clickhouse-07.patch b/clickhouse/patches/clickhouse-07.patch new file mode 100644 index 0000000..1902b55 --- /dev/null +++ b/clickhouse/patches/clickhouse-07.patch @@ -0,0 +1,10 @@ +diff --git a/contrib/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake b/contrib/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake +index 77d4ace..6972e7e 100644 +--- a/contrib/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake ++++ b/contrib/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake +@@ -72,3 +72,4 @@ elseif(NOT "${CMAKE_CXX_STANDARD}") + else() + set(ABSL_CXX_STANDARD "${CMAKE_CXX_STANDARD}") + endif() ++set(ABSL_CXX_STANDARD 17) +Submodule contrib/boost contains modified content diff --git a/clickhouse/patches/clickhouse-08.patch b/clickhouse/patches/clickhouse-08.patch new file mode 100644 index 0000000..f88ed29 --- /dev/null +++ b/clickhouse/patches/clickhouse-08.patch @@ -0,0 +1,13 @@ +diff --git a/contrib/boost/boost/system/detail/std_interoperability.hpp b/contrib/boost/boost/system/detail/std_interoperability.hpp +index 5a4e7b1..96b6043 100644 +--- a/contrib/boost/boost/system/detail/std_interoperability.hpp ++++ b/contrib/boost/boost/system/detail/std_interoperability.hpp +@@ -10,6 +10,7 @@ + #include + #include + #include ++#include + + // + +Submodule contrib/boringssl contains modified content diff --git a/clickhouse/patches/clickhouse-09.patch b/clickhouse/patches/clickhouse-09.patch new file mode 100644 index 0000000..ab14505 --- /dev/null +++ b/clickhouse/patches/clickhouse-09.patch @@ -0,0 +1,13 @@ +diff --git a/contrib/boringssl/include/openssl/thread.h b/contrib/boringssl/include/openssl/thread.h +index 91706fec2..ce28d78b2 100644 +--- a/contrib/boringssl/include/openssl/thread.h ++++ b/contrib/boringssl/include/openssl/thread.h +@@ -77,7 +77,7 @@ typedef struct crypto_mutex_st { + typedef union crypto_mutex_st { + void *handle; + } CRYPTO_MUTEX; +-#elif defined(__MACH__) && defined(__APPLE__) ++#elif (defined(__MACH__) && defined(__APPLE__)) || (defined(__sun)) + typedef pthread_rwlock_t CRYPTO_MUTEX; + #else + // It is reasonable to include pthread.h on non-Windows systems, however the diff --git a/clickhouse/patches/clickhouse-10.patch b/clickhouse/patches/clickhouse-10.patch new file mode 100644 index 0000000..0673711 --- /dev/null +++ b/clickhouse/patches/clickhouse-10.patch @@ -0,0 +1,18 @@ +diff --git a/contrib/boringssl-cmake/CMakeLists.txt b/contrib/boringssl-cmake/CMakeLists.txt +index 017a8a6..7e68e7c 100644 +--- a/contrib/boringssl-cmake/CMakeLists.txt ++++ b/contrib/boringssl-cmake/CMakeLists.txt +@@ -78,7 +78,11 @@ elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") + elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") + set(ARCH "x86") + elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386") +- set(ARCH "x86") ++ if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") ++ set(ARCH "x86_64") ++ else() ++ set(ARCH "x86") ++ endif() + elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686") + set(ARCH "x86") + elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") +Submodule contrib/cppkafka contains modified content diff --git a/clickhouse/patches/clickhouse-11.patch b/clickhouse/patches/clickhouse-11.patch new file mode 100644 index 0000000..ae4b594 --- /dev/null +++ b/clickhouse/patches/clickhouse-11.patch @@ -0,0 +1,16 @@ +diff --git a/contrib/cppkafka/include/cppkafka/detail/endianness.h b/contrib/cppkafka/include/cppkafka/detail/endianness.h +index 21594c1..b12540a 100644 +--- a/contrib/cppkafka/include/cppkafka/detail/endianness.h ++++ b/contrib/cppkafka/include/cppkafka/detail/endianness.h +@@ -109,6 +109,10 @@ + # define __LITTLE_ENDIAN LITTLE_ENDIAN + # define __PDP_ENDIAN PDP_ENDIAN + ++#elif defined(__sun) ++ ++# include ++ + #else + + # error platform not supported +Submodule contrib/grpc contains modified content diff --git a/clickhouse/patches/clickhouse-12.patch b/clickhouse/patches/clickhouse-12.patch new file mode 100644 index 0000000..a88f12c --- /dev/null +++ b/clickhouse/patches/clickhouse-12.patch @@ -0,0 +1,31 @@ +diff --git a/contrib/grpc/include/grpcpp/impl/codegen/rpc_service_method.h b/contrib/grpc/include/grpcpp/impl/codegen/rpc_service_method.h +index 4fcc211243..b3f3b5d22d 100644 +--- a/contrib/grpc/include/grpcpp/impl/codegen/rpc_service_method.h ++++ b/contrib/grpc/include/grpcpp/impl/codegen/rpc_service_method.h +@@ -94,7 +94,7 @@ class RpcServiceMethod : public RpcMethod { + enum class ApiType { + SYNC, + ASYNC, +- RAW, ++ RAW_, // illumos defines RAW as an alias of O_RAW, in sys/ioctl.h + CALL_BACK, // not CALLBACK because that is reserved in Windows + RAW_CALL_BACK, + }; +@@ -107,7 +107,7 @@ class RpcServiceMethod : public RpcMethod { + void SetHandler(MethodHandler* handler) { handler_.reset(handler); } + void SetServerApiType(RpcServiceMethod::ApiType type) { + if ((api_type_ == ApiType::SYNC) && +- (type == ApiType::ASYNC || type == ApiType::RAW)) { ++ (type == ApiType::ASYNC || type == ApiType::RAW_)) { + // this marks this method as async + handler_.reset(); + } else if (api_type_ != ApiType::SYNC) { +@@ -135,7 +135,7 @@ class RpcServiceMethod : public RpcMethod { + return "sync"; + case ApiType::ASYNC: + return "async"; +- case ApiType::RAW: ++ case ApiType::RAW_: + return "raw"; + case ApiType::CALL_BACK: + return "callback"; diff --git a/clickhouse/patches/clickhouse-13.patch b/clickhouse/patches/clickhouse-13.patch new file mode 100644 index 0000000..963482d --- /dev/null +++ b/clickhouse/patches/clickhouse-13.patch @@ -0,0 +1,13 @@ +diff --git a/contrib/grpc/include/grpcpp/impl/codegen/service_type.h b/contrib/grpc/include/grpcpp/impl/codegen/service_type.h +index 30be904a3c..9f53537afe 100644 +--- a/contrib/grpc/include/grpcpp/impl/codegen/service_type.h ++++ b/contrib/grpc/include/grpcpp/impl/codegen/service_type.h +@@ -187,7 +187,7 @@ class Service { + GPR_CODEGEN_ASSERT(methods_[idx].get() != nullptr && + "Cannot mark the method as 'raw' because it has already " + "been marked as 'generic'."); +- methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::RAW); ++ methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::RAW_); + } + + void MarkMethodGeneric(int index) { diff --git a/clickhouse/patches/clickhouse-14.patch b/clickhouse/patches/clickhouse-14.patch new file mode 100644 index 0000000..dd07cf7 --- /dev/null +++ b/clickhouse/patches/clickhouse-14.patch @@ -0,0 +1,19 @@ +diff --git a/contrib/grpc/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc b/contrib/grpc/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +index 6659dc157b..8db2b8ad69 100644 +--- a/contrib/grpc/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc ++++ b/contrib/grpc/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +@@ -22,7 +22,12 @@ + + #include + #include +-#include ++#if defined(__sun) ++# include ++# include ++#else ++# include ++#endif + + #include "absl/strings/str_cat.h" + +Submodule contrib/librdkafka contains modified content diff --git a/clickhouse/patches/clickhouse-15.patch b/clickhouse/patches/clickhouse-15.patch new file mode 100644 index 0000000..5a1692d --- /dev/null +++ b/clickhouse/patches/clickhouse-15.patch @@ -0,0 +1,34 @@ +diff --git a/contrib/librdkafka/src/rdkafka.c b/contrib/librdkafka/src/rdkafka.c +index 06244b01..f694d967 100644 +--- a/contrib/librdkafka/src/rdkafka.c ++++ b/contrib/librdkafka/src/rdkafka.c +@@ -4733,6 +4733,10 @@ rd_bool_t rd_kafka_dir_is_empty (const char *path) { + #else + DIR *dir; + struct dirent *d; ++#if defined(__sun) ++ struct stat st; ++ int ret = 0; ++#endif + + dir = opendir(path); + if (!dir) +@@ -4744,8 +4748,17 @@ rd_bool_t rd_kafka_dir_is_empty (const char *path) { + !strcmp(d->d_name, "..")) + continue; + ++#if defined(__sun) ++ ret = stat(d->d_name, &st); ++ if (ret != 0) { ++ return rd_true; // Cannot be accessed ++ } ++ if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode) || ++ S_ISLNK(st.st_mode)) { ++#else + if (d->d_type == DT_REG || d->d_type == DT_LNK || + d->d_type == DT_DIR) { ++#endif + closedir(dir); + return rd_false; + } +Submodule contrib/miniselect contains modified content diff --git a/clickhouse/patches/clickhouse-16.patch b/clickhouse/patches/clickhouse-16.patch new file mode 100644 index 0000000..57d87f5 --- /dev/null +++ b/clickhouse/patches/clickhouse-16.patch @@ -0,0 +1,14 @@ +diff --git a/contrib/miniselect/include/miniselect/floyd_rivest_select.h b/contrib/miniselect/include/miniselect/floyd_rivest_select.h +index e7d5f80..fb643d6 100644 +--- a/contrib/miniselect/include/miniselect/floyd_rivest_select.h ++++ b/contrib/miniselect/include/miniselect/floyd_rivest_select.h +@@ -31,7 +31,7 @@ inline void floyd_rivest_select_loop(Iter begin, Diff left, Diff right, Diff k, + if (size > 600) { + Diff n = right - left + 1; + Diff i = k - left + 1; +- double z = log(n); ++ double z = log(static_cast(n)); + double s = 0.5 * exp(2 * z / 3); + double sd = 0.5 * sqrt(z * s * (n - s) / n); + if (i < n / 2) { +Submodule contrib/poco contains modified content diff --git a/clickhouse/patches/clickhouse-17.patch b/clickhouse/patches/clickhouse-17.patch new file mode 100644 index 0000000..0f77357 --- /dev/null +++ b/clickhouse/patches/clickhouse-17.patch @@ -0,0 +1,12 @@ +diff --git a/contrib/poco/Net/src/PollSet.cpp b/contrib/poco/Net/src/PollSet.cpp +index 57d481d23..ee179127c 100644 +--- a/contrib/poco/Net/src/PollSet.cpp ++++ b/contrib/poco/Net/src/PollSet.cpp +@@ -16,6 +16,7 @@ + #include "Poco/Net/SocketImpl.h" + #include "Poco/Mutex.h" + #include ++#include + + + #if defined(_WIN32) && _WIN32_WINNT >= 0x0600 diff --git a/clickhouse/patches/clickhouse-18.patch b/clickhouse/patches/clickhouse-18.patch new file mode 100644 index 0000000..fadd966 --- /dev/null +++ b/clickhouse/patches/clickhouse-18.patch @@ -0,0 +1,16 @@ +diff --git a/contrib/poco-cmake/Net/CMakeLists.txt b/contrib/poco-cmake/Net/CMakeLists.txt +index 9bc06e5..dd6894f 100644 +--- a/contrib/poco-cmake/Net/CMakeLists.txt ++++ b/contrib/poco-cmake/Net/CMakeLists.txt +@@ -127,6 +127,10 @@ if (USE_INTERNAL_POCO_LIBRARY) + ) + target_include_directories (_poco_net SYSTEM PUBLIC ${LIBRARY_DIR}/Net/include) + target_link_libraries (_poco_net PUBLIC Poco::Foundation) ++ ++ if (OS_SUNOS) ++ target_link_libraries (_poco_net PUBLIC socket nsl) ++ endif() + else () + add_library (Poco::Net UNKNOWN IMPORTED GLOBAL) + +Submodule contrib/rocksdb contains modified content diff --git a/clickhouse/patches/clickhouse-19.patch b/clickhouse/patches/clickhouse-19.patch new file mode 100644 index 0000000..7a83338 --- /dev/null +++ b/clickhouse/patches/clickhouse-19.patch @@ -0,0 +1,13 @@ +diff --git a/contrib/rocksdb/monitoring/perf_context.cc b/contrib/rocksdb/monitoring/perf_context.cc +index 53f502405..07dfa2b89 100644 +--- a/contrib/rocksdb/monitoring/perf_context.cc ++++ b/contrib/rocksdb/monitoring/perf_context.cc +@@ -13,7 +13,7 @@ namespace ROCKSDB_NAMESPACE { + PerfContext perf_context; + #else + #if defined(OS_SOLARIS) +-__thread PerfContext perf_context_; ++thread_local PerfContext perf_context_; + #else + thread_local PerfContext perf_context; + #endif diff --git a/clickhouse/patches/clickhouse-20.patch b/clickhouse/patches/clickhouse-20.patch new file mode 100644 index 0000000..876c932 --- /dev/null +++ b/clickhouse/patches/clickhouse-20.patch @@ -0,0 +1,24 @@ +diff --git a/contrib/rocksdb/util/xxh3p.h b/contrib/rocksdb/util/xxh3p.h +index 05696cecd..3a883f422 100644 +--- a/contrib/rocksdb/util/xxh3p.h ++++ b/contrib/rocksdb/util/xxh3p.h +@@ -61,11 +61,15 @@ + + /* === Compiler specifics === */ + +-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* >= C99 */ +-# define XXH_RESTRICT restrict ++#if defined(__cplusplus) ++# define XXH_RESTRICT __restrict__ + #else ++# if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* >= C99 */ ++# define XXH_RESTRICT restrict ++# else + /* note : it might be useful to define __restrict or __restrict__ for some C++ compilers */ +-# define XXH_RESTRICT /* disable */ ++# define XXH_RESTRICT /* disable */ ++# endif + #endif + + #if defined(__GNUC__) +Submodule contrib/thrift contains modified content diff --git a/clickhouse/patches/clickhouse-21.patch b/clickhouse/patches/clickhouse-21.patch new file mode 100644 index 0000000..8eebc5b --- /dev/null +++ b/clickhouse/patches/clickhouse-21.patch @@ -0,0 +1,12 @@ +diff --git a/contrib/thrift/lib/cpp/src/thrift/transport/TSocket.cpp b/contrib/thrift/lib/cpp/src/thrift/transport/TSocket.cpp +index c6c2bfa00..ca6759b95 100644 +--- a/contrib/thrift/lib/cpp/src/thrift/transport/TSocket.cpp ++++ b/contrib/thrift/lib/cpp/src/thrift/transport/TSocket.cpp +@@ -23,6 +23,7 @@ + #include + #ifdef HAVE_SYS_IOCTL_H + #include ++#include + #endif + #ifdef HAVE_SYS_SOCKET_H + #include diff --git a/clickhouse/patches/clickhouse-22.patch b/clickhouse/patches/clickhouse-22.patch new file mode 100644 index 0000000..f759a4b --- /dev/null +++ b/clickhouse/patches/clickhouse-22.patch @@ -0,0 +1,15 @@ +diff --git a/programs/install/Install.cpp b/programs/install/Install.cpp +index ef72624..ce755c5 100644 +--- a/programs/install/Install.cpp ++++ b/programs/install/Install.cpp +@@ -830,8 +830,8 @@ namespace + fmt::print("The pidof command returned unusual output.\n"); + } + +- WriteBufferFromFileDescriptor stderr(STDERR_FILENO); +- copyData(sh->err, stderr); ++ WriteBufferFromFileDescriptor std_err(STDERR_FILENO); ++ copyData(sh->err, std_err); + + sh->tryWait(); + } diff --git a/clickhouse/patches/clickhouse-23.patch b/clickhouse/patches/clickhouse-23.patch new file mode 100644 index 0000000..314e8ea --- /dev/null +++ b/clickhouse/patches/clickhouse-23.patch @@ -0,0 +1,58 @@ +diff --git a/src/AggregateFunctions/QuantileExact.h b/src/AggregateFunctions/QuantileExact.h +index aa7b4bb..7eab35a 100644 +--- a/src/AggregateFunctions/QuantileExact.h ++++ b/src/AggregateFunctions/QuantileExact.h +@@ -8,7 +8,6 @@ + #include + #include + +- + namespace DB + { + +@@ -271,11 +270,11 @@ struct QuantileExactLow : public QuantileExactBase(floor(s / 2))]; ++ return array[static_cast(static_cast(floor(static_cast(s / 2))))]; + } + else + { +- return array[static_cast((floor(s / 2)) - 1)]; ++ return array[static_cast((floor(static_cast(s / 2))) - 1)]; + } + } + // else quantile is the nth index of the sorted array obtained by multiplying +@@ -303,11 +302,11 @@ struct QuantileExactLow : public QuantileExactBase(floor(s / 2))]; ++ result[indices[i]] = array[static_cast(floor(static_cast(s / 2)))]; + } + else + { +- result[indices[i]] = array[static_cast(floor((s / 2) - 1))]; ++ result[indices[i]] = array[static_cast(floor(static_cast((s / 2) - 1)))]; + } + } + // else quantile is the nth index of the sorted array obtained by multiplying +@@ -343,7 +342,7 @@ struct QuantileExactHigh : public QuantileExactBase(floor(s / 2))]; ++ return array[static_cast(floor(static_cast(s / 2)))]; + } + // else quantile is the nth index of the sorted array obtained by multiplying + // level and size of array. Example if level = 0.1 and size of array is 10. +@@ -367,7 +366,7 @@ struct QuantileExactHigh : public QuantileExactBase(floor(s / 2))]; ++ result[indices[i]] = array[static_cast(floor(static_cast(s / 2)))]; + } + // else quantile is the nth index of the sorted array obtained by multiplying + // level and size of array. Example if level = 0.1 and size of array is 10. diff --git a/clickhouse/patches/clickhouse-24.patch b/clickhouse/patches/clickhouse-24.patch new file mode 100644 index 0000000..179428c --- /dev/null +++ b/clickhouse/patches/clickhouse-24.patch @@ -0,0 +1,13 @@ +diff --git a/src/Common/Config/ConfigProcessor.cpp b/src/Common/Config/ConfigProcessor.cpp +index 5399826..39ab407 100644 +--- a/src/Common/Config/ConfigProcessor.cpp ++++ b/src/Common/Config/ConfigProcessor.cpp +@@ -234,7 +234,7 @@ void ConfigProcessor::merge(XMLDocumentPtr config, XMLDocumentPtr with) + + static std::string layerFromHost() + { +- utsname buf; ++ struct utsname buf; + if (uname(&buf)) + throw Poco::Exception(std::string("uname failed: ") + errnoToString(errno)); + diff --git a/clickhouse/patches/clickhouse-25.patch b/clickhouse/patches/clickhouse-25.patch new file mode 100644 index 0000000..ccb4ace --- /dev/null +++ b/clickhouse/patches/clickhouse-25.patch @@ -0,0 +1,29 @@ +diff --git a/src/Common/Elf.cpp b/src/Common/Elf.cpp +index ee78c98..a11a0fb 100644 +--- a/src/Common/Elf.cpp ++++ b/src/Common/Elf.cpp +@@ -129,9 +129,15 @@ String Elf::getBuildID() const + return {}; + } + +- ++#if defined(OS_SUNOS) ++String Elf::getBuildID(const char*, size_t) ++{ ++ return {}; ++} ++#else + String Elf::getBuildID(const char * nhdr_pos, size_t size) + { ++ + const char * nhdr_end = nhdr_pos + size; + + while (nhdr_pos < nhdr_end) +@@ -149,6 +155,7 @@ String Elf::getBuildID(const char * nhdr_pos, size_t size) + + return {}; + } ++#endif + + + String Elf::getBinaryHash() const diff --git a/clickhouse/patches/clickhouse-26.patch b/clickhouse/patches/clickhouse-26.patch new file mode 100644 index 0000000..bfa6e59 --- /dev/null +++ b/clickhouse/patches/clickhouse-26.patch @@ -0,0 +1,12 @@ +diff --git a/src/Common/OpenTelemetryTraceContext.h b/src/Common/OpenTelemetryTraceContext.h +index fe88981..c88003b 100644 +--- a/src/Common/OpenTelemetryTraceContext.h ++++ b/src/Common/OpenTelemetryTraceContext.h +@@ -11,6 +11,7 @@ struct OpenTelemetryTraceContext + // The incoming tracestate header and the trace flags, we just pass them + // downstream. See https://www.w3.org/TR/trace-context/ + String tracestate; ++ typedef uint8_t __uint8_t; + __uint8_t trace_flags = 0; + + // Parse/compose OpenTelemetry traceparent header. diff --git a/clickhouse/patches/clickhouse-27.patch b/clickhouse/patches/clickhouse-27.patch new file mode 100644 index 0000000..e185a03 --- /dev/null +++ b/clickhouse/patches/clickhouse-27.patch @@ -0,0 +1,16 @@ +diff --git a/src/Common/Stopwatch.cpp b/src/Common/Stopwatch.cpp +index d792e05..7d48065 100644 +--- a/src/Common/Stopwatch.cpp ++++ b/src/Common/Stopwatch.cpp +@@ -7,7 +7,11 @@ StopwatchRUsage::Timestamp StopwatchRUsage::Timestamp::current() + + ::rusage rusage {}; + #if !defined(__APPLE__) ++#if defined(OS_SUNOS) ++ ::getrusage(RUSAGE_LWP, &rusage); ++#else + ::getrusage(RUSAGE_THREAD, &rusage); ++#endif + #endif + res.user_ns = rusage.ru_utime.tv_sec * 1000000000UL + rusage.ru_utime.tv_usec * 1000UL; + res.sys_ns = rusage.ru_stime.tv_sec * 1000000000UL + rusage.ru_stime.tv_usec * 1000UL; diff --git a/clickhouse/patches/clickhouse-28.patch b/clickhouse/patches/clickhouse-28.patch new file mode 100644 index 0000000..e192356 --- /dev/null +++ b/clickhouse/patches/clickhouse-28.patch @@ -0,0 +1,16 @@ +diff --git a/src/Common/ThreadProfileEvents.h b/src/Common/ThreadProfileEvents.h +index d96339a..c43102d 100644 +--- a/src/Common/ThreadProfileEvents.h ++++ b/src/Common/ThreadProfileEvents.h +@@ -105,7 +105,11 @@ struct RUsageCounters + { + ::rusage rusage {}; + #if !defined(__APPLE__) ++#if defined(OS_SUNOS) ++ ::getrusage(RUSAGE_LWP, &rusage); ++#else + ::getrusage(RUSAGE_THREAD, &rusage); ++#endif + #endif + return RUsageCounters(rusage, getClockMonotonic()); + } diff --git a/clickhouse/patches/clickhouse-29.patch b/clickhouse/patches/clickhouse-29.patch new file mode 100644 index 0000000..155c4c5 --- /dev/null +++ b/clickhouse/patches/clickhouse-29.patch @@ -0,0 +1,13 @@ +diff --git a/src/Common/checkStackSize.cpp b/src/Common/checkStackSize.cpp +index e94abc0..54ffab7 100644 +--- a/src/Common/checkStackSize.cpp ++++ b/src/Common/checkStackSize.cpp +@@ -49,7 +49,7 @@ __attribute__((__weak__)) void checkStackSize() + stack_address = reinterpret_cast(reinterpret_cast(pthread_get_stackaddr_np(thread)) - max_stack_size); + #else + pthread_attr_t attr; +-# if defined(__FreeBSD__) ++# if defined(__FreeBSD__) || defined(OS_SUNOS) + pthread_attr_init(&attr); + if (0 != pthread_attr_get_np(pthread_self(), &attr)) + throwFromErrno("Cannot pthread_attr_get_np", ErrorCodes::CANNOT_PTHREAD_ATTR); diff --git a/clickhouse/patches/clickhouse-30.patch b/clickhouse/patches/clickhouse-30.patch new file mode 100644 index 0000000..9485699 --- /dev/null +++ b/clickhouse/patches/clickhouse-30.patch @@ -0,0 +1,30 @@ +diff --git a/src/Common/setThreadName.cpp b/src/Common/setThreadName.cpp +index 3c20711..9e45c62 100644 +--- a/src/Common/setThreadName.cpp ++++ b/src/Common/setThreadName.cpp +@@ -1,6 +1,6 @@ + #include + +-#if defined(__APPLE__) ++#if defined(__APPLE__) || defined(OS_SUNOS) + #elif defined(__FreeBSD__) + #include + #else +@@ -34,6 +34,8 @@ void setThreadName(const char * name) + if ((false)) + #elif defined(OS_DARWIN) + if (0 != pthread_setname_np(name)) ++#elif defined(OS_SUNOS) ++ if (0 != pthread_setname_np(pthread_self(), name)) + #else + if (0 != prctl(PR_SET_NAME, name, 0, 0, 0)) + #endif +@@ -44,7 +46,7 @@ std::string getThreadName() + { + std::string name(16, '\0'); + +-#if defined(__APPLE__) ++#if defined(__APPLE__) || defined(OS_SUNOS) + if (pthread_getname_np(pthread_self(), name.data(), name.size())) + throw DB::Exception("Cannot get thread name with pthread_getname_np()", DB::ErrorCodes::PTHREAD_ERROR); + #elif defined(__FreeBSD__) diff --git a/clickhouse/patches/clickhouse-31.patch b/clickhouse/patches/clickhouse-31.patch new file mode 100644 index 0000000..3f4d412 --- /dev/null +++ b/clickhouse/patches/clickhouse-31.patch @@ -0,0 +1,13 @@ +diff --git a/src/Functions/PerformanceAdaptors.h b/src/Functions/PerformanceAdaptors.h +index 5d4d013..716bb65 100644 +--- a/src/Functions/PerformanceAdaptors.h ++++ b/src/Functions/PerformanceAdaptors.h +@@ -99,7 +99,7 @@ namespace detail + /// when there is no statistical significant difference between them. + double sigma() const + { +- return mean() / sqrt(adjustedCount()); ++ return mean() / sqrt(static_cast(adjustedCount())); + } + + void run() diff --git a/clickhouse/patches/clickhouse-32.patch b/clickhouse/patches/clickhouse-32.patch new file mode 100644 index 0000000..6fd8097 --- /dev/null +++ b/clickhouse/patches/clickhouse-32.patch @@ -0,0 +1,13 @@ +diff --git a/src/IO/BitHelpers.h b/src/IO/BitHelpers.h +index 0e2a08a..1cb62f5 100644 +--- a/src/IO/BitHelpers.h ++++ b/src/IO/BitHelpers.h +@@ -9,6 +9,8 @@ + + #if defined(__OpenBSD__) || defined(__FreeBSD__) || defined (__ANDROID__) + # include ++#elif defined(__sun) ++# include + #elif defined(__APPLE__) + # include + diff --git a/clickhouse/patches/clickhouse-33.patch b/clickhouse/patches/clickhouse-33.patch new file mode 100644 index 0000000..5bc0a32 --- /dev/null +++ b/clickhouse/patches/clickhouse-33.patch @@ -0,0 +1,20 @@ +diff --git a/src/Processors/Formats/Impl/VerticalRowOutputFormat.cpp b/src/Processors/Formats/Impl/VerticalRowOutputFormat.cpp +index c6f37d2..8d292b2 100644 +--- a/src/Processors/Formats/Impl/VerticalRowOutputFormat.cpp ++++ b/src/Processors/Formats/Impl/VerticalRowOutputFormat.cpp +@@ -80,7 +80,14 @@ void VerticalRowOutputFormat::writeRowStartDelimiter() + writeIntText(row_number, out); + writeCString(":\n", out); + +- size_t width = log10(row_number + 1) + 1 + strlen("Row :"); ++ size_t width = ( ++#if defined(OS_SUNOS) ++ static_cast(std::log10(static_cast(row_number + 1))) ++#else ++ log10(row_number + 1) ++#endif ++ + 1 + strlen("Row :") ++ ); + for (size_t i = 0; i < width; ++i) + writeCString("─", out); + writeChar('\n', out); diff --git a/clickhouse/patches/clickhouse-34.patch b/clickhouse/patches/clickhouse-34.patch new file mode 100644 index 0000000..c2b6601 --- /dev/null +++ b/clickhouse/patches/clickhouse-34.patch @@ -0,0 +1,15 @@ +diff --git a/src/Storages/MergeTree/SimpleMergeSelector.cpp b/src/Storages/MergeTree/SimpleMergeSelector.cpp +index 972c6ea..b39a6ec 100644 +--- a/src/Storages/MergeTree/SimpleMergeSelector.cpp ++++ b/src/Storages/MergeTree/SimpleMergeSelector.cpp +@@ -205,8 +205,8 @@ SimpleMergeSelector::PartsRange SimpleMergeSelector::select( + Estimator estimator; + + /// Precompute logarithm of settings boundaries, because log function is quite expensive in terms of performance +- const double min_size_to_lower_base_log = log(1 + settings.min_size_to_lower_base); +- const double max_size_to_lower_base_log = log(1 + settings.max_size_to_lower_base); ++ const double min_size_to_lower_base_log = log(static_cast(1 + settings.min_size_to_lower_base)); ++ const double max_size_to_lower_base_log = log(static_cast(1 + settings.max_size_to_lower_base)); + + for (const auto & part_range : parts_ranges) + selectWithinPartition(part_range, max_total_size_to_merge, estimator, settings, min_size_to_lower_base_log, max_size_to_lower_base_log); diff --git a/clickhouse/patches/clickhouse-35.patch b/clickhouse/patches/clickhouse-35.patch new file mode 100644 index 0000000..1bb5773 --- /dev/null +++ b/clickhouse/patches/clickhouse-35.patch @@ -0,0 +1,11 @@ +diff --git a/src/Storages/PostgreSQL/PostgreSQLPoolWithFailover.h b/src/Storages/PostgreSQL/PostgreSQLPoolWithFailover.h +index 8f6027c..048200f 100644 +--- a/src/Storages/PostgreSQL/PostgreSQLPoolWithFailover.h ++++ b/src/Storages/PostgreSQL/PostgreSQLPoolWithFailover.h +@@ -1,5 +1,6 @@ + #pragma once + ++#include + #include + #include + #include "PostgreSQLConnectionPool.h" diff --git a/clickhouse/patches/clickhouse-36.patch b/clickhouse/patches/clickhouse-36.patch new file mode 100644 index 0000000..5940143 --- /dev/null +++ b/clickhouse/patches/clickhouse-36.patch @@ -0,0 +1,15 @@ +diff --git a/utils/memcpy-bench/CMakeLists.txt b/utils/memcpy-bench/CMakeLists.txt +index 5fcde23..5353b6f 100644 +--- a/utils/memcpy-bench/CMakeLists.txt ++++ b/utils/memcpy-bench/CMakeLists.txt +@@ -15,6 +15,10 @@ add_executable (memcpy-bench + + add_compile_options(memcpy-bench PRIVATE -fno-tree-loop-distribute-patterns) + ++if (OS_SUNOS) ++ target_compile_options(memcpy-bench PRIVATE "-Wa,--divide") ++endif() ++ + set_source_files_properties(FastMemcpy.cpp PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") + set_source_files_properties(FastMemcpy_Avx.cpp PROPERTIES COMPILE_FLAGS "-mavx -Wno-old-style-cast -Wno-cast-qual -Wno-cast-align") + diff --git a/clickhouse/patches/clickhouse-37.patch b/clickhouse/patches/clickhouse-37.patch new file mode 100644 index 0000000..125ada1 --- /dev/null +++ b/clickhouse/patches/clickhouse-37.patch @@ -0,0 +1,13 @@ +diff --git a/contrib/zlib-ng/zutil_p.h b/contrib/zlib-ng/zutil_p.h +index 7dc2e3d..2a748df 100644 +--- a/contrib/zlib-ng/zutil_p.h ++++ b/contrib/zlib-ng/zutil_p.h +@@ -10,6 +10,8 @@ + #elif defined(__FreeBSD__) + # include + # include ++#elif defined(__sun) ++# include + #else + # include + #endif diff --git a/clickhouse/patches/clickhouse-38.patch b/clickhouse/patches/clickhouse-38.patch new file mode 100644 index 0000000..3ebe312 --- /dev/null +++ b/clickhouse/patches/clickhouse-38.patch @@ -0,0 +1,12 @@ +diff --git a/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp b/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp +index 0825d9f329..8e178b6629 100644 +--- a/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp ++++ b/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp +@@ -1,4 +1,7 @@ + #include ++#if defined(OS_SUNOS) ++# include ++#endif + #include + #include + #include diff --git a/clickhouse/patches/clickhouse-39.patch b/clickhouse/patches/clickhouse-39.patch new file mode 100644 index 0000000..77186b9 --- /dev/null +++ b/clickhouse/patches/clickhouse-39.patch @@ -0,0 +1,22 @@ +diff --git a/src/Common/TerminalSize.cpp b/src/Common/TerminalSize.cpp +index 714a19b188..a020098aa4 100644 +--- a/src/Common/TerminalSize.cpp ++++ b/src/Common/TerminalSize.cpp +@@ -1,5 +1,8 @@ + #include + #include ++#if defined(OS_SUNOS) ++# include ++#endif + #include + #include + #include +@@ -14,7 +17,7 @@ uint16_t getTerminalWidth() + { + if (isatty(STDIN_FILENO)) + { +- winsize terminal_size {}; ++ struct winsize terminal_size {}; + + if (ioctl(STDIN_FILENO, TIOCGWINSZ, &terminal_size)) + DB::throwFromErrno("Cannot obtain terminal window size (ioctl TIOCGWINSZ)", DB::ErrorCodes::SYSTEM_ERROR); diff --git a/clickhouse/patches/clickhouse-40.patch b/clickhouse/patches/clickhouse-40.patch new file mode 100644 index 0000000..b5c3efe --- /dev/null +++ b/clickhouse/patches/clickhouse-40.patch @@ -0,0 +1,17 @@ +diff --git a/src/Common/tests/symbol_index.cpp b/src/Common/tests/symbol_index.cpp +index 496fa7dc3f..dd86268b0e 100644 +--- a/src/Common/tests/symbol_index.cpp ++++ b/src/Common/tests/symbol_index.cpp +@@ -32,7 +32,12 @@ int main(int argc, char ** argv) + std::cout << elem.name << ": " << elem.address_begin << " ... " << elem.address_end << "\n"; + std::cout << "\n"; + ++#if defined(OS_SUNOS) ++ // SunOS's dladdr accepts a `void *` as first argument, not `const void*`. ++ void * address = reinterpret_cast(std::stoull(argv[1], nullptr, 16)); ++#else + const void * address = reinterpret_cast(std::stoull(argv[1], nullptr, 16)); ++#endif + + const auto * symbol = symbol_index.findSymbol(address); + if (symbol) diff --git a/clickhouse/patches/clickhouse-41.patch b/clickhouse/patches/clickhouse-41.patch new file mode 100644 index 0000000..8d47a7f --- /dev/null +++ b/clickhouse/patches/clickhouse-41.patch @@ -0,0 +1,13 @@ +diff --git a/src/Common/tests/int_hashes_perf.cpp b/src/Common/tests/int_hashes_perf.cpp +index 543326a9e5..8a32f8f536 100644 +--- a/src/Common/tests/int_hashes_perf.cpp ++++ b/src/Common/tests/int_hashes_perf.cpp +@@ -12,7 +12,7 @@ + + static void setAffinity() + { +-#if !defined(__APPLE__) && !defined(__FreeBSD__) ++#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__sun) + cpu_set_t mask; + CPU_ZERO(&mask); + CPU_SET(0, &mask); diff --git a/clickhouse/patches/clickhouse-42.patch b/clickhouse/patches/clickhouse-42.patch new file mode 100644 index 0000000..747d6fb --- /dev/null +++ b/clickhouse/patches/clickhouse-42.patch @@ -0,0 +1,13 @@ +diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt +index 04d9a07008..f5d7d2c09c 100644 +--- a/utils/CMakeLists.txt ++++ b/utils/CMakeLists.txt +@@ -38,7 +38,7 @@ if (NOT DEFINED ENABLE_UTILS OR ENABLE_UTILS) + endif () + + # memcpy_jart.S contains position dependent code +- if (NOT CMAKE_POSITION_INDEPENDENT_CODE AND NOT OS_DARWIN) ++ if (NOT CMAKE_POSITION_INDEPENDENT_CODE AND NOT OS_DARWIN AND NOT OS_SUNOS) + add_subdirectory (memcpy-bench) + endif () + endif () diff --git a/clickhouse/patches/clickhouse-43.patch b/clickhouse/patches/clickhouse-43.patch new file mode 100644 index 0000000..52bccfd --- /dev/null +++ b/clickhouse/patches/clickhouse-43.patch @@ -0,0 +1,60 @@ +diff --git a/programs/server/config.xml b/programs/server/config.xml +index d75163ca90..5050361a6f 100644 +--- a/programs/server/config.xml ++++ b/programs/server/config.xml +@@ -22,8 +22,8 @@ + [1]: https://github.com/pocoproject/poco/blob/poco-1.9.4-release/Foundation/include/Poco/Logger.h#L105-L114 + --> + trace +- /var/log/clickhouse-server/clickhouse-server.log +- /var/log/clickhouse-server/clickhouse-server.err.log ++ /opt/clickhouse/21.5/clickhouse-server.log ++ /opt/clickhouse/21.5/clickhouse-server.err.log + +@@ -331,10 +331,10 @@ + + + +- /var/lib/clickhouse/ ++ /opt/clickhouse/21.5/ + + +- /var/lib/clickhouse/tmp/ ++ /opt/clickhouse/21.5/ + + + + +- /var/lib/clickhouse/user_files/ ++ /opt/clickhouse/21.5/user_files/ + + + +@@ -419,11 +419,11 @@ + + + +- users.xml ++ /opt/clickhouse/21.5/users.xml + + + +- /var/lib/clickhouse/access/ ++ /opt/clickhouse/21.5/access/ + + + +- /var/lib/clickhouse/format_schemas/ ++ /opt/clickhouse/21.5/format_schemas/ + + -@@ -331,10 +331,10 @@ - +@@ -333,10 +333,10 @@ + 1073741824 - /var/lib/clickhouse/ -+ /opt/clickhouse/21.5/ ++ /opt/clickhouse/21.6/ - /var/lib/clickhouse/tmp/ -+ /opt/clickhouse/21.5/ ++ /opt/clickhouse/21.6/tmp/ - /var/lib/clickhouse/user_files/ -+ /opt/clickhouse/21.5/user_files/ ++ /opt/clickhouse/21.6/user_files/ -@@ -419,11 +419,11 @@ - - - -- users.xml -+ /opt/clickhouse/21.5/users.xml +@@ -425,7 +425,7 @@ - /var/lib/clickhouse/access/ -+ /opt/clickhouse/21.5/access/ ++ /opt/clickhouse/21.6/access/ + + +- ++ + - /var/lib/clickhouse/format_schemas/ -+ /opt/clickhouse/21.5/format_schemas/ ++ /opt/clickhouse/21.6/format_schemas/ @@ -18,11 +18,11 @@ index df8a5266c3..e58318e970 100644 - /var/lib/clickhouse/ -+ /opt/clickhouse/21.6/ ++ /var/clickhouse/21.7/ - /var/lib/clickhouse/tmp/ -+ /opt/clickhouse/21.6/tmp/ ++ /var/clickhouse/21.7/tmp/ - /var/lib/clickhouse/user_files/ -+ /opt/clickhouse/21.6/user_files/ ++ /var/clickhouse/21.7/user_files/ @@ -40,7 +40,7 @@ index df8a5266c3..e58318e970 100644 - /var/lib/clickhouse/access/ -+ /opt/clickhouse/21.6/access/ ++ /var/clickhouse/21.7/access/ -+ ++ - /var/lib/clickhouse/format_schemas/ -+ /opt/clickhouse/21.6/format_schemas/ ++ /var/clickhouse/21.7/format_schemas/ @@ -18,11 +18,11 @@ index df8a5266c3..e58318e970 100644 - /var/lib/clickhouse/ -+ /var/clickhouse/21.7/ ++ /tmp/clickhouse/21.7/ - /var/lib/clickhouse/tmp/ -+ /var/clickhouse/21.7/tmp/ ++ /tmp/clickhouse/21.7/tmp/ - /var/lib/clickhouse/user_files/ -+ /var/clickhouse/21.7/user_files/ ++ /tmp/clickhouse/21.7/user_files/ @@ -40,7 +40,7 @@ index df8a5266c3..e58318e970 100644 - /var/lib/clickhouse/access/ -+ /var/clickhouse/21.7/access/ ++ /tmp/clickhouse/21.7/access/ -+ ++ - /var/lib/clickhouse/format_schemas/ -+ /var/clickhouse/21.7/format_schemas/ ++ /tmp/clickhouse/21.7/format_schemas/