From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id CDAEA6EC57; Thu, 18 Mar 2021 11:52:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CDAEA6EC57 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616057549; bh=z0wZeTckOwCvS1FOzJadb6gYmH/FXpnv228XyVVVrE4=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=yLAeNjvhD0nAqKu9d11TqsnT+Tl8SyiYexSP40wepP+NNCYn3NUAMJZJbZCzXrZPv tTF4tYyEBd79Izug0ErgbP0y/qubjfv8QWmDyowE/8VjrFYZ4H11Wiu0KtmswiNjtf i2ymwFNCQ/RC8l3R+28r+i8UHknvJfWwsmapntXY= Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 BF69D6EC57 for ; Thu, 18 Mar 2021 11:51:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BF69D6EC57 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lMoNq-0003IV-3C; Thu, 18 Mar 2021 11:51:58 +0300 To: tarantool-patches@dev.tarantool.org Cc: alexander.turenko@tarantool.org Date: Thu, 18 Mar 2021 11:51:52 +0300 Message-Id: <20210318085154.31634-2-roman.habibov@tarantool.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210318085154.31634-1-roman.habibov@tarantool.org> References: <20210318085154.31634-1-roman.habibov@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD96485A7A9FC1318933D9BB3A6B6EC3969033B83865BA14179182A05F53808504092E5837D69B7940A4C35C626B1C2FDB2B69744230996378ADC5BA09D18E853F2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE764C944B6AA401A18EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F7C2A16C2A438FE58638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95CF89CA98302ED496F5FA3EFCD9A8AB9BDD71CBCEF5E781FF0A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE74A95F4E53E8DCE969FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C390D92131081DE748117882F4460429728AD0CFFFB425014E868A13BD56FB6657A7F4EDE966BC389F9E8FC8737B5C2249221D5A8161B58CB575ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE493B89ED3C7A6281781D2457FAF19517CF2C4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F05F538519369F3743B503F486389A921A5CC5B56E945C8DA X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C4C7A0BC55FA0FE5FC72A542688CD5D3BA52A0C3567DC54B18735FAEB6015C250DB1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB5F0C88D684269EDEDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34DFB7A809FB5370875CC7323C7B6B3BB27FBE5F9C2B729D7D4F65326C3CF5E2A3D831B324B3BF3A111D7E09C32AA3244C986516E380F7ECF725A17CFAADDE02FB95A9E0DC41E9A4CF729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXhV49kC0Ti5vAyucZ+cWSPi X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822616AF1ED46522219C1F9DAA8147E77C60F96A0E8EF440D4CA021B31A5B48C7CFFB559BB5D741EB9609AE011F3211FEEF240331F90058701C67EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Roman Khabibov via Tarantool-patches Reply-To: Roman Khabibov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Export the symbols to tarantool executable in the case of libCURL included as bundled library or static build. This patch is just 1.10 adaptation of the original commit 9fc57c4 performed by Yaroslav Dynnikov . --- CMakeLists.txt | 10 +++ extra/curl_symbols | 81 ++++++++++++++++++ extra/mkexports | 20 ++++- src/CMakeLists.txt | 5 +- test/box-tap/curl-exports.test.lua | 131 +++++++++++++++++++++++++++++ 5 files changed, 242 insertions(+), 5 deletions(-) create mode 100755 extra/curl_symbols create mode 100755 test/box-tap/curl-exports.test.lua diff --git a/CMakeLists.txt b/CMakeLists.txt index 84e019eb0..5990d026e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,6 +347,16 @@ else() find_package(CURL) endif() +# +# Export libcurl symbols if the library is bundled. +# +if (ENABLE_BUNDLED_LIBCURL OR BUILD_STATIC) + set(EXPORT_LIBCURL_SYMBOLS ON) +else() + set(EXPORT_LIBCURL_SYMBOLS OFF) +endif() +message(STATUS "EXPORT_LIBCURL_SYMBOLS: ${EXPORT_LIBCURL_SYMBOLS}") + # # ReadLine # diff --git a/extra/curl_symbols b/extra/curl_symbols new file mode 100755 index 000000000..89e247a00 --- /dev/null +++ b/extra/curl_symbols @@ -0,0 +1,81 @@ +curl_easy_cleanup +curl_easy_duphandle +curl_easy_escape +curl_easy_getinfo +curl_easy_init +curl_easy_pause +curl_easy_perform +curl_easy_recv +curl_easy_reset +curl_easy_send +curl_easy_setopt +curl_easy_strerror +curl_easy_unescape +curl_easy_upkeep +curl_escape +curl_formadd +curl_formfree +curl_formget +curl_free +curl_getdate +curl_getenv +curl_global_cleanup +curl_global_init +curl_global_init_mem +curl_global_sslset +curl_maprintf +curl_mfprintf +curl_mime_addpart +curl_mime_data +curl_mime_data_cb +curl_mime_encoder +curl_mime_filedata +curl_mime_filename +curl_mime_free +curl_mime_headers +curl_mime_init +curl_mime_name +curl_mime_subparts +curl_mime_type +curl_mprintf +curl_msnprintf +curl_msprintf +curl_multi_add_handle +curl_multi_assign +curl_multi_cleanup +curl_multi_fdset +curl_multi_info_read +curl_multi_init +curl_multi_perform +curl_multi_poll +curl_multi_remove_handle +curl_multi_setopt +curl_multi_socket +curl_multi_socket_action +curl_multi_socket_all +curl_multi_strerror +curl_multi_timeout +curl_multi_wait +curl_mvaprintf +curl_mvfprintf +curl_mvprintf +curl_mvsnprintf +curl_mvsprintf +curl_pushheader_byname +curl_pushheader_bynum +curl_share_cleanup +curl_share_init +curl_share_setopt +curl_share_strerror +curl_slist_append +curl_slist_free_all +curl_strequal +curl_strnequal +curl_unescape +curl_url +curl_url_cleanup +curl_url_dup +curl_url_get +curl_url_set +curl_version +curl_version_info diff --git a/extra/mkexports b/extra/mkexports index 145e5b8ce..2a3cd8401 100755 --- a/extra/mkexports +++ b/extra/mkexports @@ -2,22 +2,36 @@ # $1 - in file # $2 - out file # $3 - os -# $4 - export templates +# $4 - is bundled curl on/off flag +# $5 - curl symbols +# $6 - export templates +echo "$1" +echo "$2" +echo "$3" +echo "$4" +echo "$5" +echo "$6" if [ "x$3x" = xDarwinx ]; then # _func1 # _func2 sed -e 's/#.*//; /^[[:space:]]*$/d; s/^/_/;' $1 > $2 + if [ "x$4x" = xONx ]; then + sed -e 's/#.*//; /^[[:space:]]*$/d; s/^/_/;' $5 >> $2 + fi else # { # func1; # func2; # }; - echo "$4" + echo "$6" ( echo "{" && { # combine static defined list of functions cat $1 ; # with list of exported functions of bundled libraries - for so in $4 ; do { + if [ "x$4x" = xONx ]; then + cat $5 + fi ; + for so in $6 ; do { # exported names from shared object nm -D $so || # or follow patch from shared object script diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04289af3d..ee968820b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -231,13 +231,12 @@ target_link_libraries(server core bit uri uuid ${ICU_LIBRARIES}) # Rule of thumb: if exporting a symbol from a static library, list the # library here. set (reexport_libraries server core misc bitset csv - ${LUAJIT_LIBRARIES} ${MSGPUCK_LIBRARIES} ${ICU_LIBRARIES}) + ${LUAJIT_LIBRARIES} ${MSGPUCK_LIBRARIES} ${ICU_LIBRARIES} ${CURL_LIBRARIES}) set (common_libraries ${reexport_libraries} ${LIBYAML_LIBRARIES} ${READLINE_LIBRARIES} - ${CURL_LIBRARIES} ${ICONV_LIBRARIES} ${OPENSSL_LIBRARIES} ) @@ -310,6 +309,8 @@ add_custom_command( COMMAND ${CMAKE_SOURCE_DIR}/extra/mkexports ${CMAKE_SOURCE_DIR}/extra/exports ${exports_file} ${CMAKE_SYSTEM_NAME} + ${EXPORT_LIBCURL_SYMBOLS} + ${CMAKE_SOURCE_DIR}/extra/curl_symbols ${EXPORT_LIST} ) diff --git a/test/box-tap/curl-exports.test.lua b/test/box-tap/curl-exports.test.lua new file mode 100755 index 000000000..a8bb1a042 --- /dev/null +++ b/test/box-tap/curl-exports.test.lua @@ -0,0 +1,131 @@ +#!/usr/bin/env tarantool + +local tap = require('tap') +local ffi = require('ffi') +ffi.cdef([[ + void *dlsym(void *handle, const char *symbol); + struct curl_version_info_data { + int age; /* see description below */ + const char *version; /* human readable string */ + unsigned int version_num; /* numeric representation */ + const char *host; /* human readable string */ + int features; /* bitmask, see below */ + char *ssl_version; /* human readable string */ + long ssl_version_num; /* not used, always zero */ + const char *libz_version; /* human readable string */ + }; +]]) + +local test = tap.test('curl-symbols') +test:plan(1) + +local RTLD_DEFAULT +-- 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 shared +-- objects that were dynamically loaded with the RTLD_GLOBAL flag. +if jit.os == "OSX" then + RTLD_DEFAULT = ffi.cast("void *", -2LL) +else + RTLD_DEFAULT = ffi.cast("void *", 0LL) +end + +-- The following list was obtained by parsing libcurl.a static library: +-- nm libcurl.a | grep -oP 'T \K(curl_.+)$' | sort +local curl_symbols = { + 'curl_easy_cleanup', + 'curl_easy_duphandle', + 'curl_easy_escape', + 'curl_easy_getinfo', + 'curl_easy_init', + 'curl_easy_pause', + 'curl_easy_perform', + 'curl_easy_recv', + 'curl_easy_reset', + 'curl_easy_send', + 'curl_easy_setopt', + 'curl_easy_strerror', + 'curl_easy_unescape', + 'curl_easy_upkeep', + 'curl_escape', + 'curl_formadd', + 'curl_formfree', + 'curl_formget', + 'curl_free', + 'curl_getdate', + 'curl_getenv', + 'curl_global_cleanup', + 'curl_global_init', + 'curl_global_init_mem', + 'curl_global_sslset', + 'curl_maprintf', + 'curl_mfprintf', + 'curl_mime_addpart', + 'curl_mime_data', + 'curl_mime_data_cb', + 'curl_mime_encoder', + 'curl_mime_filedata', + 'curl_mime_filename', + 'curl_mime_free', + 'curl_mime_headers', + 'curl_mime_init', + 'curl_mime_name', + 'curl_mime_subparts', + 'curl_mime_type', + 'curl_mprintf', + 'curl_msnprintf', + 'curl_msprintf', + 'curl_multi_add_handle', + 'curl_multi_assign', + 'curl_multi_cleanup', + 'curl_multi_fdset', + 'curl_multi_info_read', + 'curl_multi_init', + 'curl_multi_perform', + 'curl_multi_poll', + 'curl_multi_remove_handle', + 'curl_multi_setopt', + 'curl_multi_socket', + 'curl_multi_socket_action', + 'curl_multi_socket_all', + 'curl_multi_strerror', + 'curl_multi_timeout', + 'curl_multi_wait', + 'curl_mvaprintf', + 'curl_mvfprintf', + 'curl_mvprintf', + 'curl_mvsnprintf', + 'curl_mvsprintf', + 'curl_pushheader_byname', + 'curl_pushheader_bynum', + 'curl_share_cleanup', + 'curl_share_init', + 'curl_share_setopt', + 'curl_share_strerror', + 'curl_slist_append', + 'curl_slist_free_all', + 'curl_strequal', + 'curl_strnequal', + 'curl_unescape', + 'curl_url', + 'curl_url_cleanup', + 'curl_url_dup', + 'curl_url_get', + 'curl_url_set', + 'curl_version', + 'curl_version_info', +} + +test:test('curl_symbols', function(t) + t:plan(#curl_symbols) + for _, sym in ipairs(curl_symbols) do + t:ok( + ffi.C.dlsym(RTLD_DEFAULT, sym) ~= nil, + ('Symbol %q found'):format(sym) + ) + end +end) + +os.exit(test:check() and 0 or 1) -- 2.24.3 (Apple Git-128)