Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Alexander V. Tikhonov" <avtikhon@tarantool.org>
To: Alexander Turenko <alexander.turenko@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v1] build: fix static build
Date: Wed, 27 Nov 2019 14:01:45 +0300	[thread overview]
Message-ID: <800161b742d52cabba25cb31c49abc7cd26dc02a.1574852472.git.avtikhon@tarantool.org> (raw)

Fixed static build with '-DBUILD_STATIC=ON' option:
 - added lzma library installation to Dockerfile for static build
 - added lzma library to unwind library for Tarantool build at file:
     cmake/compiler.cmake
 - added dl library to gomp and icu libraries for test/unit tests
   binaries builds at files:
     cmake/BuildMisc.cmake
     cmake/FindICU.cmake
Added static build to gitlab-ci in release check criteria named
as static_build job. Previously named static_build job renamed to
static_docker_build, due to it checks the build at Dockerfile.

Also changed 'wget' tool use to 'curl -O -L' to avoid of 500 HTTP
respond from sourceforge download server.

Added patch tool to Docker image bootstrap to be able to patch the
lzma sources.

Added 'build' directory removement to avoid of old configuration
at build/curl which is used for curl building.

Added '-j' option to make tool calls for all builds to speed it up.

Set Dockerfile WORKDIR from the very start of Tarantool sources
builds to make the Dockerfile code more readable and removed all
duplicating calls to Tarantool sources directory changes.

Close #4551
---

Github: https://github.com/tarantool/tarantool/tree/avtikhon/gh-4551-static-build-full-ci
Issue: https://github.com/tarantool/tarantool/issues/4551

 .gitlab-ci.yml         | 12 ++++++++++-
 .gitlab.mk             |  7 ++++++-
 Dockerfile.staticbuild | 46 +++++++++++++++++++++++++-----------------
 cmake/BuildMisc.cmake  |  2 +-
 cmake/FindICU.cmake    |  2 +-
 cmake/compiler.cmake   |  9 +++++++++
 6 files changed, 55 insertions(+), 23 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cf13c382e..3bdcfa745 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -230,9 +230,19 @@ debian_10:
     OS: 'debian'
     DIST: 'buster'
 
+# Static builds
+
 static_build:
+  <<: *release_only_definition
+  <<: *docker_test_definition
+  variables:
+    CMAKE_EXTRA_PARAMS: '-DBUILD_STATIC=ON'
+  script:
+    - ${GITLAB_MAKE} static_build
+
+static_docker_build:
   <<: *deploy_test_definition
   variables:
     RUN_TESTS: 'ON'
   script:
-    - ${GITLAB_MAKE} static_build
+    - ${GITLAB_MAKE} static_docker_build
diff --git a/.gitlab.mk b/.gitlab.mk
index 48a92e518..a5d4ec26e 100644
--- a/.gitlab.mk
+++ b/.gitlab.mk
@@ -110,5 +110,10 @@ package: git_submodule_update
 # Static build
 # ############
 
-static_build:
+deps_debian_static:
+	apt install -y -f liblzma-dev
+
+static_build: deps_debian_static test_debian_no_deps
+
+static_docker_build:
 	docker build --network=host --build-arg RUN_TESTS="${RUN_TESTS}" -f Dockerfile.staticbuild .
diff --git a/Dockerfile.staticbuild b/Dockerfile.staticbuild
index d63c18bd1..7c15858c7 100644
--- a/Dockerfile.staticbuild
+++ b/Dockerfile.staticbuild
@@ -20,6 +20,7 @@ RUN set -x \
         unzip \
         libunwind \
         zlib \
+        patch \
     && yum -y install \
         perl \
         gcc-c++ \
@@ -44,15 +45,15 @@ RUN set -x && \
     tar -xvf openssl-1.1.0h.tar.gz && \
     cd openssl-1.1.0h && \
     ./config --libdir=lib && \
-    make && make install
+    make -j && make install
 
 RUN set -x && \
     cd / && \
-    wget http://download.icu-project.org/files/icu4c/62.1/icu4c-62_1-src.tgz && \
+    curl -O -L http://download.icu-project.org/files/icu4c/62.1/icu4c-62_1-src.tgz && \
     tar -xvf icu4c-62_1-src.tgz && \
     cd icu/source && \
     ./configure --with-data-packaging=static --enable-static --enable-shared && \
-    make && make install
+    make -j && make install
 
 RUN set -x && \
     cd / && \
@@ -60,34 +61,41 @@ RUN set -x && \
     tar -xvf libunwind-1.3-rc1.tar.gz && \
     cd libunwind-1.3-rc1 && \
     ./configure --enable-static --enable-shared && \
-    make && make install
+    make -j && make install
+
+RUN set -x && \
+    mkdir /liblzma && cd /liblzma && \
+    yumdownloader --source xz-devel && \
+    rpm2cpio xz-*.src.rpm | cpio -idv && \
+    tar xf xz-*.tar.gz && \
+    for dir in * ; do cd ${dir} 2>/dev/null && break ; done && \
+    for patch in ../*.patch ; do patch -Np1 < ${patch} ; done && \
+    ./configure --enable-static && \
+    make -j && make install
 
 COPY . /tarantool
 
+WORKDIR /tarantool
+
 RUN set -x && \
-    cd tarantool && \
     git submodule init && \
     git submodule update
 
-WORKDIR /tarantool
-
 RUN set -x && \
     find . -name 'CMakeFiles' -type d -exec rm -rf {} + && \
-    find . -name 'CMakeCache.txt' -type f -delete
+    find . -name 'CMakeCache.txt' -type f -delete && \
+    rm -rf build
 
 RUN pip install -r /tarantool/test-run/requirements.txt
 
-RUN set -x \
-    && (cd /tarantool; \
-       cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-             -DENABLE_DIST:BOOL=ON \
-             -DBUILD_STATIC=ON \
-             -DOPENSSL_USE_STATIC_LIBS=ON \
-             -DOPENSSL_ROOT_DIR=/usr/local \
-             .) \
-    && make -C /tarantool -j
-
-RUN cd /tarantool && make install
+RUN set -x && \
+    cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+         -DENABLE_DIST:BOOL=ON \
+         -DBUILD_STATIC=ON \
+         -DOPENSSL_USE_STATIC_LIBS=ON \
+         -DOPENSSL_ROOT_DIR=/usr/local \
+         . && \
+    make -j && make install
 
 ARG RUN_TESTS
 RUN if [ -n "${RUN_TESTS}" ]; then \
diff --git a/cmake/BuildMisc.cmake b/cmake/BuildMisc.cmake
index b4a3ca1fc..0c571f326 100644
--- a/cmake/BuildMisc.cmake
+++ b/cmake/BuildMisc.cmake
@@ -39,7 +39,7 @@ macro(libmisc_build)
         else()
             set(GOMP_LIBRARY gomp)
         endif()
-        target_link_libraries(misc ${GOMP_LIBRARY} pthread)
+        target_link_libraries(misc ${GOMP_LIBRARY} pthread dl)
     endif()
 
     unset(misc_src)
diff --git a/cmake/FindICU.cmake b/cmake/FindICU.cmake
index 26f0683f3..2bb9a5d59 100644
--- a/cmake/FindICU.cmake
+++ b/cmake/FindICU.cmake
@@ -50,7 +50,7 @@ include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(ICU
     REQUIRED_VARS ICU_INCLUDE_DIR ICU_LIBRARY_I18N ICU_LIBRARY_UC)
 set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
-set(ICU_LIBRARIES ${ICU_LIBRARY_I18N} ${ICU_LIBRARY_UC} ${ICU_LIBRARY_DATA})
+set(ICU_LIBRARIES ${ICU_LIBRARY_I18N} ${ICU_LIBRARY_UC} ${ICU_LIBRARY_DATA} dl)
 mark_as_advanced(ICU_INCLUDE_DIR ICU_INCLUDE_DIRS
         ICU_LIBRARY_I18N ICU_LIBRARY_UC ICU_LIBRARIES)
 
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
index c9ad2b092..00fac1c66 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -171,6 +171,15 @@ if (ENABLE_BACKTRACE)
             NAMES ${UNWIND_PLATFORM_LIB_NAME})
         set(UNWIND_LIBRARIES ${UNWIND_PLATFORM_LIBRARY} ${UNWIND_LIBRARY})
     endif()
+    if(BUILD_STATIC)
+        set(LZMA_LIB_NAME liblzma.a)
+        find_library(LZMA_LIBRARY PATH_SUFFIXES system NAMES ${LZMA_LIB_NAME})
+        if (NOT LZMA_LIBRARY)
+            message (FATAL_ERROR "ENABLE_BACKTRACE option is set but lzma "
+                                 "library is not found")
+        endif()
+        set(UNWIND_LIBRARIES ${UNWIND_LIBRARIES} ${LZMA_LIBRARY})
+    endif()
     find_package_message(UNWIND_LIBRARIES "Found unwind" "${UNWIND_LIBRARIES}")
 endif()
 
-- 
2.17.1

             reply	other threads:[~2019-11-27 11:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27 11:01 Alexander V. Tikhonov [this message]
2019-11-27 12:33 Alexander V. Tikhonov
2019-12-05 14:55 ` Alexander Turenko
2019-12-10 13:14   ` Alexander Tikhonov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=800161b742d52cabba25cb31c49abc7cd26dc02a.1574852472.git.avtikhon@tarantool.org \
    --to=avtikhon@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v1] build: fix static build' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox