ClickHouse/docs/en/development/build-osx.md

136 lines
4.0 KiB
Markdown
Raw Normal View History

2020-04-03 13:23:32 +00:00
---
2022-08-28 14:53:34 +00:00
slug: /en/development/build-osx
sidebar_position: 65
2022-12-22 09:33:11 +00:00
sidebar_label: Build on macOS
title: How to Build ClickHouse on macOS
2023-12-11 10:19:09 +00:00
description: How to build ClickHouse on macOS for macOS
2020-04-03 13:23:32 +00:00
---
:::info You don't have to build ClickHouse yourself!
You can install pre-built ClickHouse as described in [Quick Start](https://clickhouse.com/#quick-start). Follow **macOS (Intel)** or **macOS (Apple silicon)** installation instructions.
:::
2021-11-26 17:10:34 +00:00
The build works on x86_64 (Intel) and arm64 (Apple Silicon) based on macOS 10.15 (Catalina) or higher with Homebrew's vanilla Clang.
:::note
2023-04-11 18:31:00 +00:00
It is also possible to compile with Apple's XCode `apple-clang`, but it's strongly discouraged.
:::
2020-03-20 10:10:48 +00:00
## Install Homebrew {#install-homebrew}
First install [Homebrew](https://brew.sh/)
2022-06-02 13:01:59 +00:00
## For Apple's Clang (discouraged): Install XCode and Command Line Tools {#install-xcode-and-command-line-tools}
2021-04-02 13:31:20 +00:00
2022-06-02 13:01:59 +00:00
Install the latest [XCode](https://apps.apple.com/am/app/xcode/id497799835?mt=12) from App Store.
2021-04-02 13:31:20 +00:00
Open it at least once to accept the end-user license agreement and automatically install the required components.
2021-05-27 19:48:20 +00:00
Then, make sure that the latest Command Line Tools are installed and selected in the system:
2021-04-02 13:31:20 +00:00
``` bash
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
2021-04-02 13:31:20 +00:00
```
2020-03-20 10:10:48 +00:00
## Install Required Compilers, Tools, and Libraries {#install-required-compilers-tools-and-libraries}
2020-03-20 10:10:48 +00:00
``` bash
brew update
brew install ccache cmake ninja libtool gettext llvm gcc binutils grep findutils nasm
```
2020-03-20 10:10:48 +00:00
## Checkout ClickHouse Sources {#checkout-clickhouse-sources}
2020-03-20 10:10:48 +00:00
``` bash
git clone --recursive git@github.com:ClickHouse/ClickHouse.git
# ...alternatively, you can use https://github.com/ClickHouse/ClickHouse.git as the repo URL.
DOCAPI-8530: Code blocks markup fix (#7060) * Typo fix. * Links fix. * Fixed links in docs. * More fixes. * docs/en: cleaning some files * docs/en: cleaning data_types * docs/en: cleaning database_engines * docs/en: cleaning development * docs/en: cleaning getting_started * docs/en: cleaning interfaces * docs/en: cleaning operations * docs/en: cleaning query_lamguage * docs/en: cleaning en * docs/ru: cleaning data_types * docs/ru: cleaning index * docs/ru: cleaning database_engines * docs/ru: cleaning development * docs/ru: cleaning general * docs/ru: cleaning getting_started * docs/ru: cleaning interfaces * docs/ru: cleaning operations * docs/ru: cleaning query_language * docs: cleaning interfaces/http * Update docs/en/data_types/array.md decorated ``` Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/getting_started/example_datasets/nyc_taxi.md fixed typo Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/getting_started/example_datasets/ontime.md fixed typo Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/interfaces/formats.md fixed error Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/table_engines/custom_partitioning_key.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/utils/clickhouse-local.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/dicts/external_dicts_dict_sources.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/utils/clickhouse-local.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/json_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/json_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/other_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/other_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/date_time_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/table_engines/jdbc.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * docs: fixed error * docs: fixed error
2019-09-23 15:31:46 +00:00
```
2020-03-20 10:10:48 +00:00
2021-04-02 13:31:20 +00:00
## Build ClickHouse {#build-clickhouse}
2021-11-26 17:10:34 +00:00
To build using Homebrew's vanilla Clang compiler (the only **recommended** way):
2020-03-20 10:10:48 +00:00
``` bash
cd ClickHouse
mkdir build
export PATH=$(brew --prefix llvm)/bin:$PATH
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=$(brew --prefix llvm)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm)/bin/clang++ -S . -B build
cmake --build build
# The resulting binary will be created at: build/programs/clickhouse
```
2022-06-02 13:01:59 +00:00
To build using XCode native AppleClang compiler in XCode IDE (this option is only for development builds and workflows, and is **not recommended** unless you know what you are doing):
2021-04-02 13:31:20 +00:00
``` bash
cd ClickHouse
rm -rf build
mkdir build
cd build
2021-11-26 17:10:34 +00:00
XCODE_IDE=1 ALLOW_APPLECLANG=1 cmake -G Xcode -DCMAKE_BUILD_TYPE=Debug -DENABLE_JEMALLOC=OFF ..
cmake --open .
2022-06-02 13:01:59 +00:00
# ...then, in XCode IDE select ALL_BUILD scheme and start the building process.
2021-11-26 17:10:34 +00:00
# The resulting binary will be created at: ./programs/Debug/clickhouse
2021-04-02 13:31:20 +00:00
```
2020-03-20 10:10:48 +00:00
## Caveats {#caveats}
2022-06-03 11:50:17 +00:00
If you intend to run `clickhouse-server`, make sure to increase the systems `maxfiles` variable.
2022-06-02 13:01:59 +00:00
:::note
Youll need to use sudo.
:::
2020-07-20 14:29:13 +00:00
To do so, create the `/Library/LaunchDaemons/limit.maxfiles.plist` file with the following content:
2020-03-20 10:10:48 +00:00
``` xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>524288</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
```
Give the file correct permissions:
2020-03-20 10:10:48 +00:00
``` bash
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
```
Validate that the file is correct:
``` bash
plutil /Library/LaunchDaemons/limit.maxfiles.plist
```
Load the file (or reboot):
``` bash
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
```
To check if its working, use the `ulimit -n` or `launchctl limit maxfiles` commands.
2021-11-26 17:10:34 +00:00
## Running ClickHouse server
2021-11-26 17:10:34 +00:00
``` bash
2021-05-05 14:56:20 +00:00
cd ClickHouse
./build/programs/clickhouse-server --config-file ./programs/server/config.xml
```