Compile on MacOS

This guide is about how to compile Doris on MacOS.

Compiling on MacOS - 图1tip

Currently, this is not supported in the compute-storage decoupled mode.

Prerequisites

  • MacOS 12 (Monterey) or later (Both Intel and Apple Silicon are supported.)
  • Homebrew

Compile source code

  1. Install dependencies using Homebrew
  1. brew install automake autoconf libtool pkg-config texinfo coreutils gnu-getopt \
  2. python@3 cmake ninja ccache bison byacc gettext wget pcre maven llvm@16 openjdk@11 npm

Compiling on MacOS - 图2tip

On MacOS, since Homebrew does not provide an installation package for JDK8, JDK11 is used here instead. Alternatively, you can manually download and install JDK8.

  1. Compile source code
  1. bash build.sh

Compiling on MacOS - 图3tip

The first step of compiling Doris is to download and compile third-party libraries. You can download the pre-compiled versions of third-party libraries provided by the Doris community. Please refer to the instructions below for downloading pre-compiled third-party libraries to speed up the build process.

Start

  1. Increase file descriptors limit
  1. # Increase the file descriptor limit using the ulimit command.
  2. ulimit -n 65536
  3. # Check if the change is effective.
  4. $ ulimit -n
  5. # Add the configuration to your startup script so that you do not have to set it again every time you open a new terminal session.
  6. # If you are using bash, execute the following statement:
  7. echo 'ulimit -n 65536' >>~/.bashrc
  8. # If you are using zsh, execute the following statement:
  9. echo 'ulimit -n 65536' >>~/.zshrc
  1. Start BE
  1. cd output/be/bin
  2. ./start_be.sh --daemon
  1. Start FE
  1. cd output/fe/bin
  2. ./start_fe.sh --daemon

Speed up by using pre-compiled third-party libraries

Download the pre-compiled third-party libraries from Apache Doris Third Party Prebuilt. Refer to the command below:

  1. cd thirdparty
  2. rm -rf installed
  3. # Intel chip
  4. curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-darwin-x86_64.tar.xz \
  5. -o - | tar -Jxf -
  6. # Apple Silicon chip
  7. curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-darwin-arm64.tar.xz \
  8. -o - | tar -Jxf -
  9. # Check if protoc and thrift functions normally
  10. cd installed/bin
  11. ./protoc --version
  12. ./thrift --version

Compiling on MacOS - 图4tip

When running protoc and thrift, you may encounter an issue where the binary cannot be opened due to developer verification. To resolve this, you can go to “Security & Privacy” settings. In the “General” tab, click on the “Open Anyway” button to confirm your intent to open the binary. Refer to: https://support.apple.com/en-us/102445

Common Errors

  1. When running protoc and thrift, you may encounter an issue where the binary cannot be opened due to developer verification. To resolve this, you can go to “Security & Privacy” settings. In the “General” tab, click on the “Open Anyway” button to confirm your intent to open the binary. Refer to: https://support.apple.com/en-us/102445.
  2. When compiling with a Mac with an M3 chip, the compilation of the proto file fails. The failure log is as follows:
  1. [ERROR] ... [0:0]: --grpc-java_out: protoc-gen-grpc-java: Plugin failed with status code 1.

The reason for this error may be that the Apple arm-based chip does not support software on the x86 platform. You can download the protoc-gen-grpc-java software used from https://repo.maven.apache.org/maven2/io/grpc/protoc-gen-grpc-java/, and the version information can be viewed from the grpc.java.artifact property under the protoc_rosetta profile in fe/fe-core/pom.xml. If the following error is reported after downloading and executing, it means that the current Mac cannot execute software based on x86 compiled software.

  1. zsh: bad CPU type in executable:./protoc-gen-grpc-java-1.34.0-osx-x86_64.exe

You can refer to the official documentation https://support.apple.com/en-us/102527 and install Rosetta to solve this problem.