From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-f67.google.com (mail-ot1-f67.google.com [209.85.210.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 46E74469719 for ; Thu, 10 Sep 2020 13:00:20 +0300 (MSK) Received: by mail-ot1-f67.google.com with SMTP id e23so4844407otk.7 for ; Thu, 10 Sep 2020 03:00:20 -0700 (PDT) MIME-Version: 1.0 References: <20200909154546.1850-1-huston.mavr@gmail.com> In-Reply-To: <20200909154546.1850-1-huston.mavr@gmail.com> From: Alexandr Barulev Date: Thu, 10 Sep 2020 13:00:05 +0300 Message-ID: Content-Type: multipart/alternative; boundary="000000000000a97c9d05aef2a2c2" Subject: Re: [Tarantool-patches] [PATCH v3] build: refactor static build process List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, Yaroslav Dynnikov , Alexander Turenko , Igor Munkin --000000000000a97c9d05aef2a2c2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello! Here is a new commit message(as discussed at telegram chat): Author: HustonMmmavr Date: Thu Sep 10 12:43:20 2020 +0300 build: refactor static build process Refactored static build process to use static-build/CMakeLists.txt instead of Dockerfile.staticbuild (this allows to support static build on macOS). Following third-party dependencies for static build are installed via cmake `ExternalProject_Add`: - OpenSSL - Zlib - Ncurses - Readline - Unwind - ICU * Added support static build for macOS * Fixed `CONFIGURE_COMMAND` while building bundled libcurl for static build at file cmake/BuildLibCURL.cmake: - disable building shared libcurl libraries (by setting `--disable-shared` option) - disable hiding libcurl symbols (by setting `--disable-symbol-hiding` option) - prevent linking libcurl with system libz (by setting `--with-zlib=3D${FOUND_ZLIB_ROOT_DIR}` option) * Removed Dockerfile.staticbuild * Added new gitlab.ci jobs to test new style static build: - static_build_cmake_linux - static_build_cmake_osx_15 * Removed static_docker_build gitlab.ci job Closes #5095 Co-authored-by: Yaroslav Dynnikov =D1=81=D1=80, 9 =D1=81=D0=B5=D0=BD=D1=82. 2020 =D0=B3. =D0=B2 18:45, Huston= Mmmavr : > From: Yaroslav Dynnikov > > Refactored static build process to use static-build/CMakeLists.txt > instead of Dockerfile.staticbuild (this allows to support static > build on macOS). Following third-party dependencies for static build > are installed via cmake `ExternalProject_Add`: > - OpenSSL > - Zlib > - Ncurses > - Readline > - Unwind > - ICU > > * Added support static build for macOS > * Fixed `CONFIGURE_COMMAND` while building bundled libcurl for static > build at file cmake/BuildLibCURL.cmake: > - disable building shared libcurl libraries (by setting > `--disable-shared` option) > - disable hiding libcurl symbols (by setting > `--disable-symbol-hiding` option) > - prevent linking libcurl with system libz (by setting > `--with-zlib=3D${FOUND_ZLIB_ROOT_DIR}` option) > * Removed Dockerfile.staticbuild > * Added new gitlab.ci jobs to test new style static build: > - static_build_cmake_linux > - static_build_cmake_osx_15 > * Removed static_docker_build gitlab.ci job > > Closes #5095 > --- > > Branch: > https://github.com/tarantool/tarantool/tree/rosik/refactor-static-build > Issue: https://github.com/tarantool/tarantool/issues/5095 > > Changes in v3: > 1. Fixed typos at commit message > 2. Fixed commentaries at .travis.mk > 3. Fixed finding libz library at cmake/BuildLibCurl.cmake as at master > branch > 4. Instead of using static-build/.gitignore use the root .gitignore file > 5. Refactored static-build/CMakeLists.txt: > * Project name is set to tarantool-static > * Instead of explicitly finding of c/c++ compilers current version use= s > cmake `project(tarantool-static C CXX)` command. This change require= s > to manually set CFLAGS/CPPFLAGS/LDFLAGS for all static-build > dependencies (because building dependencies at macOS requires path > to macOS SDK) the idea was taken from cmake/BuildLibCurl.cmake > * Added commentaries about problem with libicu > * Removed unused TEST_COMMAND at ExternalProject_Add(zlib ...) also > removed unnecessary # STEP_TARGETS at ExternalProject_Add(readline > ...) > * Deleted doubled whitespaces > 6. Fixed static-build/README.md: > * Added list of required tools > * Added example for ubuntu/debian > * Fixed indentation and typos > 7. Refactored tests: > * Got rid of test-run > * Deleted doubled whitespaces at exports.test.lua > * Fixed defining of RTLD_DEFAULT > > > .gitignore | 8 + > .gitlab-ci.yml | 11 +- > .travis.mk | 56 +++- > Dockerfile.staticbuild | 98 ------ > cmake/BuildLibCURL.cmake | 13 +- > cmake/compiler.cmake | 24 +- > cmake/os.cmake | 5 +- > static-build/CMakeLists.txt | 311 ++++++++++++++++++ > static-build/README.md | 90 +++++ > static-build/test/CheckDependencies.cmake | 43 +++ > .../test/static-build/exports.test.lua | 142 ++++++++ > .../test/static-build/traceback.test.lua | 15 + > 12 files changed, 692 insertions(+), 124 deletions(-) > delete mode 100644 Dockerfile.staticbuild > create mode 100644 static-build/CMakeLists.txt > create mode 100644 static-build/README.md > create mode 100644 static-build/test/CheckDependencies.cmake > create mode 100755 static-build/test/static-build/exports.test.lua > create mode 100755 static-build/test/static-build/traceback.test.lua > > diff --git a/.gitignore b/.gitignore > index a42c7db35..c6e261e18 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -151,3 +151,11 @@ src/box/sql/parse.h > src/box/sql/parse.c > src/box/sql/opcodes.h > src/box/sql/opcodes.c > + > +# static-build > +static-build/*-prefix > +static-build/Makefile > +static-build/build > + > +# macOS files > +.DS_Store > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml > index 0ead08711..c9aef3dc7 100644 > --- a/.gitlab-ci.yml > +++ b/.gitlab-ci.yml > @@ -534,9 +534,14 @@ static_build: > script: > - ${GITLAB_MAKE} test_static_build > > -static_docker_build: > +static_build_cmake_linux: > + <<: *docker_test_definition > + script: > + - ${GITLAB_MAKE} test_static_build_cmake_linux > + > +static_build_cmake_osx_15: > stage: test > tags: > - - deploy_test > + - osx_15 > script: > - - ${GITLAB_MAKE} test_static_docker_build > + - ${GITLAB_MAKE} test_static_build_cmake_osx > diff --git a/.travis.mk b/.travis.mk > index efc05cf05..58d0c1596 100644 > --- a/.travis.mk > +++ b/.travis.mk > @@ -148,8 +148,14 @@ deps_debian_static: > test_static_build: deps_debian_static > CMAKE_EXTRA_PARAMS=3D-DBUILD_STATIC=3DON make -f .travis.mk > test_debian_no_deps > > -test_static_docker_build: > - docker build --no-cache --network=3Dhost --build-arg RUN_TESTS=3D= ON -f > Dockerfile.staticbuild . > +# New static build > +# builddir used in this target - is a default build path from cmake > +# ExternalProject_Add() > +test_static_build_cmake_linux: > + cd static-build && cmake > -DCMAKE_TARANTOOL_ARGS=3D"-DCMAKE_BUILD_TYPE=3DRelWithDebInfo;-DENABLE_WE= RROR=3DON" > . && \ > + make -j && ctest -V > + cd test && /usr/bin/python test-run.py --force \ > + --builddir > ${PWD}/static-build/tarantool-prefix/src/tarantool-build > $(TEST_RUN_EXTRA_PARAMS) > > # ################### > # Static Analysis > @@ -193,15 +199,16 @@ build_osx: > cmake . -DCMAKE_BUILD_TYPE=3DRelWithDebInfo -DENABLE_WERROR=3DON > ${CMAKE_EXTRA_PARAMS} > make -j > > -test_osx_no_deps: build_osx > - # Limits: Increase the maximum number of open file descriptors on > macOS: > - # Travis-ci needs the "ulimit -n " call > - # Gitlab-ci needs the "launchctl limit maxfiles " call > - # Also gitlib-ci needs the password to change the limits, while > - # travis-ci runs under root user. Limit setup must be in the same > - # call as tests runs call. > - # Tests: Temporary excluded replication/ suite with some tests > - # from other suites by issues #4357 and #4370 > + > +# Limits: Increase the maximum number of open file descriptors on macOS: > +# Travis-ci needs the "ulimit -n " call > +# Gitlab-ci needs the "launchctl limit maxfiles " call > +# Also gitlib-ci needs the password to change the limits, while > +# travis-ci runs under root user. Limit setup must be in the same > +# call as tests runs call. > +# Tests: Temporary excluded replication/ suite with some tests > +# from other suites by issues #4357 and #4370 > +INIT_TEST_ENV_OSX=3D\ > sudo -S launchctl limit maxfiles ${MAX_FILES} || : ; \ > launchctl limit maxfiles || : ; \ > ulimit -n ${MAX_FILES} || : ; \ > @@ -210,11 +217,34 @@ test_osx_no_deps: build_osx > launchctl limit maxproc || : ; \ > ulimit -u ${MAX_PROC} || : ; \ > ulimit -u ; \ > - rm -rf /tmp/tnt ; \ > - cd test && ./test-run.py --vardir /tmp/tnt --force > $(TEST_RUN_EXTRA_PARAMS) > + rm -rf /tmp/tnt > + > +test_osx_no_deps: build_osx > + ${INIT_TEST_ENV_OSX}; \ > + cd test && ./test-run.py --vardir /tmp/tnt --force > $(TEST_RUN_EXTRA_PARAMS) > > test_osx: deps_osx test_osx_no_deps > > +# Static macOS build > + > +STATIC_OSX_PKGS=3Dautoconf automake libtool cmake > file://$${PWD}/tools/brew_taps/tntpython2.rb > +base_deps_osx: > + brew update || echo | /usr/bin/ruby -e \ > + "$$(curl -fsSL > https://raw.githubusercontent.com/Homebrew/install/master/install)" > + brew install --force ${STATIC_OSX_PKGS} || brew upgrade > ${STATIC_OSX_PKGS} > + pip install --force-reinstall -r test-run/requirements.txt > + > +# builddir used in this target - is a default build path from cmake > +# ExternalProject_Add() > +test_static_build_cmake_osx: base_deps_osx > + cd static-build && cmake > -DCMAKE_TARANTOOL_ARGS=3D"-DCMAKE_BUILD_TYPE=3DRelWithDebInfo;-DENABLE_WE= RROR=3DON" > . && \ > + make -j && ctest -V > + ${INIT_TEST_ENV_OSX}; \ > + cd test && ./test-run.py --vardir /tmp/tnt \ > + --builddir > ${PWD}/static-build/tarantool-prefix/src/tarantool-build \ > + --force $(TEST_RUN_EXTRA_PARAMS) > + > + > ########### > # FreeBSD # > ########### > diff --git a/Dockerfile.staticbuild b/Dockerfile.staticbuild > deleted file mode 100644 > index f67f46f5e..000000000 > --- a/Dockerfile.staticbuild > +++ /dev/null > @@ -1,98 +0,0 @@ > -FROM centos:7 > - > -RUN yum install -y epel-release > -RUN yum install -y yum install > https://centos7.iuscommunity.org/ius-release.rpm > - > -RUN set -x \ > - && yum -y install \ > - libstdc++ \ > - libstdc++-static \ > - readline \ > - openssl \ > - lz4 \ > - binutils \ > - ncurses \ > - libgomp \ > - lua \ > - curl \ > - tar \ > - zip \ > - unzip \ > - libunwind \ > - zlib \ > - && yum -y install \ > - perl \ > - gcc-c++ \ > - cmake \ > - lz4-devel \ > - binutils-devel \ > - lua-devel \ > - make \ > - git \ > - autoconf \ > - automake \ > - libtool \ > - wget > - > -RUN yum -y install ncurses-static readline-static zlib-static pcre-stati= c > glibc-static > - > -RUN yum -y install python-devel python-pip > - > -RUN set -x && \ > - cd / && \ > - curl -O -L https://www.openssl.org/source/openssl-1.1.1f.tar.gz && \ > - tar -xvf openssl-1.1.1f.tar.gz && \ > - cd openssl-1.1.1f && \ > - ./config --libdir=3Dlib && \ > - make -j && make install > - > -RUN set -x && \ > - cd / && \ > - curl -O -L > https://github.com/unicode-org/icu/releases/download/release-62-1/icu4c-6= 2_1-src.tgz > && \ > - tar -xvf icu4c-62_1-src.tgz && \ > - cd icu/source && \ > - ./configure --with-data-packaging=3Dstatic --enable-static > --enable-shared && \ > - make -j && make install > - > -RUN set -x && \ > - cd / && \ > - curl -O -L > http://download.savannah.nongnu.org/releases/libunwind/libunwind-1.3-rc1.= tar.gz > && \ > - tar -xvf libunwind-1.3-rc1.tar.gz && \ > - cd libunwind-1.3-rc1 && \ > - ./configure --enable-static --enable-shared && \ > - make -j && make install > - > -COPY . /tarantool > - > -WORKDIR /tarantool > - > -RUN set -x && \ > - git submodule init && \ > - git submodule update > - > -# Cleanup for 'build' directory added, because it purges all artefacts > -# produced for curl build, including the old configuration in build/curl > -RUN set -x && \ > - find . -name 'CMakeFiles' -type d -exec rm -rf {} + && \ > - find . -name 'CMakeCache.txt' -type f -delete && \ > - rm -rf build test/small test/luajit-tap > - > -RUN pip install -r /tarantool/test-run/requirements.txt > - > -RUN set -x && \ > - cmake -DCMAKE_BUILD_TYPE=3DRelWithDebInfo \ > - -DENABLE_DIST:BOOL=3DON \ > - -DBUILD_STATIC=3DON \ > - -DOPENSSL_USE_STATIC_LIBS=3DON \ > - -DOPENSSL_ROOT_DIR=3D/usr/local \ > - . && \ > - make -j && make install > - > -ARG RUN_TESTS > -RUN if [ -n "${RUN_TESTS}" ]; then \ > - set -x && \ > - cd test && \ > - /usr/bin/python test-run.py --force; \ > - fi > - > -ENTRYPOINT ["/bin/bash"] > diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake > index 5f8b15a63..86fec39e9 100644 > --- a/cmake/BuildLibCURL.cmake > +++ b/cmake/BuildLibCURL.cmake > @@ -4,15 +4,21 @@ macro(curl_build) > set(LIBCURL_BINARY_DIR ${PROJECT_BINARY_DIR}/build/curl/work) > set(LIBCURL_INSTALL_DIR ${PROJECT_BINARY_DIR}/build/curl/dest) > > + message(STATUS "Looking for zlib") > + find_path(ZLIB_INCLUDE_DIR zlib.h) > + message(STATUS "Looking for zlib.h - ${ZLIB_INCLUDE_DIR}") > if (BUILD_STATIC) > set(LIBZ_LIB_NAME libz.a) > else() > set(LIBZ_LIB_NAME z) > endif() > find_library(LIBZ_LIBRARY NAMES ${LIBZ_LIB_NAME}) > - if ("${LIBZ_LIBRARY}" STREQUAL "LIBZ_LIBRARY-NOTFOUND") > + message(STATUS "Looking for libz - ${LIBZ_LIBRARY}") > + > + if (NOT ZLIB_INCLUDE_DIR OR NOT LIBZ_LIBRARY) > message(FATAL_ERROR "Unable to find zlib") > endif() > + get_filename_component(FOUND_ZLIB_ROOT_DIR ${ZLIB_INCLUDE_DIR} > DIRECTORY) > > # Use the same OpenSSL library for libcurl as is used for > # tarantool itself. > @@ -88,9 +94,10 @@ macro(curl_build) > > --prefix > --enable-static > - --enable-shared > + --disable-shared > + --disable-symbol-hiding > > - --with-zlib > + --with-zlib=3D${FOUND_ZLIB_ROOT_DIR} > ${LIBCURL_OPENSSL_OPT} > --with-ca-fallback > > diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake > index 5a1141ebd..db2ae6227 100644 > --- a/cmake/compiler.cmake > +++ b/cmake/compiler.cmake > @@ -33,10 +33,6 @@ if (CMAKE_COMPILER_IS_GNUCC) > Your GCC version is ${CMAKE_CXX_COMPILER_VERSION}, please > update > ") > endif() > -else() > - if (BUILD_STATIC) > - message(FATAL_ERROR "Static build is supported for GCC only") > - endif() > endif() > > # > @@ -120,10 +116,23 @@ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO > > unset(CC_DEBUG_OPT) > > +message(STATUS "Looking for libunwind.h") > +find_path(UNWIND_INCLUDE_DIR libunwind.h) > +message(STATUS "Looking for libunwind.h - ${UNWIND_INCLUDE_DIR}") > + > +if (UNWIND_INCLUDE_DIR) > + include_directories(${UNWIND_INCLUDE_DIR}) > +endif() > + > +set(CMAKE_REQUIRED_INCLUDES ${UNWIND_INCLUDE_DIR}) > check_include_file(libunwind.h HAVE_LIBUNWIND_H) > -if(BUILD_STATIC) > +set(CMAKE_REQUIRED_INCLUDES "") > + > +if(BUILD_STATIC AND NOT TARGET_OS_DARWIN) > set(UNWIND_LIB_NAME libunwind.a) > else() > + # libunwind can't be compiled on macOS. > + # But there exists libunwind.dylib as a part of MacOSSDK > set(UNWIND_LIB_NAME unwind) > endif() > find_library(UNWIND_LIBRARY PATH_SUFFIXES system NAMES ${UNWIND_LIB_NAME= }) > @@ -185,7 +194,10 @@ if (ENABLE_BACKTRACE) > find_package_message(UNWIND_LIBRARIES "Found unwind" > "${UNWIND_LIBRARIES}") > endif() > > -if(BUILD_STATIC) > +# On macOS there is no '-static-libstdc++' flag and it's use will > +# raise following error: > +# error: argument unused during compilation: '-static-libstdc++' > +if(BUILD_STATIC AND NOT TARGET_OS_DARWIN) > # Static linking for c++ routines > add_compile_flags("C;CXX" "-static-libstdc++") > endif() > diff --git a/cmake/os.cmake b/cmake/os.cmake > index 905be61df..276a79b42 100644 > --- a/cmake/os.cmake > +++ b/cmake/os.cmake > @@ -107,7 +107,10 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") > > # Latest versions of Homebrew wont 'link --force' for libraries, tha= t > were > # preinstalled in system. So we'll use this dirty hack > - find_program(HOMEBREW_EXECUTABLE brew) > + > + if (NOT BUILD_STATIC) > + find_program(HOMEBREW_EXECUTABLE brew) > + endif() > if(EXISTS ${HOMEBREW_EXECUTABLE}) > execute_process(COMMAND ${HOMEBREW_EXECUTABLE} --prefix > OUTPUT_VARIABLE HOMEBREW_PREFIX > diff --git a/static-build/CMakeLists.txt b/static-build/CMakeLists.txt > new file mode 100644 > index 000000000..90029fdd8 > --- /dev/null > +++ b/static-build/CMakeLists.txt > @@ -0,0 +1,311 @@ > +cmake_minimum_required(VERSION 2.8) > + > +# Detect system compilers for further configuring dependencies to be > +# builded with these compilers. This is used to build tarantool and > +# it's dependencies by usign one compiler system (for example libicu > +# by default uses clang if it exists when others uses gcc/g++ on > +# linux machine). > +project(tarantool-static C CXX) > + > +include(ExternalProject) > +set(OPENSSL_VERSION 1.1.1f) > +set(ZLIB_VERSION 1.2.11) > +set(NCURSES_VERSION 6.2) > +set(READLINE_VERSION 8.0) > +set(UNWIND_VERSION 1.3-rc1) > + > +# Pass -isysroot=3D option on Mac OS to a preprocessor and a C > +# compiler to find header files installed with an SDK. > +# > +# The idea is to set these (DEPENDENCY_*) variables to corresponding > +# environment variables at each depenency configure script. > +# > +# Note: Passing of CPPFLAGS / CFLAGS explicitly discards using of > +# corresponsing environment variables. So pass empty LDFLAGS to discard > +# using of corresponding environment variable. It is possible that a > +# linker flag assumes that some compilation flag is set. We don't pass > +# CFLAGS from environment, so we should not do it for LDFLAGS too. > +set(DEPENDENCY_CFLAGS "") > +set(DEPENDENCY_CPPFLAGS "") > +set(DEPENDENCY_LDFLAGS) > +if (APPLE) > + set(DEPENDENCY_CFLAGS "${CMAKE_C_SYSROOT_FLAG} > ${CMAKE_OSX_SYSROOT}") > + set(DEPENDENCY_CPPFLAGS "${CMAKE_C_SYSROOT_FLAG} > ${CMAKE_OSX_SYSROOT}") > +endif() > + > +# Install all libraries required by tarantool at current build dir > + > +# > +# OpenSSL > +# > +ExternalProject_Add(openssl > + URL https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz > + CONFIGURE_COMMAND /config > + CC=3D${CMAKE_C_COMPILER} > + CXX=3D${CMAKE_CXX_COMPILER} > + CFLAGS=3D${DEPENDENCY_CFLAGS} > + CPPFLAGS=3D${DEPENDENCY_CPPFLAGS} > + LDFLAGS=3D${DEPENDENCY_LDFLAGS} > + > + --prefix=3D > + --libdir=3Dlib > + no-shared > + INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install_sw > +) > + > +# > +# ICU > +# > +ExternalProject_Add(icu > + URL > https://github.com/unicode-org/icu/releases/download/release-62-1/icu4c-6= 2_1-src.tgz > + # By default libicu is built by using clang/clang++ compiler (if it > + # exists). Here is a link for detecting compilers at libicu configur= e > + # script: > https://github.com/unicode-org/icu/blob/7c7b8bd5702310b972f888299169bc3cc= 88bf0a6/icu4c/source/configure.ac#L135 > + # This will cause the problem on linux machine: tarantool is built > + # with gcc/g++ and libicu is built with clang/clang++ (if it exists) > + # so at linking stage `rellocation` errors will occur. To solve this= , > + # we can set CC/CXX to CMAKE_C_COMPILER/CMAKE_CXX_COMPILER variables > + # manually which are detected above (by cmake `project()` command) > + CONFIGURE_COMMAND /source/configure > + CC=3D${CMAKE_C_COMPILER} > + CXX=3D${CMAKE_CXX_COMPILER} > + CFLAGS=3D${DEPENDENCY_CFLAGS} > + CPPFLAGS=3D${DEPENDENCY_CPPFLAGS} > + LDFLAGS=3D${DEPENDENCY_LDFLAGS} > + > + --with-data-packaging=3Dstatic > + --prefix=3D > + --disable-shared > + --enable-static > +) > + > +# > +# ZLIB > +# > +ExternalProject_Add(zlib > + URL https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz > + CONFIGURE_COMMAND env > + CC=3D${CMAKE_C_COMPILER} > + CFLAGS=3D${DEPENDENCY_CFLAGS} > + CPPFLAGS=3D${DEPENDENCY_CPPFLAGS} > + LDFLAGS=3D${DEPENDENCY_LDFLAGS} > + /configure > + --prefix=3D > + --static > +) > + > +# > +# Ncurses > +# > +ExternalProject_Add(ncurses > + URL https://ftp.gnu.org/gnu/ncurses/ncurses-${NCURSES_VERSION}.tar.g= z > + CONFIGURE_COMMAND /configure > + CC=3D${CMAKE_C_COMPILER} > + CXX=3D${CMAKE_CXX_COMPILER} > + CFLAGS=3D${DEPENDENCY_CFLAGS} > + CPPFLAGS=3D${DEPENDENCY_CPPFLAGS} > + LDFLAGS=3D${DEPENDENCY_LDFLAGS} > + > + --prefix=3D > + > + # This flag enables creation of libcurses.a as a symlink to > libncurses.a > + # and disables subdir creation `ncurses` at > /include. It is > + # necessary for correct work of FindCurses.cmake module (this > module is > + # builtin at cmake package) which used in cmake/FindReadline.cma= ke > + --enable-overwrite > + > + # enable building libtinfo to prevent linking with libtinfo from > system > + # directories > + --with-termlib > + > + # set search paths for terminfo db > + > --with-terminfo-dirs=3D/lib/terminfo:/usr/share/terminfo:/etc/terminfo > + > + # disable install created terminfo db, use db from system > + --disable-db-install > + --without-progs > + --without-manpages > +) > + > +# > +# ReadLine > +# > +ExternalProject_Add(readline > + URL > https://ftp.gnu.org/gnu/readline/readline-${READLINE_VERSION}.tar.gz > + CONFIGURE_COMMAND /configure > + CC=3D${CMAKE_C_COMPILER} > + CFLAGS=3D${DEPENDENCY_CFLAGS} > + CPPFLAGS=3D${DEPENDENCY_CPPFLAGS} > + LDFLAGS=3D${DEPENDENCY_LDFLAGS} > + > + --prefix=3D > + --disable-shared > +) > + > +# > +# ICONV > +# > +if (APPLE) > + ExternalProject_Add(iconv > + URL https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz > + CONFIGURE_COMMAND /configure > + CC=3D${CMAKE_C_COMPILER} > + CFLAGS=3D${DEPENDENCY_CFLAGS} > + CPPFLAGS=3D${DEPENDENCY_CPPFLAGS} > + LDFLAGS=3D${DEPENDENCY_LDFLAGS} > + > + --prefix=3D > + --disable-shared > + --enable-static > + --with-gnu-ld > + STEP_TARGETS download > + ) > +else() > + # In linux iconv is embedded into glibc > + # So we find system header and copy it locally > + find_path(ICONV_INCLUDE_DIR iconv.h) > + if(NOT ICONV_INCLUDE_DIR) > + message(FATAL_ERROR "iconv include header not found") > + endif() > + > + set(ICONV_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/iconv-prefix") > + > + add_custom_command( > + OUTPUT "${ICONV_INSTALL_PREFIX}/include/iconv.h" > + COMMAND ${CMAKE_COMMAND} -E make_directory > + "${ICONV_INSTALL_PREFIX}/include" > + COMMAND ${CMAKE_COMMAND} -E copy > + "${ICONV_INCLUDE_DIR}/iconv.h" > + "${ICONV_INSTALL_PREFIX}/include/iconv.h" > + ) > + add_custom_target(iconv > + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/iconv-prefix/include/iconv.= h" > + ) > + # This is a hack for further getting install directory of library > + # by ExternalProject_Get_Property > + set_target_properties(iconv > + PROPERTIES _EP_INSTALL_DIR ${ICONV_INSTALL_PREFIX} > + ) > +endif() > + > +# > +# Unwind > +# > +if (APPLE) > + # On macOS libunwind is a part of MacOSX.sdk > + # So we need to find library and header and > + # copy it locally > + find_path(UNWIND_INCLUDE_DIR libunwind.h) > + find_library(UNWIND_LIBRARY libunwind.dylib > + PATH_SUFFIXES system > + ) > + > + set(UNWIND_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/unwind-prefix= ") > + > + set(UNWIND_DEPENDENCIES) > + > + if (UNWIND_INCLUDE_DIR AND UNWIND_LIBRARY) > + add_custom_command( > + OUTPUT "${UNWIND_INSTALL_PREFIX}/include/unwind.h" > + OUTPUT "${UNWIND_INSTALL_PREFIX}/include/libunwind.h" > + COMMAND ${CMAKE_COMMAND} -E make_directory > + "${UNWIND_INSTALL_PREFIX}/include" > + COMMAND ${CMAKE_COMMAND} -E copy > + "${UNWIND_INCLUDE_DIR}/libunwind.h" > + "${UNWIND_INCLUDE_DIR}/unwind.h" > + "${UNWIND_INSTALL_PREFIX}/include/" > + ) > + add_custom_command( > + OUTPUT "${UNWIND_INSTALL_PREFIX}/lib/libunwind.dylib" > + COMMAND ${CMAKE_COMMAND} -E make_directory > + "${UNWIND_INSTALL_PREFIX}/lib" > + COMMAND ${CMAKE_COMMAND} -E copy > + "${UNWIND_LIBRARY}" > + "${UNWIND_INSTALL_PREFIX}/lib/" > + ) > + set(UNWIND_DEPENDENCIES > + ${UNWIND_DEPENDENCIES} > + "${UNWIND_INSTALL_PREFIX}/lib/libunwind.dylib" > + "${UNWIND_INSTALL_PREFIX}/include/libunwind.h" > + ) > + else() > + message(STATUS "Unwind not found") > + endif() > + > + add_custom_target(unwind DEPENDS ${UNWIND_DEPENDENCIES}) > + # This is a hack for further getting install directory of library > + # by ExternalProject_Get_Property > + set_target_properties(unwind > + PROPERTIES _EP_INSTALL_DIR ${UNWIND_INSTALL_PREFIX} > + ) > +else() > + ExternalProject_Add(unwind > + URL > https://download.savannah.nongnu.org/releases/libunwind/libunwind-${UNWIN= D_VERSION}.tar.gz > + CONFIGURE_COMMAND /configure > + CC=3D${CMAKE_C_COMPILER} > + CXX=3D${CMAKE_CXX_COMPILER} > + CFLAGS=3D${DEPENDENCY_CFLAGS} > + CPPFLAGS=3D${DEPENDENCY_CPPFLAGS} > + LDFLAGS=3D${DEPENDENCY_LDFLAGS} > + --prefix=3D > + --disable-shared > + --enable-static > + --disable-minidebuginfo # to prevent linking with liblzma > + STEP_TARGETS download > + ) > +endif() > + > +# Get install directories of builded libraries for building > +# tarantool with custon CMAKE_PREFIX_PATH > +foreach(PROJ openssl icu zlib ncurses readline iconv unwind) > + ExternalProject_Get_Property(${PROJ} install_dir) > + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:${install_dir}) > + set(TARANTOOL_DEPENDS ${PROJ} ${TARANTOOL_DEPENDS}) > + message(STATUS "Add external project ${PROJ} in ${install_dir}") > +endforeach() > + > +ExternalProject_Add(tarantool > + DEPENDS ${TARANTOOL_DEPENDS} > + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/.. > + LIST_SEPARATOR : > + CMAKE_ARGS > + # Override LOCALSTATEDIR to avoid cmake "special" cases: > + # > https://cmake.org/cmake/help/v3.4/module/GNUInstallDirs.html#special-case= s > + -DCMAKE_INSTALL_LOCALSTATEDIR=3D/var > + -DCMAKE_INSTALL_PREFIX=3D > + -DCMAKE_PREFIX_PATH=3D${CMAKE_PREFIX_PATH} > + -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=3DFALSE > + -DOPENSSL_USE_STATIC_LIBS=3DTRUE > + -DBUILD_STATIC=3DTRUE > + -DENABLE_DIST=3DTRUE > + -DENABLE_BACKTRACE=3DTRUE > + -DCMAKE_C_COMPILER=3D${CMAKE_C_COMPILER} > + -DCMAKE_CXX_COMPILER=3D${CMAKE_CXX_COMPILER} > + ${CMAKE_TARANTOOL_ARGS} > + STEP_TARGETS build > + BUILD_COMMAND $(MAKE) > +) > + > +enable_testing() > +ExternalProject_Get_Property(tarantool binary_dir) > +SET(TARANTOOL_BINARY_DIR ${binary_dir}) > + > +add_test( > + NAME check-dependencies > + COMMAND ${CMAKE_COMMAND} > + -D FILE=3D${TARANTOOL_BINARY_DIR}/src/tarantool > + -P CheckDependencies.cmake > + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test > +) > + > +add_test( > + NAME check-exports > + COMMAND ${TARANTOOL_BINARY_DIR}/src/tarantool > + ${CMAKE_CURRENT_SOURCE_DIR}/test/static-build/exports.test.l= ua > +) > + > +add_test( > + NAME check-traceback > + COMMAND ${TARANTOOL_BINARY_DIR}/src/tarantool > + > ${CMAKE_CURRENT_SOURCE_DIR}/test/static-build/traceback.test.lua > +) > diff --git a/static-build/README.md b/static-build/README.md > new file mode 100644 > index 000000000..2219b5026 > --- /dev/null > +++ b/static-build/README.md > @@ -0,0 +1,90 @@ > +# Tarantool static build tooling > + > +These files help to prepare environment for building Tarantool > +statically. And builds it. > + > +## Prerequisites > + > +Please install following tools and libraries that will > +be necessary for building and testing: > +* git > +* A C/C++ compiler. > + > + Ordinarily, this is gcc and g++ version 4.6 or later. On Mac OS X, thi= s > + is Clang version 3.2+. > +* cmake > +* autoconf automake libtool > +* make > +* Python and modules. > + > + Python interpreter is not necessary for building Tarantool itself, > unless you > + intend to use the =E2=80=9CRun the test suite". For all platforms, thi= s is > python > + version 2.7+ (but not 3.x). You need the following Python modules: > + * pyyaml > + * argparse > + * msgpack-python > + * gevent > + * six > + > +### Here is an examples for your OS: > + > +CentOS: > + > +```bash > +yum install -y \ > + git perl gcc cmake make gcc-c++ libstdc++-static autoconf automake > libtool \ > + python-msgpack python-yaml python-argparse python-six python-gevent > +``` > + > +Ubuntu/Debian: > + > +```bash > +apt-get install -y \ > + build-essential cmake make coreutils autoconf automake libtool sed \ > + python python-pip python-setuptools python-dev \ > + python-msgpack python-yaml python-argparse python-six python-gevent > +``` > + > +MacOS: > + > +Before you start please install default Xcode Tools by Apple: > + > +```bash > +sudo xcode-select --install > +sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer > +``` > + > +Install brew using command from > +[Homebrew repository instructions](https://github.com/Homebrew/inst) > + > +After that run next script: > + > +```bash > +brew install autoconf automake libtool cmake > file://$${PWD}/tools/brew_taps/tntpython2.rbs > +pip install --force-reinstall -r test-run/requirements.txt > +``` > + > +## Usage > + > +```bash > +cmake . > +make -j > +ctest -V > +``` > + > +## Customize your build > + > +If you want to customise build, you need to set `CMAKE_TARANTOOL_ARGS` > variable > + > +### Usage > + > +There are three types of `CMAKE_BUILD_TYPE`: > +* Debug - default > +* Release > +* RelWithDebInfo > + > +And you want to build tarantool with RelWithDebInfo: > + > +```bash > +cmake -DCMAKE_TARANTOOL_ARGS=3D"-DCMAKE_BUILD_TYPE=3DRelWithDebInfo" . > +``` > diff --git a/static-build/test/CheckDependencies.cmake > b/static-build/test/CheckDependencies.cmake > new file mode 100644 > index 000000000..49e91e7fa > --- /dev/null > +++ b/static-build/test/CheckDependencies.cmake > @@ -0,0 +1,43 @@ > +## This is a cmake-based test, it checks that tarantool static binary > +# has no dependencies except allowed ones. > + > +include(GetPrerequisites) > +if(NOT FILE) > + message(FATAL_ERROR "Usage: " > + "${CMAKE_COMMAND} -DFILE=3D -P CheckDependencies.cmake= ") > +elseif(NOT EXISTS ${FILE}) > + message(FATAL_ERROR "${FILE}: No such file") > +endif() > + > +get_prerequisites(${FILE} DEPENDENCIES 0 0 "" "") > + > +if (APPLE) > + set(ALLOWLIST > + libSystem > + CoreFoundation > + libc++ > + ) > +elseif(UNIX) > + set(ALLOWLIST > + libdl > + librt > + libc > + libm > + libgcc_s > + libpthread > + ) > +else() > + message(FATAL_ERROR "Unknown platform") > +endif() > + > +foreach(DEPENDENCY_FILE ${DEPENDENCIES}) > + message("Dependency: ${DEPENDENCY_FILE}") > +endforeach() > + > +foreach(DEPENDENCY_FILE ${DEPENDENCIES}) > + get_filename_component(libname ${DEPENDENCY_FILE} NAME_WE) > + list (FIND ALLOWLIST ${libname} _index) > + if (_index EQUAL -1) > + message(FATAL_ERROR "Blocklisted dependency: ${DEPENDENCY_FILE}"= ) > + endif() > +endforeach() > diff --git a/static-build/test/static-build/exports.test.lua > b/static-build/test/static-build/exports.test.lua > new file mode 100755 > index 000000000..de54973d8 > --- /dev/null > +++ b/static-build/test/static-build/exports.test.lua > @@ -0,0 +1,142 @@ > +#!/usr/bin/env tarantool > + > +local tap =3D require('tap') > +local ffi =3D require('ffi') > +ffi.cdef([[ > + void *dlsym(void *handle, const char *symbol); > +]]) > + > +local test =3D tap.test('exports') > + > +-- See `man 3 dlsym`: > +-- RTLD_DEFAULT > +-- Find the first occurrence of the desired symbol using the default > +-- shared object search order. The search will include global symbols > +-- in the executable and its dependencies, as well as symbols in share= d > +-- objects that were dynamically loaded with the RTLD_GLOBAL flag. > +local RTLD_DEFAULT =3D ffi.cast("void *", jit.os =3D=3D "OSX" and -2LL o= r 0LL) > + > +local function check_symbol(sym) > + test:ok(ffi.C.dlsym(RTLD_DEFAULT, sym) ~=3D nil, ('Symbol %q > found'):format(sym)) > +end > + > +local check_symbols =3D { > + -- FFI > + > + 'guava', > + 'base64_decode', > + 'base64_encode', > + 'SHA1internal', > + 'random_bytes', > + 'fiber_time', > + 'ibuf_create', > + 'ibuf_destroy', > + 'port_destroy', > + 'csv_create', > + 'csv_destroy', > + 'title_get', > + 'title_update', > + 'tnt_iconv', > + 'tnt_iconv_open', > + 'tnt_iconv_close', > + 'exception_get_int', > + 'exception_get_string', > + > + 'tarantool_lua_ibuf', > + 'uuid_nil', > + 'tt_uuid_create', > + 'tt_uuid_str', > + 'tt_uuid_is_equal', > + 'tt_uuid_is_nil', > + 'tt_uuid_bswap', > + 'tt_uuid_from_string', > + 'log_level', > + 'log_format', > + 'uri_parse', > + 'uri_format', > + 'PMurHash32', > + 'PMurHash32_Process', > + 'PMurHash32_Result', > + 'crc32_calc', > + 'mp_encode_double', > + 'mp_encode_float', > + 'mp_encode_decimal', > + 'mp_decode_double', > + 'mp_decode_float', > + 'mp_decode_extl', > + 'mp_sizeof_decimal', > + 'decimal_unpack', > + > + 'log_type', > + 'say_set_log_level', > + 'say_logrotate', > + 'say_set_log_format', > + 'tarantool_uptime', > + 'tarantool_exit', > + 'log_pid', > + 'space_by_id', > + 'space_run_triggers', > + 'space_bsize', > + 'box_schema_version', > + > + 'crypto_EVP_MD_CTX_new', > + 'crypto_EVP_MD_CTX_free', > + 'crypto_HMAC_CTX_new', > + 'crypto_HMAC_CTX_free', > + 'crypto_stream_new', > + 'crypto_stream_begin', > + 'crypto_stream_append', > + 'crypto_stream_commit', > + 'crypto_stream_delete', > + > + -- Module API > + > + '_say', > + 'swim_cfg', > + 'swim_quit', > + 'fiber_new', > + 'fiber_cancel', > + 'coio_wait', > + 'coio_close', > + 'coio_call', > + 'coio_getaddrinfo', > + 'luaT_call', > + 'box_txn', > + 'box_select', > + 'clock_realtime', > + 'string_strip_helper', > + > + -- Lua / LuaJIT > + > + 'lua_newstate', > + 'lua_close', > + 'luaL_loadstring', > + 'luaJIT_profile_start', > + 'luaJIT_profile_stop', > + 'luaJIT_profile_dumpstack', > + > + 'ERR_error_string', > + 'ERR_get_error', > + > + 'EVP_get_digestbyname', > + 'EVP_get_cipherbyname', > + 'EVP_CIPHER_CTX_new', > + 'EVP_CIPHER_CTX_free', > + 'EVP_CIPHER_block_size', > + 'HMAC_Init_ex', > + 'HMAC_Update', > + 'HMAC_Final', > + > + 'ZSTD_compress', > + 'ZSTD_decompress', > + 'ZSTD_free', > + 'ZSTD_malloc', > + 'ZSTD_versionString', > +} > + > +test:plan(#check_symbols) > +for _, sym in ipairs(check_symbols) do > + check_symbol(sym) > +end > + > +os.exit(test:check() and 0 or 1) > diff --git a/static-build/test/static-build/traceback.test.lua > b/static-build/test/static-build/traceback.test.lua > new file mode 100755 > index 000000000..32e1ed8b5 > --- /dev/null > +++ b/static-build/test/static-build/traceback.test.lua > @@ -0,0 +1,15 @@ > +#!/usr/bin/env tarantool > + > +local tap =3D require('tap') > +local fiber =3D require('fiber') > + > +local test =3D tap.test('traceback') > +test:plan(1) > + > +local info =3D fiber.info()[fiber.id()] > +test:ok(info.backtrace ~=3D nil, 'fiber.info() has backtrace') > +for _, l in pairs(info.backtrace or {}) do > + test:diag('%s: %s', next(l)) > +end > + > +os.exit(test:check() and 0 or 1) > -- > 2.26.2 > > --000000000000a97c9d05aef2a2c2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello!

Here is a new commit message(as discussed at= telegram chat):

Author: HustonMmmavr <huston.mavr@gmail.com>
Date: =C2=A0 Thu Sep 10 12:= 43:20 2020 +0300

build: refactor static build process

Refacto= red static build process to use static-build/CMakeLists.txt
instead of D= ockerfile.staticbuild (this allows to support static
build on macOS). Fo= llowing third-party dependencies for static build
are installed via cmak= e `ExternalProject_Add`:
=C2=A0 =C2=A0 - OpenSSL
=C2=A0 =C2=A0 - Zlib=
=C2=A0 =C2=A0 - Ncurses
=C2=A0 =C2=A0 - Readline
=C2=A0 =C2=A0 - = Unwind
=C2=A0 =C2=A0 - ICU

* Added support static build for macOS=
* Fixed `CONFIGURE_COMMAND` while building bundled libcurl for static=C2=A0 =C2=A0 build at file cmake/BuildLibCURL.cmake:
=C2=A0 =C2=A0 - = disable building shared libcurl libraries (by setting
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 `--disable-shared` option)
=C2=A0 =C2=A0 - disable hiding lib= curl symbols (by setting
=C2=A0 =C2=A0 =C2=A0 =C2=A0 `--disable-symbol-h= iding` option)
=C2=A0 =C2=A0 - prevent linking libcurl with system libz = (by setting
=C2=A0 =C2=A0 =C2=A0 =C2=A0 `--with-zlib=3D${FOUND_ZLIB_ROOT= _DIR}` option)
* Removed Dockerfile.staticbuild
* Added new gitlab.ci jobs to test new style static build:=C2=A0 =C2=A0 - static_build_cmake_linux
=C2=A0 =C2=A0 - static_build_c= make_osx_15
* Removed static_docker_build g= itlab.ci job

Closes #5095

Co-authored-by: Yaroslav Dynnik= ov <yaroslav.dynnikov@gma= il.com>

=D1=81=D1=80, 9 =D1=81=D0=B5=D0=BD=D1=82. 2020 =D0=B3. =D0= =B2 18:45, HustonMmmavr <huston= .mavr@gmail.com>:
From: Yaroslav Dynnikov <yaroslav.dynnikov@gmail.com>

Refactored static build process to use static-build/CMakeLists.txt
instead of Dockerfile.staticbuild (this allows to support static
build on macOS). Following third-party dependencies for static build
are installed via cmake `ExternalProject_Add`:
=C2=A0 - OpenSSL
=C2=A0 - Zlib
=C2=A0 - Ncurses
=C2=A0 - Readline
=C2=A0 - Unwind
=C2=A0 - ICU

* Added support static build for macOS
* Fixed `CONFIGURE_COMMAND` while building bundled libcurl for static
=C2=A0 build at file cmake/BuildLibCURL.cmake:
=C2=A0 =C2=A0 - disable building shared libcurl libraries (by setting
=C2=A0 =C2=A0 =C2=A0 `--disable-shared` option)
=C2=A0 =C2=A0 - disable hiding libcurl symbols (by setting
=C2=A0 =C2=A0 =C2=A0 `--disable-symbol-hiding` option)
=C2=A0 =C2=A0 - prevent linking libcurl with system libz (by setting
=C2=A0 =C2=A0 =C2=A0 `--with-zlib=3D${FOUND_ZLIB_ROOT_DIR}` option)
* Removed Dockerfile.staticbuild
* Added new gitlab.ci jobs to test new style static build:
=C2=A0 - static_build_cmake_linux
=C2=A0 - static_build_cmake_osx_15
* Removed static_docker_build gitlab.ci job

Closes #5095
---

Branch: https://github.com/ta= rantool/tarantool/tree/rosik/refactor-static-build
Issue: https://github.com/tarantool/tarantool/is= sues/5095

Changes in v3:
1. Fixed typos at commit message
2. Fixed commentaries at .travis.mk
3. Fixed finding libz library at cmake/BuildLibCurl.cmake as at master
=C2=A0 =C2=A0branch
4. Instead of using static-build/.gitignore use the root .gitignore file 5. Refactored static-build/CMakeLists.txt:
=C2=A0 =C2=A0* Project name is set to tarantool-static
=C2=A0 =C2=A0* Instead of explicitly finding of c/c++ compilers current ver= sion uses
=C2=A0 =C2=A0 =C2=A0cmake `project(tarantool-static C CXX)` command. This c= hange requires
=C2=A0 =C2=A0 =C2=A0to manually set CFLAGS/CPPFLAGS/LDFLAGS for all static-= build
=C2=A0 =C2=A0 =C2=A0dependencies (because building dependencies at macOS re= quires path
=C2=A0 =C2=A0 =C2=A0to macOS SDK) the idea was taken from cmake/BuildLibCur= l.cmake
=C2=A0 =C2=A0* Added commentaries about problem with libicu
=C2=A0 =C2=A0* Removed unused TEST_COMMAND at ExternalProject_Add(zlib ...)= also
=C2=A0 =C2=A0 =C2=A0removed unnecessary # STEP_TARGETS at ExternalProject_A= dd(readline ...)
=C2=A0 =C2=A0* Deleted doubled whitespaces
6. Fixed static-build/README.md:
=C2=A0 =C2=A0* Added list of required tools
=C2=A0 =C2=A0* Added example for ubuntu/debian
=C2=A0 =C2=A0* Fixed indentation and typos
7. Refactored tests:
=C2=A0 =C2=A0* Got rid of test-run
=C2=A0 =C2=A0* Deleted doubled whitespaces at exports.test.lua
=C2=A0 =C2=A0* Fixed defining of RTLD_DEFAULT


=C2=A0.gitignore=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 = =C2=A08 +
=C2=A0.gitlab-ci.yml=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 11 +-
=C2=A0.tr= avis.mk=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 56 += ++-
=C2=A0Dockerfile.staticbuild=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 98 ------
=C2=A0cmake/BuildLibCURL.cmake=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 13 +-
=C2=A0cmake/compiler.cmake=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 24 +-
=C2=A0cmake/os.cmake=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A05 +-=
=C2=A0static-build/CMakeLists.txt=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0| 311 ++++++++++++++++++
=C2=A0static-build/README.md=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 90 +++++
=C2=A0static-build/test/CheckDependencies.cmake=C2=A0 =C2=A0 =C2=A0|=C2=A0 = 43 +++
=C2=A0.../test/static-build/exports.test.lua=C2=A0 =C2=A0 =C2=A0 =C2=A0 | 1= 42 ++++++++
=C2=A0.../test/static-build/traceback.test.lua=C2=A0 =C2=A0 =C2=A0 |=C2=A0 = 15 +
=C2=A012 files changed, 692 insertions(+), 124 deletions(-)
=C2=A0delete mode 100644 Dockerfile.staticbuild
=C2=A0create mode 100644 static-build/CMakeLists.txt
=C2=A0create mode 100644 static-build/README.md
=C2=A0create mode 100644 static-build/test/CheckDependencies.cmake
=C2=A0create mode 100755 static-build/test/static-build/exports.test.lua =C2=A0create mode 100755 static-build/test/static-build/traceback.test.lua<= br>
diff --git a/.gitignore b/.gitignore
index a42c7db35..c6e261e18 100644
--- a/.gitignore
+++ b/.gitignore
@@ -151,3 +151,11 @@ src/box/sql/parse.h
=C2=A0src/box/sql/parse.c
=C2=A0src/box/sql/opcodes.h
=C2=A0src/box/sql/opcodes.c
+
+# static-build
+static-build/*-prefix
+static-build/Makefile
+static-build/build
+
+# macOS files
+.DS_Store
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0ead08711..c9aef3dc7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -534,9 +534,14 @@ static_build:
=C2=A0 =C2=A0script:
=C2=A0 =C2=A0 =C2=A0- ${GITLAB_MAKE} test_static_build

-static_docker_build:
+static_build_cmake_linux:
+=C2=A0 <<: *docker_test_definition
+=C2=A0 script:
+=C2=A0 =C2=A0 - ${GITLAB_MAKE} test_static_build_cmake_linux
+
+static_build_cmake_osx_15:
=C2=A0 =C2=A0stage: test
=C2=A0 =C2=A0tags:
-=C2=A0 =C2=A0 - deploy_test
+=C2=A0 =C2=A0 - osx_15
=C2=A0 =C2=A0script:
-=C2=A0 =C2=A0 - ${GITLAB_MAKE} test_static_docker_build
+=C2=A0 =C2=A0 - ${GITLAB_MAKE} test_static_build_cmake_osx
diff --git a/.travis.mk b/.travis.mk
index efc05cf05..58d0c1596 100644
--- a/.tr= avis.mk
+++ b/.tr= avis.mk
@@ -148,8 +148,14 @@ deps_debian_static:
=C2=A0test_static_build: deps_debian_static
=C2=A0 =C2=A0 =C2=A0 =C2=A0 CMAKE_EXTRA_PARAMS=3D-DBUILD_STATIC=3DON make -= f .travis= .mk test_debian_no_deps

-test_static_docker_build:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0docker build --no-cache --network=3Dhost --buil= d-arg RUN_TESTS=3DON -f Dockerfile.staticbuild .
+# New static build
+# builddir used in this target - is a default build path from cmake
+# ExternalProject_Add()
+test_static_build_cmake_linux:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0cd static-build && cmake -DCMAKE_TARANT= OOL_ARGS=3D"-DCMAKE_BUILD_TYPE=3DRelWithDebInfo;-DENABLE_WERROR=3DON&q= uot; . && \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0make -j && ctest -V
+=C2=A0 =C2=A0 =C2=A0 =C2=A0cd test && /usr/bin/python test-run.py = --force \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0--builddir ${PWD}/s= tatic-build/tarantool-prefix/src/tarantool-build $(TEST_RUN_EXTRA_PARAMS)
=C2=A0# ###################
=C2=A0# Static Analysis
@@ -193,15 +199,16 @@ build_osx:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 cmake . -DCMAKE_BUILD_TYPE=3DRelWithDebInfo -DE= NABLE_WERROR=3DON ${CMAKE_EXTRA_PARAMS}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 make -j

-test_osx_no_deps: build_osx
-=C2=A0 =C2=A0 =C2=A0 =C2=A0# Limits: Increase the maximum number of open f= ile descriptors on macOS:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0#=C2=A0 =C2=A0Travis-ci needs the "ulimit = -n <value>" call
-=C2=A0 =C2=A0 =C2=A0 =C2=A0#=C2=A0 =C2=A0Gitlab-ci needs the "launchc= tl limit maxfiles <value>" call
-=C2=A0 =C2=A0 =C2=A0 =C2=A0# Also gitlib-ci needs the password to change t= he limits, while
-=C2=A0 =C2=A0 =C2=A0 =C2=A0# travis-ci runs under root user. Limit setup m= ust be in the same
-=C2=A0 =C2=A0 =C2=A0 =C2=A0# call as tests runs call.
-=C2=A0 =C2=A0 =C2=A0 =C2=A0# Tests: Temporary excluded replication/ suite = with some tests
-=C2=A0 =C2=A0 =C2=A0 =C2=A0#=C2=A0 =C2=A0 =C2=A0 =C2=A0 from other suites = by issues #4357 and #4370
+
+# Limits: Increase the maximum number of open file descriptors on macOS: +#=C2=A0 =C2=A0Travis-ci needs the "ulimit -n <value>" call=
+#=C2=A0 =C2=A0Gitlab-ci needs the "launchctl limit maxfiles <value= >" call
+# Also gitlib-ci needs the password to change the limits, while
+# travis-ci runs under root user. Limit setup must be in the same
+# call as tests runs call.
+# Tests: Temporary excluded replication/ suite with some tests
+#=C2=A0 =C2=A0 =C2=A0 =C2=A0 from other suites by issues #4357 and #4370 +INIT_TEST_ENV_OSX=3D\
=C2=A0 =C2=A0 =C2=A0 =C2=A0 sudo -S launchctl limit maxfiles ${MAX_FILES} |= | : ; \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 launchctl limit max= files || : ; \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ulimit -n ${MAX_FIL= ES} || : ; \
@@ -210,11 +217,34 @@ test_osx_no_deps: build_osx
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 launchctl limit max= proc || : ; \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ulimit -u ${MAX_PRO= C} || : ; \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ulimit -u ; \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -rf /tmp/tnt ; \=
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cd test && = ./test-run.py --vardir /tmp/tnt --force $(TEST_RUN_EXTRA_PARAMS)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -rf /tmp/tnt
+
+test_osx_no_deps: build_osx
+=C2=A0 =C2=A0 =C2=A0 =C2=A0${INIT_TEST_ENV_OSX}; \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0cd test && ./test-run.py --vardir /tmp/= tnt --force $(TEST_RUN_EXTRA_PARAMS)

=C2=A0test_osx: deps_osx test_osx_no_deps

+# Static macOS build
+
+STATIC_OSX_PKGS=3Dautoconf automake libtool cmake file://$${PWD}/tools/bre= w_taps/tntpython2.rb
+base_deps_osx:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0brew update || echo | /usr/bin/ruby -e \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"$$(curl -fsSL= https://raw.githubusercontent.com/= Homebrew/install/master/install)"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0brew install --force ${STATIC_OSX_PKGS} || brew= upgrade ${STATIC_OSX_PKGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0pip install --force-reinstall -r test-run/requi= rements.txt
+
+# builddir used in this target - is a default build path from cmake
+# ExternalProject_Add()
+test_static_build_cmake_osx: base_deps_osx
+=C2=A0 =C2=A0 =C2=A0 =C2=A0cd static-build && cmake -DCMAKE_TARANT= OOL_ARGS=3D"-DCMAKE_BUILD_TYPE=3DRelWithDebInfo;-DENABLE_WERROR=3DON&q= uot; . && \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0make -j && ctest -V
+=C2=A0 =C2=A0 =C2=A0 =C2=A0${INIT_TEST_ENV_OSX}; \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0cd test && ./test-run.py --vardir /tmp/= tnt \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0--builddir ${PWD}/s= tatic-build/tarantool-prefix/src/tarantool-build \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0--force $(TEST_RUN_= EXTRA_PARAMS)
+
+
=C2=A0###########
=C2=A0# FreeBSD #
=C2=A0###########
diff --git a/Dockerfile.staticbuild b/Dockerfile.staticbuild
deleted file mode 100644
index f67f46f5e..000000000
--- a/Dockerfile.staticbuild
+++ /dev/null
@@ -1,98 +0,0 @@
-FROM centos:7
-
-RUN yum install -y epel-release
-RUN yum install -y yum install https://centos7.iusc= ommunity.org/ius-release.rpm
-
-RUN set -x \
-=C2=A0 =C2=A0 && yum -y install \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 libstdc++ \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 libstdc++-static \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 readline \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 openssl \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 lz4 \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 binutils \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 ncurses \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 libgomp \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 lua \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 curl \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 tar \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 zip \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 unzip \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 libunwind \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 zlib \
-=C2=A0 =C2=A0 && yum -y install \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 perl \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 gcc-c++ \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 cmake \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 lz4-devel \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 binutils-devel \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 lua-devel \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 make \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 git \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 autoconf \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 automake \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 libtool \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 wget
-
-RUN yum -y install ncurses-static readline-static zlib-static pcre-static = glibc-static
-
-RUN yum -y install python-devel python-pip
-
-RUN set -x && \
-=C2=A0 =C2=A0 cd / && \
-=C2=A0 =C2=A0 curl -O -L https://www.openssl.or= g/source/openssl-1.1.1f.tar.gz && \
-=C2=A0 =C2=A0 tar -xvf openssl-1.1.1f.tar.gz && \
-=C2=A0 =C2=A0 cd openssl-1.1.1f && \
-=C2=A0 =C2=A0 ./config --libdir=3Dlib && \
-=C2=A0 =C2=A0 make -j && make install
-
-RUN set -x && \
-=C2=A0 =C2=A0 cd / && \
-=C2=A0 =C2=A0 curl -O -L https://github.com/unicode-org/icu/releases/download/release-62= -1/icu4c-62_1-src.tgz && \
-=C2=A0 =C2=A0 tar -xvf icu4c-62_1-src.tgz && \
-=C2=A0 =C2=A0 cd icu/source && \
-=C2=A0 =C2=A0 ./configure --with-data-packaging=3Dstatic --enable-static -= -enable-shared && \
-=C2=A0 =C2=A0 make -j && make install
-
-RUN set -x && \
-=C2=A0 =C2=A0 cd / && \
-=C2=A0 =C2=A0 curl -O -L http://download.savannah.nongnu.org/releases/libunwind/libunwind-1.3-r= c1.tar.gz && \
-=C2=A0 =C2=A0 tar -xvf libunwind-1.3-rc1.tar.gz && \
-=C2=A0 =C2=A0 cd libunwind-1.3-rc1 && \
-=C2=A0 =C2=A0 ./configure --enable-static --enable-shared && \
-=C2=A0 =C2=A0 make -j && make install
-
-COPY . /tarantool
-
-WORKDIR /tarantool
-
-RUN set -x && \
-=C2=A0 =C2=A0 git submodule init && \
-=C2=A0 =C2=A0 git submodule update
-
-# Cleanup for 'build' directory added, because it purges all artef= acts
-# produced for curl build, including the old configuration in build/curl -RUN set -x && \
-=C2=A0 =C2=A0 find . -name 'CMakeFiles' -type d -exec rm -rf {} + = && \
-=C2=A0 =C2=A0 find . -name 'CMakeCache.txt' -type f -delete &&= amp; \
-=C2=A0 =C2=A0 rm -rf build test/small test/luajit-tap
-
-RUN pip install -r /tarantool/test-run/requirements.txt
-
-RUN set -x && \
-=C2=A0 =C2=A0 cmake -DCMAKE_BUILD_TYPE=3DRelWithDebInfo \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-DENABLE_DIST:BOOL=3DON \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-DBUILD_STATIC=3DON \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-DOPENSSL_USE_STATIC_LIBS=3DON \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-DOPENSSL_ROOT_DIR=3D/usr/local \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0. && \
-=C2=A0 =C2=A0 make -j && make install
-
-ARG RUN_TESTS
-RUN if [ -n "${RUN_TESTS}" ]; then \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 set -x && \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 cd test && \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 /usr/bin/python test-run.py --force; \
-=C2=A0 =C2=A0 fi
-
-ENTRYPOINT ["/bin/bash"]
diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake
index 5f8b15a63..86fec39e9 100644
--- a/cmake/BuildLibCURL.cmake
+++ b/cmake/BuildLibCURL.cmake
@@ -4,15 +4,21 @@ macro(curl_build)
=C2=A0 =C2=A0 =C2=A0set(LIBCURL_BINARY_DIR ${PROJECT_BINARY_DIR}/build/curl= /work)
=C2=A0 =C2=A0 =C2=A0set(LIBCURL_INSTALL_DIR ${PROJECT_BINARY_DIR}/build/cur= l/dest)

+=C2=A0 =C2=A0 message(STATUS "Looking for zlib")
+=C2=A0 =C2=A0 find_path(ZLIB_INCLUDE_DIR zlib.h)
+=C2=A0 =C2=A0 message(STATUS "Looking for zlib.h - ${ZLIB_INCLUDE_DIR= }")
=C2=A0 =C2=A0 =C2=A0if (BUILD_STATIC)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0set(LIBZ_LIB_NAME libz.a)
=C2=A0 =C2=A0 =C2=A0else()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0set(LIBZ_LIB_NAME z)
=C2=A0 =C2=A0 =C2=A0endif()
=C2=A0 =C2=A0 =C2=A0find_library(LIBZ_LIBRARY NAMES ${LIBZ_LIB_NAME})
-=C2=A0 =C2=A0 if ("${LIBZ_LIBRARY}" STREQUAL "LIBZ_LIBRARY-= NOTFOUND")
+=C2=A0 =C2=A0 message(STATUS "Looking for libz - ${LIBZ_LIBRARY}"= ;)
+
+=C2=A0 =C2=A0 if (NOT ZLIB_INCLUDE_DIR OR NOT LIBZ_LIBRARY)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0message(FATAL_ERROR "Unable to find = zlib")
=C2=A0 =C2=A0 =C2=A0endif()
+=C2=A0 =C2=A0 get_filename_component(FOUND_ZLIB_ROOT_DIR ${ZLIB_INCLUDE_DI= R} DIRECTORY)

=C2=A0 =C2=A0 =C2=A0# Use the same OpenSSL library for libcurl as is used f= or
=C2=A0 =C2=A0 =C2=A0# tarantool itself.
@@ -88,9 +94,10 @@ macro(curl_build)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0--prefix <= INSTALL_DIR>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0--enable-stat= ic
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --enable-shared +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --disable-shared +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --disable-symbol-h= iding

-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-zlib
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-zlib=3D${FO= UND_ZLIB_ROOT_DIR}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0${LIBCURL_OPE= NSSL_OPT}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0--with-ca-fal= lback

diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
index 5a1141ebd..db2ae6227 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -33,10 +33,6 @@ if (CMAKE_COMPILER_IS_GNUCC)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Your GCC version is ${CMAKE_CXX_C= OMPILER_VERSION}, please update
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "= ;)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 endif()
-else()
-=C2=A0 =C2=A0 =C2=A0if (BUILD_STATIC)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0message(FATAL_ERROR "Static = build is supported for GCC only")
-=C2=A0 =C2=A0 =C2=A0endif()
=C2=A0endif()

=C2=A0#
@@ -120,10 +116,23 @@ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO

=C2=A0unset(CC_DEBUG_OPT)

+message(STATUS "Looking for libunwind.h")
+find_path(UNWIND_INCLUDE_DIR libunwind.h)
+message(STATUS "Looking for libunwind.h - ${UNWIND_INCLUDE_DIR}"= )
+
+if (UNWIND_INCLUDE_DIR)
+=C2=A0 =C2=A0 include_directories(${UNWIND_INCLUDE_DIR})
+endif()
+
+set(CMAKE_REQUIRED_INCLUDES ${UNWIND_INCLUDE_DIR})
=C2=A0check_include_file(libunwind.h HAVE_LIBUNWIND_H)
-if(BUILD_STATIC)
+set(CMAKE_REQUIRED_INCLUDES "")
+
+if(BUILD_STATIC AND NOT TARGET_OS_DARWIN)
=C2=A0 =C2=A0 =C2=A0set(UNWIND_LIB_NAME libunwind.a)
=C2=A0else()
+=C2=A0 =C2=A0 # libunwind can't be compiled on macOS.
+=C2=A0 =C2=A0 # But there exists libunwind.dylib as a part of MacOSSDK
=C2=A0 =C2=A0 =C2=A0set(UNWIND_LIB_NAME unwind)
=C2=A0endif()
=C2=A0find_library(UNWIND_LIBRARY PATH_SUFFIXES system NAMES ${UNWIND_LIB_N= AME})
@@ -185,7 +194,10 @@ if (ENABLE_BACKTRACE)
=C2=A0 =C2=A0 =C2=A0find_package_message(UNWIND_LIBRARIES "Found unwin= d" "${UNWIND_LIBRARIES}")
=C2=A0endif()

-if(BUILD_STATIC)
+# On macOS there is no '-static-libstdc++' flag and it's use w= ill
+# raise following error:
+# error: argument unused during compilation: '-static-libstdc++' +if(BUILD_STATIC AND NOT TARGET_OS_DARWIN)
=C2=A0 =C2=A0 =C2=A0# Static linking for c++ routines
=C2=A0 =C2=A0 =C2=A0add_compile_flags("C;CXX" "-static-libst= dc++")
=C2=A0endif()
diff --git a/cmake/os.cmake b/cmake/os.cmake
index 905be61df..276a79b42 100644
--- a/cmake/os.cmake
+++ b/cmake/os.cmake
@@ -107,7 +107,10 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin&quo= t;)

=C2=A0 =C2=A0 =C2=A0# Latest versions of Homebrew wont 'link --force= 9; for libraries, that were
=C2=A0 =C2=A0 =C2=A0# preinstalled in system. So we'll use this dirty h= ack
-=C2=A0 =C2=A0 find_program(HOMEBREW_EXECUTABLE brew)
+
+=C2=A0 =C2=A0 if (NOT BUILD_STATIC)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 find_program(HOMEBREW_EXECUTABLE brew)
+=C2=A0 =C2=A0 endif()
=C2=A0 =C2=A0 =C2=A0if(EXISTS ${HOMEBREW_EXECUTABLE})
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0execute_process(COMMAND ${HOMEBREW_EXECUT= ABLE} --prefix
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0OUTPUT_VARIABLE HOMEBREW_PREFIX
diff --git a/static-build/CMakeLists.txt b/static-build/CMakeLists.txt
new file mode 100644
index 000000000..90029fdd8
--- /dev/null
+++ b/static-build/CMakeLists.txt
@@ -0,0 +1,311 @@
+cmake_minimum_required(VERSION 2.8)
+
+# Detect system compilers for further configuring dependencies to be
+# builded with these compilers. This is used to build tarantool and
+# it's dependencies by usign one compiler system (for example libicu +# by default uses clang if it exists when others uses gcc/g++ on
+# linux machine).
+project(tarantool-static C CXX)
+
+include(ExternalProject)
+set(OPENSSL_VERSION 1.1.1f)
+set(ZLIB_VERSION 1.2.11)
+set(NCURSES_VERSION 6.2)
+set(READLINE_VERSION 8.0)
+set(UNWIND_VERSION 1.3-rc1)
+
+# Pass -isysroot=3D<SDK_PATH> option on Mac OS to a preprocessor and= a C
+# compiler to find header files installed with an SDK.
+#
+# The idea is to set these (DEPENDENCY_*) variables to corresponding
+# environment variables at each depenency configure script.
+#
+# Note: Passing of CPPFLAGS / CFLAGS explicitly discards using of
+# corresponsing environment variables. So pass empty LDFLAGS to discard +# using of corresponding environment variable. It is possible that a
+# linker flag assumes that some compilation flag is set. We don't pass=
+# CFLAGS from environment, so we should not do it for LDFLAGS too.
+set(DEPENDENCY_CFLAGS "")
+set(DEPENDENCY_CPPFLAGS "")
+set(DEPENDENCY_LDFLAGS)
+if (APPLE)
+=C2=A0 =C2=A0 set(DEPENDENCY_CFLAGS=C2=A0 =C2=A0"${CMAKE_C_SYSROOT_FL= AG} ${CMAKE_OSX_SYSROOT}")
+=C2=A0 =C2=A0 set(DEPENDENCY_CPPFLAGS "${CMAKE_C_SYSROOT_FLAG} ${CMAK= E_OSX_SYSROOT}")
+endif()
+
+# Install all libraries required by tarantool at current build dir
+
+#
+# OpenSSL
+#
+ExternalProject_Add(openssl
+=C2=A0 =C2=A0 URL https://www.o= penssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
+=C2=A0 =C2=A0 CONFIGURE_COMMAND <SOURCE_DIR>/config
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CC=3D${CMAKE_C_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CXX=3D${CMAKE_CXX_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CFLAGS=3D${DEPENDENCY_CFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CPPFLAGS=3D${DEPENDENCY_CPPFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 LDFLAGS=3D${DEPENDENCY_LDFLAGS}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --prefix=3D<INSTALL_DIR>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --libdir=3Dlib
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 no-shared
+=C2=A0 =C2=A0 INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install_sw
+)
+
+#
+# ICU
+#
+ExternalProject_Add(icu
+=C2=A0 =C2=A0 URL https://github.com/unicode-org/icu/releases/download/release-62-1/icu4c-= 62_1-src.tgz
+=C2=A0 =C2=A0 # By default libicu is built by using clang/clang++ compiler= (if it
+=C2=A0 =C2=A0 # exists). Here is a link for detecting compilers at libicu = configure
+=C2=A0 =C2=A0 # script: https://github.com/unicode-org/icu/blob= /7c7b8bd5702310b972f888299169bc3cc88bf0a6/icu4c/source/configure.ac#L135
+=C2=A0 =C2=A0 # This will cause the problem on linux machine: tarantool is= built
+=C2=A0 =C2=A0 # with gcc/g++ and libicu is built with clang/clang++ (if it= exists)
+=C2=A0 =C2=A0 # so at linking stage `rellocation` errors will occur. To so= lve this,
+=C2=A0 =C2=A0 # we can set CC/CXX to CMAKE_C_COMPILER/CMAKE_CXX_COMPILER v= ariables
+=C2=A0 =C2=A0 # manually which are detected above (by cmake `project()` co= mmand)
+=C2=A0 =C2=A0 CONFIGURE_COMMAND <SOURCE_DIR>/source/configure
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CC=3D${CMAKE_C_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CXX=3D${CMAKE_CXX_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CFLAGS=3D${DEPENDENCY_CFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CPPFLAGS=3D${DEPENDENCY_CPPFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 LDFLAGS=3D${DEPENDENCY_LDFLAGS}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-data-packaging=3Dstatic
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --prefix=3D<INSTALL_DIR>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --disable-shared
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --enable-static
+)
+
+#
+# ZLIB
+#
+ExternalProject_Add(zlib
+=C2=A0 =C2=A0 URL
https://zlib.net/zlib-${ZLIB_VERS= ION}.tar.gz
+=C2=A0 =C2=A0 CONFIGURE_COMMAND env
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CC=3D${CMAKE_C_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CFLAGS=3D${DEPENDENCY_CFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CPPFLAGS=3D${DEPENDENCY_CPPFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 LDFLAGS=3D${DEPENDENCY_LDFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 <SOURCE_DIR>/configure
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --prefix=3D<INSTALL_DIR>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --static
+)
+
+#
+# Ncurses
+#
+ExternalProject_Add(ncurses
+=C2=A0 =C2=A0 URL https://ftp.= gnu.org/gnu/ncurses/ncurses-${NCURSES_VERSION}.tar.gz
+=C2=A0 =C2=A0 CONFIGURE_COMMAND <SOURCE_DIR>/configure
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CC=3D${CMAKE_C_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CXX=3D${CMAKE_CXX_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CFLAGS=3D${DEPENDENCY_CFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CPPFLAGS=3D${DEPENDENCY_CPPFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 LDFLAGS=3D${DEPENDENCY_LDFLAGS}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --prefix=3D<INSTALL_DIR>
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 # This flag enables creation of libcurses.a as= a symlink to libncurses.a
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 # and disables subdir creation `ncurses` at &l= t;install_dir>/include. It is
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 # necessary for correct work of FindCurses.cma= ke module (this module is
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 # builtin at cmake package) which used in cmak= e/FindReadline.cmake
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --enable-overwrite
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 # enable building libtinfo to prevent linking = with libtinfo from system
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 # directories
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-termlib
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 # set search paths for terminfo db
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-terminfo-dirs=3D/lib/terminfo:/usr/shar= e/terminfo:/etc/terminfo
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 # disable install created terminfo db, use db = from system
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --disable-db-install
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --without-progs
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --without-manpages
+)
+
+#
+# ReadLine
+#
+ExternalProject_Add(readline
+=C2=A0 =C2=A0 URL https://f= tp.gnu.org/gnu/readline/readline-${READLINE_VERSION}.tar.gz
+=C2=A0 =C2=A0 CONFIGURE_COMMAND <SOURCE_DIR>/configure
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CC=3D${CMAKE_C_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CFLAGS=3D${DEPENDENCY_CFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CPPFLAGS=3D${DEPENDENCY_CPPFLAGS}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 LDFLAGS=3D${DEPENDENCY_LDFLAGS}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --prefix=3D<INSTALL_DIR>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 --disable-shared
+)
+
+#
+# ICONV
+#
+if (APPLE)
+=C2=A0 =C2=A0 ExternalProject_Add(iconv
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 URL https://ft= p.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CONFIGURE_COMMAND <SOURCE_DIR>/configure=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CC=3D${CMAKE_C_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CFLAGS=3D${DEPENDENCY_CFLAGS} +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CPPFLAGS=3D${DEPENDENCY_CPPFLAGS= }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 LDFLAGS=3D${DEPENDENCY_LDFLAGS}<= br> +
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --prefix=3D<INSTALL_DIR> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --disable-shared
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --enable-static
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-gnu-ld
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 STEP_TARGETS download
+=C2=A0 =C2=A0 )
+else()
+=C2=A0 =C2=A0 # In linux iconv is embedded into glibc
+=C2=A0 =C2=A0 # So we find system header and copy it locally
+=C2=A0 =C2=A0 find_path(ICONV_INCLUDE_DIR iconv.h)
+=C2=A0 =C2=A0 if(NOT ICONV_INCLUDE_DIR)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 message(FATAL_ERROR "iconv include header= not found")
+=C2=A0 =C2=A0 endif()
+
+=C2=A0 =C2=A0 set(ICONV_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/i= conv-prefix")
+
+=C2=A0 =C2=A0 add_custom_command(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 OUTPUT "${ICONV_INSTALL_PREFIX}/include/i= conv.h"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 COMMAND ${CMAKE_COMMAND} -E make_directory
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${ICONV_INSTALL_PREFIX}/in= clude"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 COMMAND ${CMAKE_COMMAND} -E copy
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${ICONV_INCLUDE_DIR}/iconv= .h"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${ICONV_INSTALL_PREFIX}/in= clude/iconv.h"
+=C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 add_custom_target(iconv
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/icon= v-prefix/include/iconv.h"
+=C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 # This is a hack for further getting install directory of li= brary
+=C2=A0 =C2=A0 # by ExternalProject_Get_Property
+=C2=A0 =C2=A0 set_target_properties(iconv
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 PROPERTIES _EP_INSTALL_DIR ${ICONV_INSTALL_PRE= FIX}
+=C2=A0 =C2=A0 )
+endif()
+
+#
+# Unwind
+#
+if (APPLE)
+=C2=A0 =C2=A0 # On macOS libunwind is a part of MacOSX.sdk
+=C2=A0 =C2=A0 # So we need to find library and header and
+=C2=A0 =C2=A0 # copy it locally
+=C2=A0 =C2=A0 find_path(UNWIND_INCLUDE_DIR libunwind.h)
+=C2=A0 =C2=A0 find_library(UNWIND_LIBRARY libunwind.dylib
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 PATH_SUFFIXES system
+=C2=A0 =C2=A0 )
+
+=C2=A0 =C2=A0 set(UNWIND_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/= unwind-prefix")
+
+=C2=A0 =C2=A0 set(UNWIND_DEPENDENCIES)
+
+=C2=A0 =C2=A0 if (UNWIND_INCLUDE_DIR AND UNWIND_LIBRARY)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 add_custom_command(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 OUTPUT "${UNWIND_INSTALL_PR= EFIX}/include/unwind.h"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 OUTPUT "${UNWIND_INSTALL_PR= EFIX}/include/libunwind.h"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 COMMAND ${CMAKE_COMMAND} -E make= _directory
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${UNWIND_INS= TALL_PREFIX}/include"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 COMMAND ${CMAKE_COMMAND} -E copy=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${UNWIND_INC= LUDE_DIR}/libunwind.h"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${UNWIND_INC= LUDE_DIR}/unwind.h"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${UNWIND_INS= TALL_PREFIX}/include/"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 add_custom_command(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 OUTPUT "${UNWIND_INSTALL_PR= EFIX}/lib/libunwind.dylib"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 COMMAND ${CMAKE_COMMAND} -E make= _directory
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${UNWIND_INS= TALL_PREFIX}/lib"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 COMMAND ${CMAKE_COMMAND} -E copy=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${UNWIND_LIB= RARY}"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${UNWIND_INS= TALL_PREFIX}/lib/"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 set(UNWIND_DEPENDENCIES
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ${UNWIND_DEPENDENCIES}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${UNWIND_INSTALL_PREFIX}/l= ib/libunwind.dylib"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${UNWIND_INSTALL_PREFIX}/i= nclude/libunwind.h"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 else()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 message(STATUS "Unwind not found") +=C2=A0 =C2=A0 endif()
+
+=C2=A0 =C2=A0 add_custom_target(unwind DEPENDS ${UNWIND_DEPENDENCIES})
+=C2=A0 =C2=A0 # This is a hack for further getting install directory of li= brary
+=C2=A0 =C2=A0 # by ExternalProject_Get_Property
+=C2=A0 =C2=A0 set_target_properties(unwind
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 PROPERTIES _EP_INSTALL_DIR ${UNWIND_INSTALL_PR= EFIX}
+=C2=A0 =C2=A0 )
+else()
+=C2=A0 =C2=A0 ExternalProject_Add(unwind
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 URL https://download.savannah.nongnu.org/releases/li= bunwind/libunwind-${UNWIND_VERSION}.tar.gz
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CONFIGURE_COMMAND <SOURCE_DIR>/configure=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CC=3D${CMAKE_C_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CXX=3D${CMAKE_CXX_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CFLAGS=3D${DEPENDENCY_CFLAGS} +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CPPFLAGS=3D${DEPENDENCY_CPPFLAGS= }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 LDFLAGS=3D${DEPENDENCY_LDFLAGS}<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --prefix=3D<INSTALL_DIR> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --disable-shared
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --enable-static
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 --disable-minidebuginfo # to pre= vent linking with liblzma
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 STEP_TARGETS download
+=C2=A0 =C2=A0 )
+endif()
+
+# Get install directories of builded libraries for building
+# tarantool with custon CMAKE_PREFIX_PATH
+foreach(PROJ openssl icu zlib ncurses readline iconv unwind)
+=C2=A0 =C2=A0 ExternalProject_Get_Property(${PROJ} install_dir)
+=C2=A0 =C2=A0 set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:${install_dir}) +=C2=A0 =C2=A0 set(TARANTOOL_DEPENDS ${PROJ} ${TARANTOOL_DEPENDS})
+=C2=A0 =C2=A0 message(STATUS "Add external project ${PROJ} in ${insta= ll_dir}")
+endforeach()
+
+ExternalProject_Add(tarantool
+=C2=A0 =C2=A0 DEPENDS ${TARANTOOL_DEPENDS}
+=C2=A0 =C2=A0 SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..
+=C2=A0 =C2=A0 LIST_SEPARATOR :
+=C2=A0 =C2=A0 CMAKE_ARGS
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Override LOCALSTATEDIR to avoid cmake "= special" cases:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 # https://cmake.org/cmake/help/v3.4/module/GNUInstallDirs.html#special-c= ases
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -DCMAKE_INSTALL_LOCALSTATEDIR=3D<INSTALL_DI= R>/var
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -DCMAKE_INSTALL_PREFIX=3D<INSTALL_DIR> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 -DCMAKE_PREFIX_PATH=3D${CMAKE_PREFIX_PATH}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=3DFALSE
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -DOPENSSL_USE_STATIC_LIBS=3DTRUE
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -DBUILD_STATIC=3DTRUE
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -DENABLE_DIST=3DTRUE
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -DENABLE_BACKTRACE=3DTRUE
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -DCMAKE_C_COMPILER=3D${CMAKE_C_COMPILER}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -DCMAKE_CXX_COMPILER=3D${CMAKE_CXX_COMPILER} +=C2=A0 =C2=A0 =C2=A0 =C2=A0 ${CMAKE_TARANTOOL_ARGS}
+=C2=A0 =C2=A0 STEP_TARGETS build
+=C2=A0 =C2=A0 BUILD_COMMAND $(MAKE)
+)
+
+enable_testing()
+ExternalProject_Get_Property(tarantool binary_dir)
+SET(TARANTOOL_BINARY_DIR ${binary_dir})
+
+add_test(
+=C2=A0 =C2=A0 NAME check-dependencies
+=C2=A0 =C2=A0 COMMAND ${CMAKE_COMMAND}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -D FILE=3D${TARANTOOL_BINARY_DIR}/src/tarantoo= l
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -P CheckDependencies.cmake
+=C2=A0 =C2=A0 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test
+)
+
+add_test(
+=C2=A0 =C2=A0 NAME check-exports
+=C2=A0 =C2=A0 COMMAND ${TARANTOOL_BINARY_DIR}/src/tarantool
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ${CMAKE_CURRENT_SOURCE_DIR}/test= /static-build/exports.test.lua
+)
+
+add_test(
+=C2=A0 =C2=A0 NAME check-traceback
+=C2=A0 =C2=A0 COMMAND ${TARANTOOL_BINARY_DIR}/src/tarantool
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ${CMAKE_CURRENT_SOURCE_DIR}/test= /static-build/traceback.test.lua
+)
diff --git a/static-build/README.md b/static-build/README.md
new file mode 100644
index 000000000..2219b5026
--- /dev/null
+++ b/static-build/README.md
@@ -0,0 +1,90 @@
+# Tarantool static build tooling
+
+These files help to prepare environment for building Tarantool
+statically. And builds it.
+
+## Prerequisites
+
+Please install following tools and libraries that will
+be necessary for building and testing:
+* git
+* A C/C++ compiler.
+
+=C2=A0 Ordinarily, this is gcc and g++ version 4.6 or later. On Mac OS X, = this
+=C2=A0 is Clang version 3.2+.
+* cmake
+* autoconf automake libtool
+* make
+* Python and modules.
+
+=C2=A0 Python interpreter is not necessary for building Tarantool itself, = unless you
+=C2=A0 intend to use the =E2=80=9CRun the test suite". For all platfo= rms, this is python
+=C2=A0 version 2.7+ (but not 3.x). You need the following Python modules:<= br> +=C2=A0 * pyyaml
+=C2=A0 * argparse
+=C2=A0 * msgpack-python
+=C2=A0 * gevent
+=C2=A0 * six
+
+### Here is an examples for your OS:
+
+CentOS:
+
+```bash
+yum install -y \
+=C2=A0 =C2=A0 git perl gcc cmake make gcc-c++ libstdc++-static autoconf au= tomake libtool \
+=C2=A0 =C2=A0 python-msgpack python-yaml python-argparse python-six python= -gevent
+```
+
+Ubuntu/Debian:
+
+```bash
+apt-get install -y \
+=C2=A0 =C2=A0 build-essential cmake make coreutils autoconf automake libto= ol sed \
+=C2=A0 =C2=A0 python python-pip python-setuptools python-dev \
+=C2=A0 =C2=A0 python-msgpack python-yaml python-argparse python-six python= -gevent
+```
+
+MacOS:
+
+Before you start please install default Xcode Tools by Apple:
+
+```bash
+sudo xcode-select --install
+sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
+```
+
+Install brew using command from
+[Homebrew repository instructions](https://github.com/Homebrew/inst= )
+
+After that run next script:
+
+```bash
+brew install autoconf automake libtool cmake file://$${PWD}/tools/brew_tap= s/tntpython2.rbs
+pip install --force-reinstall -r test-run/requirements.txt
+```
+
+## Usage
+
+```bash
+cmake .
+make -j
+ctest -V
+```
+
+## Customize your build
+
+If you want to customise build, you need to set `CMAKE_TARANTOOL_ARGS` var= iable
+
+### Usage
+
+There are three types of `CMAKE_BUILD_TYPE`:
+* Debug - default
+* Release
+* RelWithDebInfo
+
+And you want to build tarantool with RelWithDebInfo:
+
+```bash
+cmake -DCMAKE_TARANTOOL_ARGS=3D"-DCMAKE_BUILD_TYPE=3DRelWithDebInfo&q= uot; .
+```
diff --git a/static-build/test/CheckDependencies.cmake b/static-build/test/= CheckDependencies.cmake
new file mode 100644
index 000000000..49e91e7fa
--- /dev/null
+++ b/static-build/test/CheckDependencies.cmake
@@ -0,0 +1,43 @@
+## This is a cmake-based test, it checks that tarantool static binary
+# has no dependencies except allowed ones.
+
+include(GetPrerequisites)
+if(NOT FILE)
+=C2=A0 =C2=A0 message(FATAL_ERROR "Usage: "
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 "${CMAKE_COMMAND} -DFILE=3D<FILENAME&g= t; -P CheckDependencies.cmake")
+elseif(NOT EXISTS ${FILE})
+=C2=A0 =C2=A0 message(FATAL_ERROR "${FILE}: No such file")
+endif()
+
+get_prerequisites(${FILE} DEPENDENCIES 0 0 "" "")
+
+if (APPLE)
+=C2=A0 =C2=A0 set(ALLOWLIST
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 libSystem
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CoreFoundation
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 libc++
+=C2=A0 =C2=A0 )
+elseif(UNIX)
+=C2=A0 =C2=A0 set(ALLOWLIST
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 libdl
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 librt
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 libc
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 libm
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 libgcc_s
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 libpthread
+=C2=A0 =C2=A0 )
+else()
+=C2=A0 =C2=A0 message(FATAL_ERROR "Unknown platform")
+endif()
+
+foreach(DEPENDENCY_FILE ${DEPENDENCIES})
+=C2=A0 =C2=A0 message("Dependency: ${DEPENDENCY_FILE}")
+endforeach()
+
+foreach(DEPENDENCY_FILE ${DEPENDENCIES})
+=C2=A0 =C2=A0 get_filename_component(libname ${DEPENDENCY_FILE} NAME_WE) +=C2=A0 =C2=A0 list (FIND ALLOWLIST ${libname} _index)
+=C2=A0 =C2=A0 if (_index EQUAL -1)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 message(FATAL_ERROR "Blocklisted dependen= cy: ${DEPENDENCY_FILE}")
+=C2=A0 =C2=A0 endif()
+endforeach()
diff --git a/static-build/test/static-build/exports.test.lua b/static-build= /test/static-build/exports.test.lua
new file mode 100755
index 000000000..de54973d8
--- /dev/null
+++ b/static-build/test/static-build/exports.test.lua
@@ -0,0 +1,142 @@
+#!/usr/bin/env tarantool
+
+local tap =3D require('tap')
+local ffi =3D require('ffi')
+ffi.cdef([[
+=C2=A0 =C2=A0 void *dlsym(void *handle, const char *symbol);
+]])
+
+local test =3D tap.test('exports')
+
+-- See `man 3 dlsym`:
+-- RTLD_DEFAULT
+--=C2=A0 =C2=A0Find the first occurrence of the desired symbol using the d= efault
+--=C2=A0 =C2=A0shared object search order. The search will include global = symbols
+--=C2=A0 =C2=A0in the executable and its dependencies, as well as symbols = in shared
+--=C2=A0 =C2=A0objects that were dynamically loaded with the RTLD_GLOBAL f= lag.
+local RTLD_DEFAULT =3D ffi.cast("void *", jit.os =3D=3D "OS= X" and -2LL or 0LL)
+
+local function check_symbol(sym)
+=C2=A0 =C2=A0 test:ok(ffi.C.dlsym(RTLD_DEFAULT, sym) ~=3D nil, ('Symbo= l %q found'):format(sym))
+end
+
+local check_symbols =3D {
+=C2=A0 =C2=A0 -- FFI
+
+=C2=A0 =C2=A0 'guava',
+=C2=A0 =C2=A0 'base64_decode',
+=C2=A0 =C2=A0 'base64_encode',
+=C2=A0 =C2=A0 'SHA1internal',
+=C2=A0 =C2=A0 'random_bytes',
+=C2=A0 =C2=A0 'fiber_time',
+=C2=A0 =C2=A0 'ibuf_create',
+=C2=A0 =C2=A0 'ibuf_destroy',
+=C2=A0 =C2=A0 'port_destroy',
+=C2=A0 =C2=A0 'csv_create',
+=C2=A0 =C2=A0 'csv_destroy',
+=C2=A0 =C2=A0 'title_get',
+=C2=A0 =C2=A0 'title_update',
+=C2=A0 =C2=A0 'tnt_iconv',
+=C2=A0 =C2=A0 'tnt_iconv_open',
+=C2=A0 =C2=A0 'tnt_iconv_close',
+=C2=A0 =C2=A0 'exception_get_int',
+=C2=A0 =C2=A0 'exception_get_string',
+
+=C2=A0 =C2=A0 'tarantool_lua_ibuf',
+=C2=A0 =C2=A0 'uuid_nil',
+=C2=A0 =C2=A0 'tt_uuid_create',
+=C2=A0 =C2=A0 'tt_uuid_str',
+=C2=A0 =C2=A0 'tt_uuid_is_equal',
+=C2=A0 =C2=A0 'tt_uuid_is_nil',
+=C2=A0 =C2=A0 'tt_uuid_bswap',
+=C2=A0 =C2=A0 'tt_uuid_from_string',
+=C2=A0 =C2=A0 'log_level',
+=C2=A0 =C2=A0 'log_format',
+=C2=A0 =C2=A0 'uri_parse',
+=C2=A0 =C2=A0 'uri_format',
+=C2=A0 =C2=A0 'PMurHash32',
+=C2=A0 =C2=A0 'PMurHash32_Process',
+=C2=A0 =C2=A0 'PMurHash32_Result',
+=C2=A0 =C2=A0 'crc32_calc',
+=C2=A0 =C2=A0 'mp_encode_double',
+=C2=A0 =C2=A0 'mp_encode_float',
+=C2=A0 =C2=A0 'mp_encode_decimal',
+=C2=A0 =C2=A0 'mp_decode_double',
+=C2=A0 =C2=A0 'mp_decode_float',
+=C2=A0 =C2=A0 'mp_decode_extl',
+=C2=A0 =C2=A0 'mp_sizeof_decimal',
+=C2=A0 =C2=A0 'decimal_unpack',
+
+=C2=A0 =C2=A0 'log_type',
+=C2=A0 =C2=A0 'say_set_log_level',
+=C2=A0 =C2=A0 'say_logrotate',
+=C2=A0 =C2=A0 'say_set_log_format',
+=C2=A0 =C2=A0 'tarantool_uptime',
+=C2=A0 =C2=A0 'tarantool_exit',
+=C2=A0 =C2=A0 'log_pid',
+=C2=A0 =C2=A0 'space_by_id',
+=C2=A0 =C2=A0 'space_run_triggers',
+=C2=A0 =C2=A0 'space_bsize',
+=C2=A0 =C2=A0 'box_schema_version',
+
+=C2=A0 =C2=A0 'crypto_EVP_MD_CTX_new',
+=C2=A0 =C2=A0 'crypto_EVP_MD_CTX_free',
+=C2=A0 =C2=A0 'crypto_HMAC_CTX_new',
+=C2=A0 =C2=A0 'crypto_HMAC_CTX_free',
+=C2=A0 =C2=A0 'crypto_stream_new',
+=C2=A0 =C2=A0 'crypto_stream_begin',
+=C2=A0 =C2=A0 'crypto_stream_append',
+=C2=A0 =C2=A0 'crypto_stream_commit',
+=C2=A0 =C2=A0 'crypto_stream_delete',
+
+=C2=A0 =C2=A0 -- Module API
+
+=C2=A0 =C2=A0 '_say',
+=C2=A0 =C2=A0 'swim_cfg',
+=C2=A0 =C2=A0 'swim_quit',
+=C2=A0 =C2=A0 'fiber_new',
+=C2=A0 =C2=A0 'fiber_cancel',
+=C2=A0 =C2=A0 'coio_wait',
+=C2=A0 =C2=A0 'coio_close',
+=C2=A0 =C2=A0 'coio_call',
+=C2=A0 =C2=A0 'coio_getaddrinfo',
+=C2=A0 =C2=A0 'luaT_call',
+=C2=A0 =C2=A0 'box_txn',
+=C2=A0 =C2=A0 'box_select',
+=C2=A0 =C2=A0 'clock_realtime',
+=C2=A0 =C2=A0 'string_strip_helper',
+
+=C2=A0 =C2=A0 -- Lua / LuaJIT
+
+=C2=A0 =C2=A0 'lua_newstate',
+=C2=A0 =C2=A0 'lua_close',
+=C2=A0 =C2=A0 'luaL_loadstring',
+=C2=A0 =C2=A0 'luaJIT_profile_start',
+=C2=A0 =C2=A0 'luaJIT_profile_stop',
+=C2=A0 =C2=A0 'luaJIT_profile_dumpstack',
+
+=C2=A0 =C2=A0 'ERR_error_string',
+=C2=A0 =C2=A0 'ERR_get_error',
+
+=C2=A0 =C2=A0 'EVP_get_digestbyname',
+=C2=A0 =C2=A0 'EVP_get_cipherbyname',
+=C2=A0 =C2=A0 'EVP_CIPHER_CTX_new',
+=C2=A0 =C2=A0 'EVP_CIPHER_CTX_free',
+=C2=A0 =C2=A0 'EVP_CIPHER_block_size',
+=C2=A0 =C2=A0 'HMAC_Init_ex',
+=C2=A0 =C2=A0 'HMAC_Update',
+=C2=A0 =C2=A0 'HMAC_Final',
+
+=C2=A0 =C2=A0 'ZSTD_compress',
+=C2=A0 =C2=A0 'ZSTD_decompress',
+=C2=A0 =C2=A0 'ZSTD_free',
+=C2=A0 =C2=A0 'ZSTD_malloc',
+=C2=A0 =C2=A0 'ZSTD_versionString',
+}
+
+test:plan(#check_symbols)
+for _, sym in ipairs(check_symbols) do
+=C2=A0 =C2=A0 check_symbol(sym)
+end
+
+os.exit(test:check() and 0 or 1)
diff --git a/static-build/test/static-build/traceback.test.lua b/static-bui= ld/test/static-build/traceback.test.lua
new file mode 100755
index 000000000..32e1ed8b5
--- /dev/null
+++ b/static-build/test/static-build/traceback.test.lua
@@ -0,0 +1,15 @@
+#!/usr/bin/env tarantool
+
+local tap =3D require('tap')
+local fiber =3D require('fiber')
+
+local test =3D tap.test('traceback')
+test:plan(1)
+
+local info =3D fiber.info()[fiber.id()]
+test:ok(info.backtrace ~=3D nil, 'fiber.info() has backtrace')
+for _, l in pairs(info.backtrace or {}) do
+=C2=A0 =C2=A0 test:diag('%s: %s', next(l))
+end
+
+os.exit(test:check() and 0 or 1)
--
2.26.2

--000000000000a97c9d05aef2a2c2--