Compilation

This document focuses on how to code Doris through source code.

Use off-the-shelf mirrors

  1. Download Docker Mirror

    $ docker pull apache/incubator-doris:build-env-ldb-toolchain-latest

    Check mirror download completed:

    1. $ docker images
    2. REPOSITORY TAG IMAGE ID CREATED SIZE
    3. apache/incubator-doris build-env-ldb-toolchain-latest 49f68cecbc1a 4 days ago 3.76GB

Note1: For different versions of Doris, you need to download the corresponding mirror version. From Apache Doris 0.15 version, the docker image will keep same version number with Doris. For example, you can use apache/incubator-doris:build-env-for-0.15.0 to compile Apache Doris 0.15.0.

Node2: apache/incubator-doris:build-env-ldb-toolchain-latest is for compiling trunk code, and will be updated along with trunk code. View the update time in docker/README.md

image versioncommit idrelease version
apache/incubator-doris:build-envbefore ff0dd0dCompilation - 图1 (opens new window)0.8.x, 0.9.x
apache/incubator-doris:build-env-1.1ff0dd0dCompilation - 图2 (opens new window) or later0.10.x or later
apache/incubator-doris:build-env-1.24ef5a8cCompilation - 图3 (opens new window) or later0.12.x - 0.14.0
apache/incubator-doris:build-env-1.3.1ad67dd3Compilation - 图4 (opens new window) or later0.14.x
apache/incubator-doris:build-env-for-0.15.0a81f4daCompilation - 图5 (opens new window) or later0.15.0
apache/incubator-doris:build-env-latestbefore 0efef1bCompilation - 图6 (opens new window)
apache/incubator-doris:build-env-ldb-toolchain-latesttrunktrunk

note:

  1. Dev docker image ChangeLogCompilation - 图7 (opens new window)

  2. Doris version 0.14.0 still uses apache/incubator-doris:build-env-1.2 to compile, and the 0.14.x code will use apache/incubator-doris:build-env-1.3.1.

  3. From docker image of build-env-1.3.1, both OpenJDK 8 and OpenJDK 11 are included, and OpenJDK 11 is used for compilation by default. Please make sure that the JDK version used for compiling is the same as the JDK version used at runtime, otherwise it may cause unexpected operation errors. You can use the following command to switch the default JDK version in container:

Switch to JDK 8:

  1. $ alternatives --set java java-1.8.0-openjdk.x86_64
  2. $ alternatives --set javac java-1.8.0-openjdk.x86_64
  3. $ export JAVA_HOME=/usr/lib/jvm/java-1.8.0

Switch to JDK 11:

  1. $ alternatives --set java java-11-openjdk.x86_64
  2. $ alternatives --set javac java-11-openjdk.x86_64
  3. $ export JAVA_HOME=/usr/lib/jvm/java-11
  1. Running Mirror

    $ docker run -it apache/incubator-doris:build-env-ldb-toolchain-latest

    It is recommended to run the container by mounting the local Doris source directory, so that the compiled binary file will be stored in the host machine and will not disappear because the container exits.

    At the same time, it is recommended to mount the maven .m2 directory in the mirror to the host directory at the same time to prevent repeated downloading of maven’s dependent libraries each time the compilation is started.

    1. $ docker run -it -v /your/local/.m2:/root/.m2 -v /your/local/incubator-doris-DORIS-x.x.x-release/:/root/incubator-doris-DORIS-x.x.x-release/ apache/incubator-doris:build-env-ldb-toolchain-latest
  2. Download source code

    After starting the mirror, you should be in the container. The Doris source code can be downloaded from the following command (local source directory mounted is not required):

    1. $ wget https://dist.apache.org/repos/dist/dev/incubator/doris/xxx.tar.gz
    2. or
    3. $ git clone https://github.com/apache/incubator-doris.git
  3. Compile Doris

    1. $ sh build.sh

    ** Note: **

    If you are using build-env-for-0.15.0 or later version for the first time, use the following command when compiling:

    sh build.sh --clean --be --fe --ui

    This is because from build-env-for-0.15.0, we upgraded thrift (0.9 -> 0.13), you need to use the —clean command to force the use of the new version of thrift to generate code files, otherwise incompatible code will appear.

    After compilation, the output file is in the output/ directory.

Self-compiling Development Environment Mirror

You can also create a Doris development environment mirror yourself, referring specifically to the docker/README.md file.

Direct Compilation (CentOS/Ubuntu)

You can try to compile Doris directly in your own Linux environment.

  1. System Dependence

    • Before commit ad67dd3Compilation - 图8 (opens new window) will use the dependencies as follows:

      GCC 7.3+, Oracle JDK 1.8+, Python 2.7+, Apache Maven 3.5+, CMake 3.11+ Bison 3.0+

      If you are using Ubuntu 16.04 or newer, you can use the following command to install the dependencies

      sudo apt-get install build-essential openjdk-8-jdk maven cmake byacc flex automake libtool-bin bison binutils-dev libiberty-dev zip unzip libncurses5-dev curl git ninja-build python autopoint pkg-config

      If you are using CentOS you can use the following command to install the dependencies

      sudo yum groupinstall 'Development Tools' && sudo yum install maven cmake byacc flex automake libtool bison binutils-devel zip unzip ncurses-devel curl git wget python2 glibc-static libstdc++-static java-1.8.0-openjdk

    • After commit ad67dd3Compilation - 图9 (opens new window) will use the dependencies as follows:

      GCC 10+, Oracle JDK 1.8+, Python 2.7+, Apache Maven 3.5+, CMake 3.19.2+ Bison 3.0+

      If you are using Ubuntu 16.04 or newer, you can use the following command to install the dependencies

      1. sudo apt install build-essential openjdk-8-jdk maven cmake byacc flex automake libtool-bin bison binutils-dev libiberty-dev zip unzip libncurses5-dev curl git ninja-build python
      2. sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
      3. sudo apt update
      4. sudo apt install gcc-10 g++-10
      5. sudo apt-get install autoconf automake libtool autopoint

      If you are using CentOS you can use the following command to install the dependencies

      1. sudo yum groupinstall 'Development Tools' && sudo yum install maven cmake byacc flex automake libtool bison binutils-devel zip unzip ncurses-devel curl git wget python2 glibc-static libstdc++-static java-1.8.0-openjdk
      2. sudo yum install centos-release-scl
      3. sudo yum install devtoolset-10
      4. scl enable devtoolset-10 bash

      If devtoolset-10 is not found in current repo. Oracle has already rebuilt the devtoolset-10 packages. You can use this repo file:

      1. [ol7_software_collections]
      2. name=Software Collection packages for Oracle Linux 7 ($basearch)
      3. baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/SoftwareCollections/$basearch/
      4. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
      5. gpgcheck=1
      6. enabled=1

      After installation, set environment variables PATH, JAVA_HOME, etc.

      nit: you can find the jdk install directory by using command alternatives --list

      Doris 0.14.0 will use gcc7 env to compile.

  2. Compile Doris

    1. $ sh build.sh

    After compilation, the output file is in the output/ directory.

FAQ

  1. Could not transfer artifact net.sourceforge.czt.dev:cup-maven-plugin:pom:1.6-cdh from/to xxx

    If you encounter the above error, please refer to PR #4769Compilation - 图10 (opens new window) to modify the cloudera-related repo configuration in fe/pom.xml.

  2. The third party relies on download connection errors, failures, etc.

    The download links of the third-party libraries that Doris relies on are all in the thirdparty/vars.sh file. Over time, some download connections may fail. If you encounter this situation. It can be solved in the following two ways:

    1. Manually modify the thirdparty/vars.sh file

      Manually modify the problematic download connection and the corresponding MD5 value.

    2. Use a third-party download warehouse:

      1. export REPOSITORY_URL=https://doris-thirdparty-repo.bj.bcebos.com/thirdparty
      2. sh build-thirdparty.sh

      REPOSITORY_URL contains all third-party library source code packages and their historical versions.

Special statement

Starting from version 0.13, the dependency on the two third-party libraries [1] and [2] will be removed in the default compiled output. These two third-party libraries are under GNU General Public License V3Compilation - 图11 (opens new window). This license is incompatible with Apache License 2.0Compilation - 图12 (opens new window), so it should not appear in the Apache release by default.

Remove library [1] will result in the inability to access MySQL external tables. The feature of accessing MySQL external tables will be implemented through UnixODBC in future release version.

Remove library [2] will cause some data written in earlier versions (before version 0.8) to be unable to read. Because the data in the earlier version was compressed using the LZO algorithm, in later versions, it has been changed to the LZ4 compression algorithm. We will provide tools to detect and convert this part of the data in the future.

If required, users can continue to use these two dependent libraries. If you want to use it, you need to add the following options when compiling:

  1. WITH_MYSQL=1 WITH_LZO=1 sh build.sh

Note that when users rely on these two third-party libraries, Doris is not used under the Apache License 2.0 by default. Please pay attention to the GPL related agreements.

  • [1] mysql-5.7.18
  • [2] lzo-2.10