From b64910ce27a4df33e3ad2e3f40764e8b3271a9aa Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 6 Apr 2017 18:29:33 -0400 Subject: MDEV-12452 MDEV-12453 : Fix building rocksdb and aws_key_management on macOS use CMAKE_CXX_STANDARD to set C++11 flags with CMake 3.1+ (apples flags are somehow different from standard clang) port htonbe16/32/64 macros for rocksdb use reinterpret_cast to cast macOS's pthread_t (pointer type) to size_t , for rocksdb --- plugin/aws_key_management/CMakeLists.txt | 8 ++++++-- storage/rocksdb/CMakeLists.txt | 4 +++- storage/rocksdb/build_rocksdb.cmake | 4 ---- storage/rocksdb/rdb_buff.h | 10 ++++++++++ storage/rocksdb/ut0counter.h | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/plugin/aws_key_management/CMakeLists.txt b/plugin/aws_key_management/CMakeLists.txt index 66b8074406f..59fdd1684f2 100644 --- a/plugin/aws_key_management/CMakeLists.txt +++ b/plugin/aws_key_management/CMakeLists.txt @@ -50,7 +50,6 @@ ENDIF() FIND_LIBRARY(AWS_CPP_SDK_CORE NAMES aws-cpp-sdk-core PATH_SUFFIXES "${SDK_INSTALL_BINARY_PREFIX}") FIND_LIBRARY(AWS_CPP_SDK_KMS NAMES aws-cpp-sdk-kms PATH_SUFFIXES "${SDK_INSTALL_BINARY_PREFIX}") -SET(CMAKE_REQUIRED_FLAGS ${CXX11_FLAGS}) FIND_PATH(AWS_CPP_SDK_INCLUDE_DIR NAMES aws/kms/KMSClient.h) IF(AWS_CPP_SDK_CORE AND AWS_CPP_SDK_KMS AND AWS_CPP_SDK_INCLUDE_DIR) @@ -121,6 +120,7 @@ ELSE() -DBUILD_ONLY=kms -DBUILD_SHARED_LIBS=OFF -DFORCE_SHARED_CRT=OFF + -DENABLE_TESTING=OFF "-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} ${PIC_FLAG}" "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${PIC_FLAG}" "-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} ${PIC_FLAG}" @@ -140,7 +140,11 @@ ELSE() ENDIF() ADD_DEFINITIONS(${SSL_DEFINES}) # Need to know whether openssl should be initialized -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_FLAGS}") +IF(CMAKE_VERSION GREATER "3.0") + SET(CMAKE_CXX_STANDARD 11) +ELSE() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_FLAGS}") +ENDIF() IF(WIN32) SET(AWS_CPP_SDK_DEPENDENCIES bcrypt winhttp wininet userenv version) ELSE() diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 308bd26592e..3223e084709 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -54,7 +54,9 @@ ELSE() SKIP_ROCKSDB_PLUGIN("Compiler not supported") ENDIF() -IF(CXX11_FLAGS) +IF(CMAKE_VERSION GREATER 3.0) + SET(CMAKE_CXX_STANDARD 11) +ELSEIF(CXX11_FLAGS) ADD_DEFINITIONS(${CXX11_FLAGS}) ENDIF() diff --git a/storage/rocksdb/build_rocksdb.cmake b/storage/rocksdb/build_rocksdb.cmake index 4b830bbdf32..b4871662f9d 100644 --- a/storage/rocksdb/build_rocksdb.cmake +++ b/storage/rocksdb/build_rocksdb.cmake @@ -29,10 +29,6 @@ else() endif() endif() -include (CheckTypeSize) -check_type_size(size_t SIZEOF_SIZE_T) -set_property(SOURCE ha_rocksdb.cc APPEND PROPERTY COMPILE_DEFINITIONS - SIZEOF_SIZE_T=${SIZEOF_SIZE_T} SIZEOF_UINT64_T=8) # Optional compression libraries. diff --git a/storage/rocksdb/rdb_buff.h b/storage/rocksdb/rdb_buff.h index c2d039b46c5..4b5850137f6 100644 --- a/storage/rocksdb/rdb_buff.h +++ b/storage/rocksdb/rdb_buff.h @@ -30,6 +30,16 @@ #define be16toh _byteswap_ushort #endif +#if __APPLE__ +#include +#define htobe64(x) OSSwapHostToBigInt64(x) +#define be64toh(x) OSSwapBigToHostInt64(x) +#define htobe32(x) OSSwapHostToBigInt32(x) +#define be32toh(x) OSSwapBigToHostInt32(x) +#define htobe16(x) OSSwapHostToBigInt16(x) +#define be16toh(x) OSSwapBigToHostInt16(x) +#endif + namespace myrocks { /* diff --git a/storage/rocksdb/ut0counter.h b/storage/rocksdb/ut0counter.h index af2e023af27..97c92dc675b 100644 --- a/storage/rocksdb/ut0counter.h +++ b/storage/rocksdb/ut0counter.h @@ -78,7 +78,7 @@ struct thread_id_indexer_t : public generic_indexer_t { thread id is represented as a pointer, it may not work as effectively. */ size_t get_rnd_index() const { - return get_curr_thread_id(); + return reinterpret_cast(get_curr_thread_id()); } }; -- cgit v1.2.1