follow https://clickhouse.tech/docs/en/development/build-osx/
**Operating system**
mac os10.15.4

**Cmake version**
cmake version 3.17.3

**Ninja version**
1.10.0
**Compiler name and version**
mac os

**Full cmake and/or ninja output**
zhangpeng@zhangpeng-local build % cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang`
-- IPO/LTO not enabled.
-- CMAKE_BUILD_TYPE is not set, set to default = RelWithDebInfo
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- Disabling compiler -pipe option (have only 5545 mb of memory)
CMake Warning at CMakeLists.txt:250 (message):
  Cannot find llvm-ar.  System ar will be used instead.  It does not work
  with ThinLTO.


CMake Warning at CMakeLists.txt:258 (message):
  Cannot find llvm-ranlib.  System ranlib will be used instead.  It does not
  work with ThinLTO.


-- Default libraries: -nodefaultlibs  -lc -lm -lpthread -ldl
-- Using libcxx: cxx
-- Using libcxxfs:
-- Using libcxxabi: cxxabi
-- Tests are enabled
-- Building for: Darwin-19.4.0 x86_64  ; USE_STATIC_LIBRARIES=ON MAKE_STATIC_LIBRARIES=ON SPLIT_SHARED= UNBUNDLED=OFF CCACHE=CCACHE_FOUND-NOTFOUND
-- Using double-conversion:  : double-conversion
-- Using ssl=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/openssl/include;/Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/openssl-cmake/linux_x86_64/include : ssl;crypto
-- Using ldap=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/openldap-cmake/darwin_x86_64/include;/Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/openldap/include : ldap_r;lber
-- Build without ICU (support for collations and charset conversion functions will be disabled)
-- Using zlib-ng: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/zlib-ng;/Users/zhangpeng/codes/github/clickhouse/ClickHouse/build/contrib/zlib-ng : zlib
-- Using zstd: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/zstd/lib : zstd
-- Using termcap: /usr/lib/libncurses.dylib
-- Using sparsehash: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/sparsehash-c11
-- Using re2: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/re2 : re2;  : re2_st
-- Using libgsasl=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/libgsasl/src;/Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/libgsasl/linux_x86_64/include : libgsasl
-- Using librdkafka=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/librdkafka/src : rdkafka cppkafka
-- Using AMQP-CPP=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/AMQP-CPP/include;/Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/AMQP-CPP/include;/Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/AMQP-CPP : AMQP-CPP
-- Using capnp=1: capnpc
-- Using opencl=:  :
-- Using h3=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/h3/src/h3lib/include : h3
-- Using libxml2: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/libxml2/include;/Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/libxml2-cmake/linux_x86_64/include : libxml2
-- Using brotli=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/brotli/c/include : brotli
-- Using protobuf=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/protobuf/src : libprotobuf : $<TARGET_FILE:protoc>
-- Using gRPC=ON: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/grpc/include : libgrpc++
-- Using pdqsort: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/pdqsort
-- Using hdfs3=:  :
-- Using aws_s3=:  :
-- Using snappy: snappy
-- Using Parquet: arrow_static: ; parquet_static: ; thrift_static ; flatbuffers
-- Using simdjson=ON
-- Using rapidjson=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/rapidjson/include
-- Using fastops=0:  :
-- Using snappy: snappy
-- Using internal=ON orc=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/orc/c++/include : orc
-- Using snappy: snappy
-- Using avro=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/avro/lang/c++/include : avrocpp
-- Using msgpack=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/msgpack-c/include
-- Using cassandra=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/cassandra/include/ : cassandra_static
-- Using libuv: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/libuv : uv_a
-- Using cityhash:  : cityhash
-- Using farmhash:  : farmhash
-- Using btrie:  : btrie
-- Using gtest=1: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/googletest/googletest : gtest_main;gtest :
-- Build without mysqlclient (support for MYSQL dictionary source will be disabled)
-- compiler C   = /usr/bin/clang  -fdiagnostics-color=always  -gdwarf-aranges -msse4.1 -msse4.2 -mpopcnt  -Wall -Wno-unused-command-line-argument  -fdiagnostics-absolute-paths -Werror -mmacosx-version-min=10.15 -O2 -g -DNDEBUG -O3
-- compiler CXX = /usr/bin/clang++  -fdiagnostics-color=always -std=c++2a -fsized-deallocation  -gdwarf-aranges -msse4.1 -msse4.2 -mpopcnt   -Wall -Wno-unused-command-line-argument  -stdlib=libc++ -fdiagnostics-absolute-paths -Werror -mmacosx-version-min=10.15 -O2 -g -DNDEBUG -O3
-- LINKER_FLAGS =  -rdynamic -Wl,-U,_inside_main -mmacosx-version-min=10.15
-- Using cctz
-- Not using FastMemcpy
-- Using hyperscan
CMake Warning at contrib/jemalloc-cmake/CMakeLists.txt:10 (message):
  jemalloc support on non-linux is EXPERIMENTAL


-- jemalloc malloc_conf: oversize_threshold:0,muzzy_decay_ms:10000
-- Using jemalloc
-- Using cpuid
-- Using replxx
-- Not using unixodbc
-- Using Poco::Crypto
-- Not using Poco::Data::ODBC
-- ZSTD VERSION 1.4.0
-- Using CMake version 3.17.3
-- ZLIB_HEADER_VERSION: 1.2.11
-- ZLIBNG_HEADER_VERSION: 1.9.9
-- Arch detected: 'x86_64'
-- Basearch of 'x86_64' has been detected as: 'x86'
-- Architecture-specific source files: arch/x86/x86.c;arch/x86/insert_string_sse.c;arch/x86/deflate_quick.c;arch/x86/fill_window_sse.c;arch/x86/slide_sse.c;arch/x86/crc_folding.c
-- The following features have been enabled:

 * CMAKE_BUILD_TYPE, Build type: RelWithDebInfo (selected)
 * ZLIB_COMPAT, Provide a zlib-compatible API
 * WITH_OPTIM, Build with optimisation
 * WITH_NEW_STRATEGIES, Use new strategies
 * SSE42_CRC, Support CRC hash generation using the SSE4.2 instruction set, using "-msse4"
 * SSE42_DEFLATE_QUICK, Support SSE4.2-accelerated quick compression
 * PCLMUL_CRC, Support CRC hash generation using PCLMULQDQ, using "-mpclmul"

-- The following REQUIRED packages have been found:

 * Threads

-- The following features have been disabled:

 * WITH_GZFILEOP, Compile with support for gzFile-related functions
 * WITH_SANITIZERS, Build with address sanitizer and all supported sanitizers other than memory sanitizer
 * WITH_MSAN, Build with memory sanitizer
 * WITH_FUZZERS, Build test/fuzz
 * MAINTAINER, Build with maintainer warnings and tests enabled

-- Using curl: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/curl/include : curl
-- FLATBUFFERS_LIBRARY: flatbuffers
-- PROJECT version: 2.11.0
-- libuv version: v1.34.1
-- OpenSSL version: v
-- Using std::atomic implementation for atomic operations
-- Using hash header <functional> and namespace "std"
-- /Users/zhangpeng/codes/github/clickhouse/ClickHouse/src: Have 5547 megabytes of memory. Limiting concurrent linkers jobs to 1 and compiler jobs to 3
-- Will build ClickHouse 20.7.1.1 revision 54437
-- Target check already exists
-- /Users/zhangpeng/codes/github/clickhouse/ClickHouse/utils: Have 5547 megabytes of memory. Limiting concurrent linkers jobs to 1 and compiler jobs to OFF
-- Configuring done
CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   cassandra

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/zhangpeng/codes/github/clickhouse/ClickHouse/build
zhangpeng@zhangpeng-local build % ninja
[0/2] Re-checking globbed directories...
[16/549] Building CXX object src/Common/tests/CMakeFiles/memory_statistics_os_perf.dir/memory_statistics_os_perf.cpp.o
FAILED: src/Common/tests/CMakeFiles/memory_statistics_os_perf.dir/memory_statistics_os_perf.cpp.o
/usr/bin/clang++  -DPOCO_ENABLE_CPP11 -DPOCO_HAVE_FD_POLL -DPOCO_OS_FAMILY_UNIX -DUNALIGNED_OK -DUSE_FASTMEMCPY=0 -DUSE_REPLXX=1 -DWITH_COVERAGE=0 -DWITH_GZFILEOP -DX86_64 -DZLIB_COMPAT -Iincludes/configs -I../src -Isrc -Isrc/Core/include -I../base/common/.. -Ibase/common/.. -I../contrib/cityhash102/include -I../contrib/cctz/include -Icontrib/zlib-ng -I../contrib/zlib-ng -I../base/pcg-random/. -isystem ../contrib/libcxx/include -isystem ../contrib/libcxxabi/include -isystem ../contrib/msgpack-c/include -isystem ../contrib/re2 -isystem ../contrib/boost -isystem ../contrib/poco/Net/include -isystem ../contrib/poco/Foundation/include -isystem ../contrib/poco/NetSSL_OpenSSL/include -isystem ../contrib/poco/Crypto/include -isystem ../contrib/openssl-cmake/linux_x86_64/include -isystem ../contrib/openssl/include -isystem ../contrib/poco/Util/include -isystem ../contrib/poco/JSON/include -isystem ../contrib/poco/XML/include -isystem ../contrib/replxx/include -isystem ../contrib/fmtlib-cmake/../fmtlib/include -isystem ../contrib/double-conversion -isystem ../contrib/ryu -isystem contrib/re2_st -isystem ../contrib/croaring -fdiagnostics-color=always -std=c++2a -fsized-deallocation  -gdwarf-aranges -msse4.1 -msse4.2 -mpopcnt   -Wall -Wno-unused-command-line-argument  -stdlib=libc++ -fdiagnostics-absolute-paths -Werror -mmacosx-version-min=10.15 -Wextra -Wpedantic -Wno-vla-extension -Wno-zero-length-array -Wcomma -Wconditional-uninitialized -Wcovered-switch-default -Wdeprecated -Wembedded-directive -Wempty-init-stmt -Wextra-semi-stmt -Wextra-semi -Wgnu-case-range -Winconsistent-missing-destructor-override -Wnewline-eof -Wold-style-cast -Wrange-loop-analysis -Wredundant-parens -Wreserved-id-macro -Wshadow-field -Wshadow-uncaptured-local -Wshadow -Wstring-plus-int -Wundef -Wunreachable-code-return -Wunreachable-code -Wunused-exception-parameter -Wunused-macros -Wunused-member-function -Wzero-as-null-pointer-constant -Weverything -Wno-c++98-compat-pedantic -Wno-c++98-compat -Wno-c99-extensions -Wno-conversion -Wno-ctad-maybe-unsupported -Wno-deprecated-dynamic-exception-spec -Wno-disabled-macro-expansion -Wno-documentation-unknown-command -Wno-double-promotion -Wno-exit-time-destructors -Wno-float-equal -Wno-global-constructors -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-nested-anon-types -Wno-packed -Wno-padded -Wno-return-std-move-in-c++11 -Wno-shift-sign-overflow -Wno-sign-conversion -Wno-switch-enum -Wno-undefined-func-template -Wno-unused-template -Wno-vla -Wno-weak-template-vtables -Wno-weak-vtables -O2 -g -DNDEBUG -O3  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk   -D OS_DARWIN -nostdinc++ -MD -MT src/Common/tests/CMakeFiles/memory_statistics_os_perf.dir/memory_statistics_os_perf.cpp.o -MF src/Common/tests/CMakeFiles/memory_statistics_os_perf.dir/memory_statistics_os_perf.cpp.o.d -o src/Common/tests/CMakeFiles/memory_statistics_os_perf.dir/memory_statistics_os_perf.cpp.o -c ../src/Common/tests/memory_statistics_os_perf.cpp
/Users/zhangpeng/codes/github/clickhouse/ClickHouse/src/Common/tests/memory_statistics_os_perf.cpp:7:21: error: expected namespace name
    using namespace DB;
                    ^
/Users/zhangpeng/codes/github/clickhouse/ClickHouse/src/Common/tests/memory_statistics_os_perf.cpp:10:5: error: unknown type name 'MemoryStatisticsOS'
    MemoryStatisticsOS stats;
    ^
/Users/zhangpeng/codes/github/clickhouse/ClickHouse/src/Common/tests/memory_statistics_os_perf.cpp:15:9: error: use of undeclared identifier 'MemoryStatisticsOS'
        MemoryStatisticsOS::Data data = stats.get();
        ^
/Users/zhangpeng/codes/github/clickhouse/ClickHouse/src/Common/tests/memory_statistics_os_perf.cpp:15:34: error: use of undeclared identifier 'data'; did you mean 'std::data'?
        MemoryStatisticsOS::Data data = stats.get();
                                 ^~~~
                                 std::data
/Users/zhangpeng/codes/github/clickhouse/ClickHouse/contrib/libcxx/include/iterator:1982:6: note: 'std::data' declared here
auto data(_Cont& __c)
     ^
/Users/zhangpeng/codes/github/clickhouse/ClickHouse/src/Common/tests/memory_statistics_os_perf.cpp:16:20: error: use of undeclared identifier 'data'
        counter += data.resident;
                   ^
5 errors generated.
[18/549] Building CXX object src/Common/tests/CMakeFiles/integer_hash_tables_and_hashes.dir/integer_hash_tables_and_hashes.cpp.o
ninja: build stopped: subcommand failed.

#include <Common/MemoryStatisticsOS.h>
#include <iostream>
int main(int argc, char ** argv)
{
    using namespace DB;
    size_t num_iterations = argc >= 2 ? std::stoull(argv[1]) : 1000000;
    MemoryStatisticsOS stats;
    uint64_t counter = 0;
    for (size_t i = 0; i < num_iterations; ++i)
    {
        MemoryStatisticsOS::Data data = stats.get();
        counter += data.resident;
    }
    if (num_iterations)
        std::cerr << (counter / num_iterations) << '\n';
    return 0;
}