Skip to content

Instantly share code, notes, and snippets.

@javisantana
Last active March 11, 2020 05:45
Show Gist options
  • Save javisantana/87bc161d21eac4649fe820ff50f80e32 to your computer and use it in GitHub Desktop.
Save javisantana/87bc161d21eac4649fe820ff50f80e32 to your computer and use it in GitHub Desktop.
compile clickhouse on mojave

clickhouse on osx

These are the steps I followed to compile clickhouse on OSX mojave (10.4.3). These might not be the best way to make it compile on OSX, my knowledge about C++ and build tooling is really limited but they do the work.

clickhouse sha-1: 2ad4df1d6a

compile command (apply the patch below before running cmake)

cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang` -DCMAKE_BUILD_TYPE=Debug -DENABLE_MYSQL=0 -DUSE_STATIC_LIBRARIES=1 -DNO_WERROR=1 -DENABLE_TESTS=0 -DUSE_RDKAFKA=0
ninja clickhouse

with USE_STATIC_LIBRARIES=0 clickhouse binary won't start.

✗ clang --version
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
diff --git a/cmake/darwin/default_libs.cmake b/cmake/darwin/default_libs.cmake
index 679fef8808..142175d147 100644
--- a/cmake/darwin/default_libs.cmake
+++ b/cmake/darwin/default_libs.cmake
@@ -1,7 +1,7 @@
set (DEFAULT_LIBS "-nodefaultlibs")
if (NOT COMPILER_CLANG)
- message (FATAL_ERROR "Darwin build is supported only for Clang")
+ #message (FATAL_ERROR "Darwin build is supported only for Clang")
endif ()
set (DEFAULT_LIBS "${DEFAULT_LIBS} ${COVERAGE_OPTION} -lc -lm -lpthread -ldl")
diff --git a/contrib/libcxx-cmake/CMakeLists.txt b/contrib/libcxx-cmake/CMakeLists.txt
index a654ce59d6..2e96884ada 100644
--- a/contrib/libcxx-cmake/CMakeLists.txt
+++ b/contrib/libcxx-cmake/CMakeLists.txt
@@ -44,9 +44,6 @@ target_include_directories(cxx SYSTEM BEFORE PUBLIC $<BUILD_INTERFACE:${LIBCXX_S
target_compile_definitions(cxx PRIVATE -D_LIBCPP_BUILDING_LIBRARY -DLIBCXX_BUILDING_LIBCXXABI)
target_compile_options(cxx PUBLIC -nostdinc++ -Wno-reserved-id-macro)
-if (OS_DARWIN AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11))
- target_compile_options(cxx PUBLIC -Wno-ctad-maybe-unsupported)
-endif ()
target_link_libraries(cxx PUBLIC cxxabi)
diff --git a/dbms/src/Common/Allocator.h b/dbms/src/Common/Allocator.h
index 5d39d32724..0e11e0c06c 100644
--- a/dbms/src/Common/Allocator.h
+++ b/dbms/src/Common/Allocator.h
@@ -251,7 +251,8 @@ private:
/// default. This may lead to worse TLB performance.
void * getMmapHint()
{
- return reinterpret_cast<void *>(std::uniform_int_distribution<intptr_t>(0x100000000000UL, 0x700000000000UL)(thread_local_rng));
+ //return reinterpret_cast<void *>(std::uniform_int_distribution<intptr_t>(0x100000000000UL, 0x700000000000UL)(thread_local_rng));
+ return nullptr;
}
#else
void * getMmapHint()
diff --git a/libs/libcommon/src/DateLUTImpl.cpp b/libs/libcommon/src/DateLUTImpl.cpp
index 51f5ceb759..32cc8df723 100644
--- a/libs/libcommon/src/DateLUTImpl.cpp
+++ b/libs/libcommon/src/DateLUTImpl.cpp
@@ -45,15 +45,15 @@ UInt8 getDayOfWeek(const cctz::civil_day & date)
}
-__attribute__((__weak__)) extern bool inside_main;
+//__attribute__((__weak__)) extern bool inside_main;
DateLUTImpl::DateLUTImpl(const std::string & time_zone_)
: time_zone(time_zone_)
{
/// DateLUT should not be initialized in global constructors for the following reasons:
/// 1. It is too heavy.
- if (&inside_main)
- assert(inside_main);
+ //if (&inside_main)
+ //assert(inside_main);
size_t i = 0;
time_t start_of_day = DATE_LUT_MIN;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment