Merge pull request #22885 from traceon/gcc-macos-compilation-fixes

Fix vanilla GCC compilation in macOS
This commit is contained in:
alexey-milovidov 2021-04-10 14:17:11 +03:00 committed by GitHub
commit 2d4a8c4787
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 34 additions and 11 deletions

2
.gitmodules vendored
View File

@ -133,7 +133,7 @@
url = https://github.com/unicode-org/icu.git
[submodule "contrib/flatbuffers"]
path = contrib/flatbuffers
url = https://github.com/google/flatbuffers.git
url = https://github.com/ClickHouse-Extras/flatbuffers.git
[submodule "contrib/libc-headers"]
path = contrib/libc-headers
url = https://github.com/ClickHouse-Extras/libc-headers.git

View File

@ -9,6 +9,7 @@
#include <common/getMemoryAmount.h>
#include <common/logger_useful.h>
#include <Common/formatReadable.h>
#include <Common/SymbolIndex.h>
#include <Common/StackTrace.h>
#include <Common/getNumberOfPhysicalCPUCores.h>

View File

@ -1,11 +1,11 @@
set (DEFAULT_LIBS "-nodefaultlibs")
if (NOT COMPILER_CLANG)
message (FATAL_ERROR "Darwin build is supported only for Clang")
endif ()
set (DEFAULT_LIBS "${DEFAULT_LIBS} ${COVERAGE_OPTION} -lc -lm -lpthread -ldl")
if (COMPILER_GCC)
set (DEFAULT_LIBS "${DEFAULT_LIBS} -lgcc_eh")
endif ()
message(STATUS "Default libraries: ${DEFAULT_LIBS}")
set(CMAKE_CXX_STANDARD_LIBRARIES ${DEFAULT_LIBS})

View File

@ -1,3 +1,8 @@
if (OS_DARWIN AND COMPILER_GCC)
# AMQP-CPP requires libuv which cannot be built with GCC in macOS due to a bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93082
set (ENABLE_AMQPCPP OFF CACHE INTERNAL "")
endif()
option(ENABLE_AMQPCPP "Enalbe AMQP-CPP" ${ENABLE_LIBRARIES})
if (NOT ENABLE_AMQPCPP)

View File

@ -1,3 +1,8 @@
if (OS_DARWIN AND COMPILER_GCC)
# Cassandra requires libuv which cannot be built with GCC in macOS due to a bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93082
set (ENABLE_CASSANDRA OFF CACHE INTERNAL "")
endif()
option(ENABLE_CASSANDRA "Enable Cassandra" ${ENABLE_LIBRARIES})
if (NOT ENABLE_CASSANDRA)

@ -1 +1 @@
Subproject commit a2fa7b76e2ee16d2ad955e9214a90bbf79da66fc
Subproject commit 672643e9a427ef803abf13bc8cb4989606553d64

2
contrib/boringssl vendored

@ -1 +1 @@
Subproject commit fd9ce1a0406f571507068b9555d0b545b8a18332
Subproject commit 83c1cda8a0224dc817cbad2966c7ed4acc35f02a

View File

@ -16,7 +16,7 @@ endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fvisibility=hidden -fno-common -fno-exceptions -fno-rtti")
if(APPLE)
if(APPLE AND CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()

2
contrib/flatbuffers vendored

@ -1 +1 @@
Subproject commit 6df40a2471737b27271bdd9b900ab5f3aec746c7
Subproject commit 22e3ffc66d2d7d72d1414390aa0f04ffd114a5a1

2
contrib/libcxx vendored

@ -1 +1 @@
Subproject commit 8b80a151d12b98ffe2d0c22f7cec12c3b9ff88d7
Subproject commit 2fa892f69acbaa40f8a18c6484854a6183a34482

View File

@ -56,6 +56,11 @@ if (USE_UNWIND)
target_compile_definitions(cxx PUBLIC -DSTD_EXCEPTION_HAS_STACK_TRACE=1)
endif ()
# Override the deduced attribute support that causes error.
if (OS_DARWIN AND COMPILER_GCC)
add_compile_definitions(_LIBCPP_INIT_PRIORITY_MAX)
endif ()
target_compile_options(cxx PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-nostdinc++>)
# Third party library may have substandard code.

View File

@ -508,5 +508,10 @@ if (ENABLE_TESTS AND USE_GTEST)
clickhouse_common_zookeeper
string_utils)
# For __udivmodti4 referenced in Core/tests/gtest_DecimalFunctions.cpp
if (OS_DARWIN AND COMPILER_GCC)
target_link_libraries(unit_tests_dbms PRIVATE gcc)
endif ()
add_check(unit_tests_dbms)
endif ()

View File

@ -11,7 +11,9 @@
#ifdef __APPLE__
// ucontext is not available without _XOPEN_SOURCE
# pragma clang diagnostic ignored "-Wreserved-id-macro"
# ifdef __clang__
# pragma clang diagnostic ignored "-Wreserved-id-macro"
# endif
# define _XOPEN_SOURCE 700
#endif
#include <ucontext.h>