<div dir="ltr">I’ve squashed commit and changed it’s message;<br>Also I’ve sended diff at previous answer<br><br><a href="https://github.com/tarantool/tarantool/tree/rosik/refactor-static-build">https://github.com/tarantool/tarantool/tree/rosik/refactor-static-build</a></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">ср, 5 авг. 2020 г. в 20:08, Mavr Huston <<a href="mailto:huston.mavr@gmail.com">huston.mavr@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi, thanks for the review!<br><br>libicu installs as ExternalProject_Add too, its missed in commit message;<br><br>Problem with curses and ncurses was on macOS and linux, because libcurses<br>is an entire copy of libncurses, and tarantool links with system<br>libcurses instead of libncurses installed as tarantool dependency, but<br>module FindCurses.cmkae provides workaround for this problem -<br>CURSES_NEED_NCURSES flag.- to use ncurses instead of curses. (i will fix<br>this part at commit message)<br><br>About disable-shred flag, used at libcurl building - we want to link only with<br>static libraries, so we prevent creating unused .so.<br><br>I've renamed static_build_no_deps_* jobs after review to static_build_cmake_*<br><br>Also about such path tarantool-prefix/* - it's a cmake ExternalProject_Add()<br>default path (i've also added comment at .<a href="http://travis.mk" target="_blank">travis.mk</a>)<br><br>Useless comments "Init macOS test env" deleted.<br><br>>      if (BUILD_STATIC)<br>> -        set(LIBZ_LIB_NAME libz.a)<br>> +        find_library(LIBZ_LIBRARY NAMES libz.a)<br>>      else()<br>> -        set(LIBZ_LIB_NAME z)<br>> +        find_library(LIBZ_LIBRARY NAMES z)<br>>      endif()<br>> -    find_library(LIBZ_LIBRARY NAMES ${LIBZ_LIB_NAME})<br>Here we simplified code, by deleting useless variable.<br><br>I've added commentaries to cmake/compiler.cmake about libunwind on macOS<br>and about ignoring flag -static-libstdc++ on macOS<br><br>I've fixed static-build for using system compiler:  gcc/g++ on linux <br>and clang/clang++ on macOS<br><br>I've refactored IF (NOT APPLE) condition to IF (APPLE) at<br>static-build/CMakeLists.txt<br><br>I've mentioned macOS dependencies at static-build/README.md xcode-tools and<br>others, also I've added example with CMAKE_TARANTOOL_ARGS.<br><br>Added commentaries about _EP_INSTALL_DIR at static-build/CMakeLists.txt<br><br>Also deleted unused use_unix_sockets_iproto = True<br><br>Also deleted curl-features.test.lua, because after rebase on master it fails,<br>due to missing curl_version_info symbol at tarantool binary. This symbol lost<br>after #807c7fa584f21ee955b2a14623d70f7510a3650d (build: update curl submodule<br>to 7.71.1 version )<br><br><br>After pass the review I'll squash this changes to base commit and update commit<br>message.<br><br>Here is a diff of changes:<br>=====================================<br><br>diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml<br>index 5ec5dd9b9..c9aef3dc7 100644<br>--- a/.gitlab-ci.yml<br>+++ b/.gitlab-ci.yml<br>@@ -534,14 +534,14 @@ static_build:<br>   script:<br>     - ${GITLAB_MAKE} test_static_build<br> <br>-static_build_no_deps_linux:<br>+static_build_cmake_linux:<br>   <<: *docker_test_definition<br>   script:<br>-    - ${GITLAB_MAKE} test_static_build_no_deps_linux<br>+    - ${GITLAB_MAKE} test_static_build_cmake_linux<br> <br>-static_build_no_deps_osx_15:<br>+static_build_cmake_osx_15:<br>   stage: test<br>   tags:<br>     - osx_15<br>   script:<br>-    - ${GITLAB_MAKE} test_static_build_no_deps_osx<br>+    - ${GITLAB_MAKE} test_static_build_cmake_osx<br>diff --git a/.<a href="http://travis.mk" target="_blank">travis.mk</a> b/.<a href="http://travis.mk" target="_blank">travis.mk</a><br>index 64862348f..482672429 100644<br>--- a/.<a href="http://travis.mk" target="_blank">travis.mk</a><br>+++ b/.<a href="http://travis.mk" target="_blank">travis.mk</a><br>@@ -149,8 +149,8 @@ test_static_build: deps_debian_static<br>     CMAKE_EXTRA_PARAMS=-DBUILD_STATIC=ON make -f .<a href="http://travis.mk" target="_blank">travis.mk</a> test_debian_no_deps<br> <br> # New static build<br>-<br>-test_static_build_no_deps_linux:<br>+# builddir used in this target - is a default build path from cmake ExternalProject_Add()<br>+test_static_build_cmake_linux:<br>      cd static-build && cmake . && make -j && ctest -V<br>    cd test && /usr/bin/python test-run.py --force \<br>             --builddir ${PWD}/static-build/tarantool-prefix/src/tarantool-build $(TEST_RUN_EXTRA_PARAMS)<br>@@ -218,7 +218,6 @@ INIT_TEST_ENV_OSX=\<br>                rm -rf /tmp/tnt<br> <br> test_osx_no_deps: build_osx<br>-   # Init macOS test env<br>        ${INIT_TEST_ENV_OSX}; \<br>      cd test && ./test-run.py --vardir /tmp/tnt --force $(TEST_RUN_EXTRA_PARAMS)<br> <br>@@ -233,9 +232,9 @@ base_deps_osx:<br>  brew install --force ${STATIC_OSX_PKGS} || brew upgrade ${STATIC_OSX_PKGS}<br>   pip install --force-reinstall -r test-run/requirements.txt<br> <br>-test_static_build_no_deps_osx: base_deps_osx<br>+# builddir used in this target - is a default build path from cmake ExternalProject_Add()<br>+test_static_build_cmake_osx: base_deps_osx<br>       cd static-build && cmake . && make -j && ctest -V<br>-    # Init macOS test env<br>        ${INIT_TEST_ENV_OSX}; \<br>      cd test && ./test-run.py --vardir /tmp/tnt \<br>                 --builddir ${PWD}/static-build/tarantool-prefix/src/tarantool-build \<br>diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake<br>index 8422181d6..afe480679 100644<br>--- a/cmake/FindReadline.cmake<br>+++ b/cmake/FindReadline.cmake<br>@@ -14,6 +14,14 @@ if(BUILD_STATIC)<br>     if (NOT CURSES_INFO_LIBRARY)<br>         set(CURSES_INFO_LIBRARY "")<br>     endif()<br>+<br>+    # From Modules/FindCurses.cmake:<br>+    # Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the<br>+    # ``find_package(Curses)`` call if NCurses functionality is required.<br>+    # This flag is set for linking with required library (installed<br>+    # via static-build/CMakeLists.txt). If this variable won't be set<br>+    # then tarantool binary links with system library curses which is an<br>+    # entire copy of ncurses<br>     set(CURSES_NEED_NCURSES TRUE)<br> endif()<br> <br>diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake<br>index 14f1e1186..db2ae6227 100644<br>--- a/cmake/compiler.cmake<br>+++ b/cmake/compiler.cmake<br>@@ -131,6 +131,8 @@ set(CMAKE_REQUIRED_INCLUDES "")<br> if(BUILD_STATIC AND NOT TARGET_OS_DARWIN)<br>     set(UNWIND_LIB_NAME libunwind.a)<br> else()<br>+    # libunwind can't be compiled on macOS.<br>+    # But there exists libunwind.dylib as a part of MacOSSDK<br>     set(UNWIND_LIB_NAME unwind)<br> endif()<br> find_library(UNWIND_LIBRARY PATH_SUFFIXES system NAMES ${UNWIND_LIB_NAME})<br>@@ -192,6 +194,9 @@ if (ENABLE_BACKTRACE)<br>     find_package_message(UNWIND_LIBRARIES "Found unwind" "${UNWIND_LIBRARIES}")<br> endif()<br> <br>+# On macOS there is no '-static-libstdc++' flag and it's use will<br>+# raise following error:<br>+# error: argument unused during compilation: '-static-libstdc++'<br> if(BUILD_STATIC AND NOT TARGET_OS_DARWIN)<br>     # Static linking for c++ routines<br>     add_compile_flags("C;CXX" "-static-libstdc++")<br>diff --git a/static-build/CMakeLists.txt b/static-build/CMakeLists.txt<br>index 86582af0a..53ceb609c 100644<br>--- a/static-build/CMakeLists.txt<br>+++ b/static-build/CMakeLists.txt<br>@@ -9,11 +9,18 @@ set(NCURSES_VERSION 6.2)<br> set(READLINE_VERSION 8.0)<br> set(UNWIND_VERSION 1.3-rc1)<br> <br>-find_program(C_COMPILER gcc)<br>-find_program(CXX_COMPILER g++)<br>+if (APPLE)<br>+    find_program(C_COMPILER clang)<br>+    find_program(CXX_COMPILER clang++)<br>+else()<br>+    find_program(C_COMPILER gcc)<br>+    find_program(CXX_COMPILER g++)<br>+endif()<br> set(CMAKE_C_COMPILER ${C_COMPILER})<br> set(CMAKE_CXX_COMPILER ${CXX_COMPILER})<br> <br>+# Install all libraries required by tarantool at current build dir<br>+<br> #<br> # OpenSSL<br> #<br>@@ -80,7 +87,18 @@ ExternalProject_Add(readline<br> #<br> # ICONV<br> #<br>-if (NOT APPLE)<br>+if (APPLE)<br>+    ExternalProject_Add(iconv<br>+        URL <a href="https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz" target="_blank">https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz</a><br>+        CONFIGURE_COMMAND CC=${CMAKE_C_COMPILER}<br>+            <SOURCE_DIR>/configure<br>+            --prefix=<INSTALL_DIR><br>+            --disable-shared<br>+            --enable-static<br>+            --with-gnu-ld<br>+        STEP_TARGETS download<br>+    )<br>+else()<br>     # In linux iconv is embedded into glibc<br>     # So we find system header and copy it locally<br>     find_path(ICONV_INCLUDE_DIR iconv.h)<br>@@ -101,20 +119,11 @@ if (NOT APPLE)<br>     add_custom_target(iconv<br>         DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/iconv-prefix/include/iconv.h"<br>     )<br>+    # This is a hack for further getting install directory of library<br>+    # by ExternalProject_Get_Property<br>     set_target_properties(iconv<br>         PROPERTIES _EP_INSTALL_DIR ${ICONV_INSTALL_PREFIX}<br>     )<br>-else()<br>-    ExternalProject_Add(iconv<br>-        URL <a href="https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz" target="_blank">https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz</a><br>-        CONFIGURE_COMMAND CC=${CMAKE_C_COMPILER}<br>-            <SOURCE_DIR>/configure<br>-            --prefix=<INSTALL_DIR><br>-            --disable-shared<br>-            --enable-static<br>-            --with-gnu-ld<br>-        STEP_TARGETS download<br>-    )<br> endif()<br> <br> #<br>@@ -162,6 +171,8 @@ if (APPLE)<br>     endif()<br> <br>     add_custom_target(unwind DEPENDS ${UNWIND_DEPENDENCIES})<br>+    # This is a hack for further getting install directory of library<br>+    # by ExternalProject_Get_Property<br>     set_target_properties(unwind<br>         PROPERTIES _EP_INSTALL_DIR ${UNWIND_INSTALL_PREFIX}<br>     )<br>@@ -178,6 +189,8 @@ else()<br>     )<br> endif()<br> <br>+# Get install directories of builded libraries for building<br>+# tarantool with custon CMAKE_PREFIX_PATH<br> foreach(PROJ openssl icu zlib ncurses readline iconv unwind)<br>     ExternalProject_Get_Property(${PROJ} install_dir)<br>     set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:${install_dir})<br>@@ -197,16 +210,14 @@ ExternalProject_Add(tarantool<br>         -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}<br>         -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=FALSE<br>         -DOPENSSL_USE_STATIC_LIBS=TRUE<br>-        -DCMAKE_BUILD_TYPE=Debug<br>         -DBUILD_STATIC=TRUE<br>         -DENABLE_DIST=TRUE<br>         -DENABLE_BACKTRACE=TRUE<br>-        -DPACKAGE:STRING=${PACKAGE_NAME}<br>         -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}<br>         -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}<br>         ${CMAKE_TARANTOOL_ARGS}<br>-    BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} -j<br>     STEP_TARGETS build<br>+    BUILD_COMMAND $(MAKE)<br> )<br> <br> enable_testing()<br>diff --git a/static-build/README.md b/static-build/README.md<br>index 29fe085c3..0019e963f 100644<br>--- a/static-build/README.md<br>+++ b/static-build/README.md<br>@@ -13,6 +13,24 @@ yum install -y \<br>     python-msgpack python-yaml python-argparse python-six python-gevent<br> ```<br> <br>+MacOS:<br>+<br>+Before you start please install default Xcode Tools by Apple:<br>+<br>+```<br>+sudo xcode-select --install<br>+sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer<br>+```<br>+<br>+Install brew using command from<br>+[Homebrew repository instructions](<a href="https://github.com/Homebrew/inst" target="_blank">https://github.com/Homebrew/inst</a>)<br>+<br>+After that run next script:<br>+<br>+```bash<br>+  brew install autoconf automake libtool cmake file://$${PWD}/tools/brew_taps/tntpython2.rbs<br>+  pip install --force-reinstall -r test-run/requirements.txt<br>+```<br> <br> ### Usage<br> <br>@@ -21,3 +39,20 @@ cmake .<br> make -j<br> ctest -V<br> ```<br>+<br>+## Customize your build<br>+<br>+If you want to customise build, you need to set `CMAKE_TARANTOOL_ARGS` variable<br>+<br>+### Usage<br>+<br>+There is three types of `CMAKE_BUILD_TYPE`:<br>+* Debug - default<br>+* Release<br>+* RelWithDebInfo<br>+<br>+And you want to build tarantool with RelWithDebInfo:<br>+<br>+```bash<br>+cmake -DCMAKE_TARANTOOL_ARGS="-DCMAKE_BUILD_TYPE=RelWithDebInfo" .<br>+```<br>diff --git a/static-build/test/static-build/curl-features.test.lua b/static-build/test/static-build/curl-features.test.lua<br>deleted file mode 100755<br>index 57b1c4306..000000000<br>--- a/static-build/test/static-build/curl-features.test.lua<br>+++ /dev/null<br>@@ -1,67 +0,0 @@<br>-#!/usr/bin/env tarantool<br>-<br>-local tap = require('tap')<br>-local ffi = require('ffi')<br>-ffi.cdef([[<br>-    struct curl_version_info_data {<br>-        int age;                  /* see description below */<br>-        const char *version;      /* human readable string */<br>-        unsigned int version_num; /* numeric representation */<br>-        const char *host;         /* human readable string */<br>-        int features;             /* bitmask, see below */<br>-        char *ssl_version;        /* human readable string */<br>-        long ssl_version_num;     /* not used, always zero */<br>-        const char *libz_version; /* human readable string */<br>-        const char * const *protocols; /* protocols */<br>-<br>-        /* when 'age' is CURLVERSION_SECOND or higher, the members below exist */<br>-        const char *ares;         /* human readable string */<br>-        int ares_num;             /* number */<br>-<br>-        /* when 'age' is CURLVERSION_THIRD or higher, the members below exist */<br>-        const char *libidn;       /* human readable string */<br>-<br>-        /* when 'age' is CURLVERSION_FOURTH or higher (>= 7.16.1), the members<br>-           below exist */<br>-        int iconv_ver_num;       /* '_libiconv_version' if iconv support enabled */<br>-<br>-        const char *libssh_version; /* human readable string */<br>-<br>-        /* when 'age' is CURLVERSION_FIFTH or higher (>= 7.57.0), the members<br>-           below exist */<br>-        unsigned int brotli_ver_num; /* Numeric Brotli version<br>-                                        (MAJOR << 24) | (MINOR << 12) | PATCH */<br>-        const char *brotli_version; /* human readable string. */<br>-<br>-        /* when 'age' is CURLVERSION_SIXTH or higher (>= 7.66.0), the members<br>-           below exist */<br>-        unsigned int nghttp2_ver_num; /* Numeric nghttp2 version<br>-                                         (MAJOR << 16) | (MINOR << 8) | PATCH */<br>-        const char *nghttp2_version; /* human readable string. */<br>-<br>-        const char *quic_version;    /* human readable quic (+ HTTP/3) library +<br>-                                        version or NULL */<br>-<br>-        /* when 'age' is CURLVERSION_SEVENTH or higher (>= 7.70.0), the members<br>-           below exist */<br>-        const char *cainfo;          /* the built-in default CURLOPT_CAINFO, might<br>-                                        be NULL */<br>-        const char *capath;          /* the built-in default CURLOPT_CAPATH, might<br>-                                        be NULL */<br>-    };<br>-<br>-    struct curl_version_info_data *curl_version_info(int age);<br>-]])<br>-<br>-local info = ffi.C.curl_version_info(7)<br>-local test = tap.test('curl-features')<br>-test:plan(2)<br>-<br>-if test:ok(info.ssl_version ~= nil, 'Curl built with SSL support') then<br>-    test:diag('ssl_version: ' .. ffi.string(info.ssl_version))<br>-end<br>-if test:ok(info.libz_version ~= nil, 'Curl built with LIBZ') then<br>-    test:diag('libz_version: ' .. ffi.string(info.libz_version))<br>-end<br>-<br>-os.exit(test:check() and 0 or 1)<br>diff --git a/static-build/test/static-build/suite.ini b/static-build/test/static-build/suite.ini<br>index 4da3d5d2f..92e349466 100644<br>--- a/static-build/test/static-build/suite.ini<br>+++ b/static-build/test/static-build/suite.ini<br>@@ -3,4 +3,3 @@ core = app<br> description = Static build tests<br> script = box.lua<br> is_parallel = True<br>-use_unix_sockets_iproto = True<br></div>
</blockquote></div>