From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A082A46970F for ; Wed, 27 Nov 2019 14:01:47 +0300 (MSK) From: "Alexander V. Tikhonov" Date: Wed, 27 Nov 2019 14:01:45 +0300 Message-Id: <800161b742d52cabba25cb31c49abc7cd26dc02a.1574852472.git.avtikhon@tarantool.org> Subject: [Tarantool-patches] [PATCH v1] build: fix static build List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Turenko Cc: tarantool-patches@dev.tarantool.org 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