ClickHouse: Build ClickHouse on MacOS failed

➜  build git:(master) cmake .. -DCMAKE_C_COMPILER=`brew --prefix llvm`/bin/clang-11 -DCMAKE_CXX_COMPILER=`brew --prefix llvm`/bin/clang++ -DCMAKE_PREFIX_PATH=`brew --prefix llvm` -DCMAKE_BUILD_TYPE=Debug
➜  build git:(master) ninja
[0/2] Re-checking globbed directories...
[2159/6139] Building CXX object contrib/flatbuffers/CMakeFiles/flatbuffers.dir/src/util.cpp.o
FAILED: contrib/flatbuffers/CMakeFiles/flatbuffers.dir/src/util.cpp.o
/usr/local/opt/llvm/bin/clang++ -DFLATBUFFERS_LOCALE_INDEPENDENT=0 -I../contrib/flatbuffers/include -I../contrib/flatbuffers/grpc -isystem ../contrib/libcxx/include -isystem ../contrib/libcxxabi/include -fdiagnostics-color=always -std=gnu++2a -fsized-deallocation  -gdwarf-aranges -msse4.1 -msse4.2 -mpopcnt   -Wall -Wno-unused-command-line-argument  -stdlib=libc++ -fdiagnostics-absolute-paths -fexperimental-new-pass-manager -Werror -w -std=c++11 -stdlib=libc++ -Wall -pedantic -Werror -Wextra -Wno-unused-parameter -g -O0 -g3 -ggdb3 -fno-inline  -D_LIBCPP_DEBUG=0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.15   -D OS_DARWIN -Wold-style-cast -nostdinc++ -std=c++17 -MD -MT contrib/flatbuffers/CMakeFiles/flatbuffers.dir/src/util.cpp.o -MF contrib/flatbuffers/CMakeFiles/flatbuffers.dir/src/util.cpp.o.d -o contrib/flatbuffers/CMakeFiles/flatbuffers.dir/src/util.cpp.o -c ../contrib/flatbuffers/src/util.cpp
In file included from ../contrib/flatbuffers/src/util.cpp:40:
In file included from ../contrib/flatbuffers/include/flatbuffers/base.h:32:
/Users/godliness/IdeaProjects/godliness/ClickHouse/contrib/libcxx/include/cstdlib:158:9: error: no member named 'aligned_alloc' in the global namespace
using ::aligned_alloc;
      ~~^
1 error generated.
[2168/6139] Building CXX object contrib/flatbuffers/CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o
ninja: build stopped: subcommand failed.
➜  ~ llvm-ar --version
LLVM (http://llvm.org/):
  LLVM version 11.0.1
  Optimized build.
  Default target: x86_64-apple-darwin19.6.0
  Host CPU: haswell

I am using clang-11 as https://github.com/ClickHouse/ClickHouse/issues/21731#issuecomment-799672993 said.

But i still got this error as above.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 31 (22 by maintainers)

Most upvoted comments

and compile it successfully, but run the clickhouse binary it shows:

<jemalloc>: ../contrib/jemalloc/include/jemalloc/internal/tsd_generic.h:145: Failed assertion: "tsd_booted"
[1]    81768 abort      ./clickhouse --vresion

This is something recent, but can be worked around by specifying -DENABLE_JEMALLOC=0 during cmake configure stage.

Hi @traceon , it’s working now, thank you very much

@tlightsky please, perform the following steps, manually executing each command in the same terminal windows (follow suggestions in the comments too):

# Preferably, upgrade macOS to the latest version (reboots may be required).
# Then upgrade Xcode to the latest version (in App Store).
# Then open Xcode at least once, accept end-user agreements/allow installation of the required components, if any.

# Then:
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

# ...wait until Command Line Tools are successfully installed.

# Then (in a new terminal):

brew update
brew upgrade
brew install cmake ninja libtool gettext llvm gcc

# Perform repo sync, and clean config/build:

cd ClickHouse
rm -rf build
rm -rf contrib/libcxx
rm -rf contrib/flatbuffers
rm -rf contrib/abseil-cpp
git submodule update --init --recursive
git pull --recurse-submodules
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
cmake --build . --config RelWithDebInfo
cd ..