mirror of https://github.com/ByConity/ByConity
Adds support for building on Solaris-derived systems
This commit adds a number of changes to platform-detection and compile-time directives required to support building ClickHouse on Solaris-derived systems, most notably illumos.
This commit is contained in:
parent
6dec5266c4
commit
217745f231
|
@ -25,6 +25,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)
|
||||
// On Solaris-derived systems, this returns the ID of the LWP, analogous
|
||||
// to a thread.
|
||||
current_tid = static_cast<uint64_t>(pthread_self());
|
||||
#else
|
||||
if (0 != pthread_threadid_np(nullptr, ¤t_tid))
|
||||
throw std::logic_error("pthread_threadid_np returned error");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#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
|
||||
|
|
|
@ -1643,22 +1643,22 @@ typedef setseq_base<pcg128_t, pcg128_t, xsl_rr_rr_mixin>
|
|||
|
||||
template <bitcount_t table_pow2, bitcount_t advance_pow2,
|
||||
typename BaseRNG, bool kdd = true>
|
||||
using ext_std8 = extended<table_pow2, advance_pow2, BaseRNG,
|
||||
using ext_std8 = pgc_detail::extended<table_pow2, advance_pow2, BaseRNG,
|
||||
oneseq_rxs_m_xs_8_8, kdd>;
|
||||
|
||||
template <bitcount_t table_pow2, bitcount_t advance_pow2,
|
||||
typename BaseRNG, bool kdd = true>
|
||||
using ext_std16 = extended<table_pow2, advance_pow2, BaseRNG,
|
||||
using ext_std16 = pgc_detail::extended<table_pow2, advance_pow2, BaseRNG,
|
||||
oneseq_rxs_m_xs_16_16, kdd>;
|
||||
|
||||
template <bitcount_t table_pow2, bitcount_t advance_pow2,
|
||||
typename BaseRNG, bool kdd = true>
|
||||
using ext_std32 = extended<table_pow2, advance_pow2, BaseRNG,
|
||||
using ext_std32 = pgc_detail::extended<table_pow2, advance_pow2, BaseRNG,
|
||||
oneseq_rxs_m_xs_32_32, kdd>;
|
||||
|
||||
template <bitcount_t table_pow2, bitcount_t advance_pow2,
|
||||
typename BaseRNG, bool kdd = true>
|
||||
using ext_std64 = extended<table_pow2, advance_pow2, BaseRNG,
|
||||
using ext_std64 = pgc_detail::extended<table_pow2, advance_pow2, BaseRNG,
|
||||
oneseq_rxs_m_xs_64_64, kdd>;
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -844,8 +844,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();
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -129,7 +129,12 @@ String Elf::getBuildID() const
|
|||
return {};
|
||||
}
|
||||
|
||||
|
||||
#if defined(OS_SUNOS)
|
||||
String Elf::getBuildID(const char * nhdr_pos, size_t size)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
#else
|
||||
String Elf::getBuildID(const char * nhdr_pos, size_t size)
|
||||
{
|
||||
const char * nhdr_end = nhdr_pos + size;
|
||||
|
@ -149,6 +154,7 @@ String Elf::getBuildID(const char * nhdr_pos, size_t size)
|
|||
|
||||
return {};
|
||||
}
|
||||
#endif // OS_SUNOS
|
||||
|
||||
|
||||
String Elf::getBinaryHash() const
|
||||
|
|
|
@ -11,7 +11,12 @@ 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;
|
||||
|
||||
#if defined(OS_SUNOS)
|
||||
uint8_t trace_flags = 0;
|
||||
#else
|
||||
__uint8_t trace_flags = 0;
|
||||
#endif
|
||||
|
||||
// Parse/compose OpenTelemetry traceparent header.
|
||||
bool parseTraceparentHeader(const std::string & traceparent, std::string & error);
|
||||
|
|
|
@ -7,8 +7,12 @@ 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 // OS_SUNOS
|
||||
#endif // __APPLE__
|
||||
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;
|
||||
return res;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#if defined(OS_SUNOS)
|
||||
# include <sys/termios.h>
|
||||
#endif
|
||||
#include <Common/Exception.h>
|
||||
#include <Common/TerminalSize.h>
|
||||
#include <boost/program_options.hpp>
|
||||
|
@ -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);
|
||||
|
|
|
@ -105,8 +105,12 @@ struct RUsageCounters
|
|||
{
|
||||
::rusage rusage {};
|
||||
#if !defined(__APPLE__)
|
||||
#if defined(OS_SUNOS)
|
||||
::getrusage(RUSAGE_LWP, &rusage);
|
||||
#else
|
||||
::getrusage(RUSAGE_THREAD, &rusage);
|
||||
#endif
|
||||
#endif // OS_SUNOS
|
||||
#endif // __APPLE
|
||||
return RUsageCounters(rusage, getClockMonotonic());
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ __attribute__((__weak__)) void checkStackSize()
|
|||
stack_address = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <pthread.h>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) || defined(OS_SUNOS)
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <pthread_np.h>
|
||||
#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__)
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined (__ANDROID__)
|
||||
# include <sys/endian.h>
|
||||
#elif defined(__sun)
|
||||
# include <endian.h>
|
||||
#elif defined(__APPLE__)
|
||||
# include <libkern/OSByteOrder.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
#include <sys/ioctl.h>
|
||||
#if defined(OS_SUNOS)
|
||||
# include <sys/termios.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <Processors/Formats/Impl/PrettyBlockOutputFormat.h>
|
||||
#include <Formats/FormatFactory.h>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <Core/Types.h>
|
||||
#include <Poco/Util/AbstractConfiguration.h>
|
||||
#include "PostgreSQLConnectionPool.h"
|
||||
|
|
|
@ -39,7 +39,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 ()
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in New Issue