Compiling the Version
A build.sh script is provided for compiling openGauss and generating the installation package. You can compile openGauss by using the script. You can also configure environment variables and run commands to compile openGauss.
This section describes the prerequisites and procedure for openGauss compilation. The following figure shows the compilation process.
Preparation Before Compiling
Downloading Code
Prerequisites
The git and git-lfs have been installed and configured on the local host.
Procedure
Run the following command to download the code and open-source and third-party software repository. [git ssh address] indicates the actual code download address. You can obtain them from the openGauss community.
[user@linux sda]$ git clone [git ssh address] openGauss-server [user@linux sda]$ git clone [git ssh address] openGauss-third_party [user@linux sda]$ # mkdir binarylibs For details about this comment, see the following note.
NOTE:
- openGauss-server: openGauss code repository.
- openGauss-third_party: open-source third-party software repository on which openGauss depends.
- binarylibs: package for storing the built open-source third-party software. You can obtain the package by referring to Compiling Open-source Software . Since compiling and building open-source software take a long time, we have compiled and built binarylibs using openGauss-third_party and compress and upload binarylibs to the Internet. You can download the compressed package by visiting https://opengauss.obs.cn-south-1.myhuaweicloud.com/1.0.0/openGauss-third_party_binarylibs.tar.gz. After the download is complete, decompress the package and rename the folder to binarylibs.
When the progress of each download reaches 100%, the download is successful.
Compiling Open-source Software
Compiling Open-source Software
Before compiling the openGauss, compile and build the open-source and third-party software on which the openGauss depends. These open-source and third-party software is stored in the openGauss-third_party code repository. After downloading the software, you can use git lfs pull to obtain large files from the code repository. Generally, you only need to build the software once. If the open-source software is updated, rebuild the software.
Since this step takes a long time, we have compiled and built binarylibs using openGauss-third_party. You can download the package by referring to Downloading Code.
Table 1 Requirements for the openGauss open-source and third-party software before compilation
In addition, you need to download the gcc-8.2.0.zip or gcc-8.2.0.tar.gz source code package of gcc8.2.0 and copy it to the corresponding path. For example, if the download directory of the open-source third-party software is /sda/openGauss-third_party, copy the gcc source code package to the /sda/openGauss-third_party/buildtools/gcc/ directory. After the software and gcc8.2.0 source code package in Table 1 are downloaded and copied to the corresponding path, point the default Python version to python3.x and perform the following operations:
Run the following commands to go to the directory of the open-source and third-party software on which the kernel depends, compile and build the open-source and third-party software, and generate binary programs or library files. /sda/openGauss-third_party is the directory for downloading open-source third-party software.
[user@linux sda]$ cd /sda/openGauss-third_party/build [user@linux build]$ sh build_all.sh
After the preceding commands are executed, the open-source and third-party software required for openGauss compilation is automatically generated. To generate any open-source and third-party software independently, go to the corresponding directory and run the build.sh script. For example:
[user@linux sda]$ cd /sda/openGauss-third_party/dependency/openssl [user@linux openssl]$ sh build.sh
The OpenSSL is generated.
NOTE: For error logs, you can view the corresponding log in the build directory and the log in the corresponding module. For example, you can view the OpenSSL compilation and installation logs in the dependency module.
- /sda/openGauss-third_party/build/dependency_build.log
- /sda/openGauss-third_party/dependency/build/openssl_build.log
- /sda/openGauss-third_party/dependency/openssl/build_openssl.log
Compilation and Build Result
After the preceding script is executed, the final compilation and build result is stored in the binarylibs directory at the same level as openGauss-third_party. These files will be used during the compilation of openGauss-server.
Introduction to build.sh
openGauss-server/build.sh is an important script tool during compilation. It integrates software installation and compilation and product installation package compilation functions to quickly compile and package code.
The following table describes the parameters.
Table 2 build.sh parameters
NOTE:
- -m [debug | release | memcheck] indicates that three target versions can be selected:
- release: indicates that the binary program of the release version is generated. During compilation of this version, the GCC high-level optimization option is configured to remove the kernel debugging code. This option is usually used in the generation environment or performance test environment.
- debug: indicates that a binary program of the debug version is generated. During compilation of this version, the kernel code debugging function is added, which is usually used in the development self-test environment.
- memcheck: indicates that a binary program of the memcheck version is generated. During compilation of this version, the ASAN function is added based on the debug version to locate memory problems.
- -3rd [binarylibs path] is the path of binarylibs. By default, binarylibs exists in the current code folder. If binarylibs is moved to openGauss-server or a soft link to binarylibs is created in openGauss-server, you do not need to specify the parameter. However, if you do so, please note that the file is easy to be deleted by the git clean command.
- Each option in this script has a default value. The number of options is small and the dependency is simple. Therefore, this script is easy to use. If the required value is different from the default value, set this parameter based on the actual requirements.
Software Compilation and Installation
Software compilation and installation are to compile code to generate software and install the software on a computer. The one-click compilation script build.sh is provided. You can also manually configure environment variables. The two methods are described below in this section.
Prerequisites
- The software and hardware have been prepared based on the requirements for setting up the compilation environment, and the code has been downloaded by referring to Downloading Code.
- The open-source software has been compiled and built. For details, see Compiling Open-source Software.
- You are familiar with the parameter options and functions of the build.sh script.
- The code environment is clean, and no file is generated before the current compilation. For details, see FAQ 4.1.
Compilation Using the One-click Script
Run the following command to go to the directory where the software code compilation script is stored:
[user@linux sda]$ cd /sda/openGauss-server
Run the following command to compile openGauss:
[user@linux openGauss-server]$ sh build.sh -m [debug | release | memcheck] -3rd [binarylibs path]
For example:
sh build.sh # Compile and install openGauss of the release version. binarylibs or its soft link must exist in the code directory. Otherwise, the operation fails. sh build.sh -m debug -3rd /sdc/binarylibs # Compile and install openGauss of the debug version.
If the following information is displayed, the compilation is successful:
make compile sucessfully!
- The software installation path after compilation is /sda/openGauss-server/dest.
- The compiled binary files are stored in /sda/openGauss-server/dest/bin.
- Compilation log: make_compile.log
Manual Compilation
Run the following command to go to the software code directory:
[user@linux sda]$ cd /sda/openGauss-server
Run the following script to obtain the system version:
[user@linux openGauss-server]$ sh src/get_PlatForm_str.sh
NOTE:
- The command output indicates the OSs supported by the openGauss. The OSs supported by the openGauss are centos7.6_x86_64 and openeuler_aarch64.
- If Failed or another version is displayed, the openGauss does not support the current operating system.
Configure environment variables, add ____ based on the code download location, and replace *** with the result obtained in Step 2.
export CODE_BASE=________ # Path of the openGauss-server file export BINARYLIBS=________ # Path of the binarylibs file export GAUSSHOME=$CODE_BASE/dest/ export GCC_PATH=$BINARYLIBS/buildtools/***/gcc8.2/ export CC=$GCC_PATH/gcc/bin/gcc export CXX=$GCC_PATH/gcc/bin/g++ export LD_LIBRARY_PATH=$GAUSSHOME/lib:$GCC_PATH/gcc/lib64:$GCC_PATH/isl/lib:$GCC_PATH/mpc/lib/:$GCC_PATH/mpfr/lib/:$GCC_PATH/gmp/lib/:$LD_LIBRARY_PATH export PATH=$GAUSSHOME/bin:$GCC_PATH/gcc/bin:$PATH
Select a version and configure it.
debug version:
./configure --gcc-version=8.2.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --without-readline --without-zlib
release version:
./configure --gcc-version=8.2.0 CC=g++ CFLAGS="-O2 -g3" --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-thread-safety --without-readline --without-zlib
memcheck version:
./configure --gcc-version=8.2.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --without-readline --without-zlib --enable-memory-check
NOTE:
- [debug | release | memcheck] indicates that three target versions are available. The three target versions are as follows:
- release: indicates that the binary program of the release version is generated. During compilation of this version, the GCC high-level optimization option is configured to remove the kernel debugging code. This option is usually used in the generation environment or performance test environment.
- debug: indicates that a binary program of the debug version is generated. During compilation of this version, the kernel code debugging function is added, which is usually used in the development self-test environment.
- memcheck: indicates that a binary program of the memcheck version is generated. During compilation of this version, the ASAN function is added based on the debug version to locate memory problems.
- On the ARM-based platform, -D__USE_NUMA needs to be added to CFLAGS.
- On the ARMv8.1 platform or a later version (for example, Kunpeng 920), -D__ARM_LSE needs to be added to CFLAGS.
- If binarylibs is moved to openGauss-server or a soft link to binarylibs is created in openGauss-server, you do not need to specify the --3rd parameter. However, if you do so, please note that the file is easy to be deleted by the git clean command.
Run the following commands to compile openGauss:
[user@linux openGauss-server]$ make -sj [user@linux openGauss-server]$ make install -sj
If the following information is displayed, the compilation and installation are successful:
openGauss installation complete.
- The software installation path after compilation is $GAUSSHOME.
- The compiled binary files are stored in $GAUSSHOME/bin.
Compiling the Installation Package
To compile the installation package is to compile the code and generate the software installation package. The compilation and packaging process of the installation package is also integrated in build.sh.
Prerequisites
- The software and hardware have been prepared based on the requirements for setting up the compilation environment, and the code has been downloaded by referring to Downloading Code.
- The open-source software has been compiled and built. For details, see Compiling Open-source Software.
- You are familiar with the parameter options and functions of the build.sh script.
- The code environment is clean, and no file is generated before the current compilation. For details, see FAQ 4.1.
Procedure
Run the following command to go to the code directory:
[user@linux sda]$ cd /sda/openGauss-server
Run the following command to compile the openGauss installation package:
[user@linux openGauss-server]$ sh build.sh -m [debug | release | memcheck] -3rd [binarylibs path] -pkg
For example:
sh build.sh -pkg # Generate the openGauss installation package of the release version. binarylibs or its soft link must exist in the code directory. Otherwise, the operation fails. sh build.sh -m debug -3rd /sdc/binarylibs -pkg # Generate the openGauss installation package of the debug version.
Compared with Software Compilation and Installation, this operation involves the process of generating software by one-click compilation and the process of encapsulating the software into an installation package. Compared with the build.sh command in Software Compilation and Installation, only the -pkg option is added.
NOTE:
If the following information is displayed, the installation package compilation is successful:
success!
- The generated installation package is stored in the ./package directory.
- Compilation log: make_compile.log
- Installation package packaging log: ./package/make_package.log