build: enable cmake in curl build
Initially tried to change autoconf tools in Curl build to cmake and found the following build issue on: CentOS 6 CentOS 7 Debian 8 Ubuntu 14.04 Issue found: CMake Error at CMakeLists.txt:41 (cmake_minimum_required): CMake 3.0 or higher is required. You are running version 2.8.12.2 To fix the issue check is removed of the version from curl sources in Tarantool's third party '<root Tarantool sources>/third_party/curl': 12af024bc85606b14ffc415413a7e86e6bbee7eb ('Enable curl build with old cmake') After this fix completely changed autoconf to cmake in curl build. Autoconf part was completely removed and code cleaned up for cmake. For curl cmake build all autoconf options were ported to cmake configuration call, check the accurate list of the change in [1]. Also the following issues resolved: 1. Found that CURL cmake configuration file: third_party/curl/lib/CMakeLists.txt has installation part for built libcurl.a library: install(TARGETS ${LIB_NAME} EXPORT ${TARGETS_EXPORT_NAME} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} where it changes CMAKE_INSTALL_LIBDIR to appropriate name with suffix of the architecture, like: lib lib64 x86_64 Found that find_library routine from the file: cmake/FindLibCURL.cmake returns only 'lib' value and it breaks the building of the depends binaries. To avoid of it the CMAKE_INSTALL_LIBDIR option was set to cmake call: -DCMAKE_INSTALL_LIBDIR=lib 2. Found issue with building on CentOS 6: Linking C executable curl build/ares/dest/lib/libcares.a(ares__timeval.c.o): In function `ares__tvnow': ares__timeval.c:(.text+0x15): undefined reference to `clock_gettime' collect2: error: ld returned 1 exit status It was fixed with added "-lrt" flag to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS build flags, when cmake version is lower than 3.0 and RT library had needed function. 3. Found issues with building Tarantool statically on Debian 9 and its package build on CentOS 8. Building statically got the issues with openssl linking, like [2]: static-build/openssl-prefix/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_lock_new': threads_pthread.c:(.text+0x45): undefined reference to `pthread_rwlock_init' It happened because in openssl radically changed how threads-related things were handled before 1.1.0 version. It required the application to provide us with the locking functionality in form of callbacks. Since 1.1.0, these matters are entirely internal, so libcrypto requires the presence of the platform specific thread implementation of our choosing, which is pthread on everything. After '-pthread' added to C compile flags package build on CentOS 8 failed with the issue [3]: /build/usr/src/debug/tarantool-2.6.0.141/third_party/curl/lib/warnless.c:101:4: error: #error "SIZEOF_CURL_OFF_T not defined" # error "SIZEOF_CURL_OFF_T not defined" ^~~~~ /build/usr/src/debug/tarantool-2.6.0.141/third_party/curl/lib/warnless.c: In function 'curlx_uztoso': /build/usr/src/debug/tarantool-2.6.0.141/third_party/curl/lib/warnless.c:192:40: error: 'CURL_MASK_SCOFFT' undeclared (first use in this function); did you mean 'CURL_MASK_SINT'? return (curl_off_t)(uznum & (size_t) CURL_MASK_SCOFFT); ^~~~~~~~~~~~~~~~ CURL_MASK_SINT To avoid of the issue decided to use '-pthread' flag only for openssl when it had not this flag in openssl compilation. 4. Found issue with static build using CentOS 7, where SSL cmake rule failed. Building the image got the issue: [ 1%] Performing configure step for 'bundled-libcurl-project' CMake Warning at CMakeLists.txt:50 (message): the curl cmake build system is poorly maintained. Be aware -- curl version=[7.66.0-DEV] -- Found c-ares: /tarantool/build/ares/dest/lib/libcares.a Found *nroff option: -- -man CMake Error at /usr/share/cmake/Modules/FindOpenSSL.cmake:278 (list): list GET given empty list Call Stack (most recent call first): CMakeLists.txt:347 (find_package) Root cause of the issue that Dockerfile uses globaly installed openSSL with: cmake ... -DOPENSSL_ROOT_DIR=/usr/local ... Its cmake build file: /usr/share/cmake/Modules/FindOpenSSL.cmake fails on parsing the SSL version: it has: REGEX "^#define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*") but it should to use: REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*") Anyway we want to use the same OpenSSL library for libcurl, as is used for Tarantool itself. So the path to it set for cURL build: list(APPEND LIBCURL_CMAKE_FLAGS "-DCMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/cmake") 5. In CMake build CMAKE_USE_LIBSSH2 flag is enabled by default, while in autoconf --with-libssh2 was disabled by default. We need to switch CMAKE_USE_LIBSSH2 flag off with: list(APPEND LIBCURL_CMAKE_FLAGS "-DCMAKE_USE_LIBSSH2=OFF") to avoid of linking issues, like: ld: libssh2.c:(.text+0x4d8): undefined reference to `libssh2_*... this issue exists in curl issues [4]. Furthermore the following defaults are also disabled to keep the configuration consistent with autoconf one: list(APPEND LIBCURL_CMAKE_FLAGS "-DPICKY_COMPILER=OFF") list(APPEND LIBCURL_CMAKE_FLAGS "-DBUILD_CURL_EXE=OFF") Closes #4968 Closes #5019 Closes #5396 [1] - https://github.com/tarantool/tarantool/issues/4968#issue-617183031 [2] - https://gitlab.com/tarantool/tarantool/-/jobs/779176133#L6021 [3] - https://gitlab.com/tarantool/tarantool/-/jobs/778309145#L3060 [4] - https://github.com/curl/curl/issues/1146
Please register or sign in to comment