From: Roman Khabibov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org
Cc: alexander.turenko@tarantool.org
Subject: [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols
Date: Fri, 19 Mar 2021 17:13:06 +0300 [thread overview]
Message-ID: <20210319141308.98726-2-roman.habibov@tarantool.org> (raw)
In-Reply-To: <20210319141308.98726-1-roman.habibov@tarantool.org>
Export the symbols to tarantool executable in the case of libCURL
included as bundled library.
This patch is just 1.10 adaptation of the original commit 9fc57c4
performed by Yaroslav Dynnikov <yaroslav.dynnikov@gmail.com>.
---
CMakeLists.txt | 10 +++
| 81 ++++++++++++++++++++
| 14 +++-
src/CMakeLists.txt | 5 +-
test/box-tap/curl-build.test.lua | 124 +++++++++++++++++++++++++++++++
5 files changed, 229 insertions(+), 5 deletions(-)
create mode 100755 extra/curl_symbols
create mode 100755 test/box-tap/curl-build.test.lua
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 84e019eb0..7e2ddb503 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)
+ set(EXPORT_LIBCURL_SYMBOLS ON)
+else()
+ set(EXPORT_LIBCURL_SYMBOLS OFF)
+endif()
+message(STATUS "EXPORT_LIBCURL_SYMBOLS: ${EXPORT_LIBCURL_SYMBOLS}")
+
#
# ReadLine
#
--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
--git a/extra/mkexports b/extra/mkexports
index 145e5b8ce..c10f20ae4 100755
--- a/extra/mkexports
+++ b/extra/mkexports
@@ -2,22 +2,30 @@
# $1 - in file
# $2 - out file
# $3 - os
-# $4 - export templates
+# $4 - is bundled curl on/off flag
+# $5 - curl symbols
+# $6 - export templates
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-build.test.lua b/test/box-tap/curl-build.test.lua
new file mode 100755
index 000000000..ab58efffa
--- /dev/null
+++ b/test/box-tap/curl-build.test.lua
@@ -0,0 +1,124 @@
+#!/usr/bin/env tarantool
+
+local tap = require('tap')
+local ffi = require('ffi')
+ffi.cdef([[
+ void *dlsym(void *handle, const char *symbol);
+]])
+
+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',
+}
+
+--
+-- Check if all curl symbols are exported.
+--
+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)
next prev parent reply other threads:[~2021-03-19 14:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-19 14:13 [Tarantool-patches] [PATCH 0/3] Export curl symbols, enable smtp and install headers Roman Khabibov via Tarantool-patches
2021-03-19 14:13 ` Roman Khabibov via Tarantool-patches [this message]
2021-03-31 23:56 ` [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols Alexander Turenko via Tarantool-patches
2021-04-09 19:54 ` Roman Khabibov via Tarantool-patches
2021-04-01 0:01 ` Alexander Turenko via Tarantool-patches
2021-03-19 14:13 ` [Tarantool-patches] [PATCH 2/3] build: enable smtp in libCURL Roman Khabibov via Tarantool-patches
2021-04-01 0:52 ` Alexander Turenko via Tarantool-patches
2021-04-09 19:54 ` Roman Khabibov via Tarantool-patches
2021-03-19 14:13 ` [Tarantool-patches] [PATCH 3/3] build: install libCURL headers Roman Khabibov via Tarantool-patches
2021-04-01 0:10 ` Alexander Turenko via Tarantool-patches
2021-04-09 19:54 ` Roman Khabibov via Tarantool-patches
2021-04-13 13:14 ` [Tarantool-patches] [PATCH 0/3] Export curl symbols, enable smtp and install headers Leonid Vasiliev via Tarantool-patches
2021-04-14 17:52 ` Roman Khabibov via Tarantool-patches
-- strict thread matches above, loose matches on Subject: below --
2021-03-18 11:33 [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols Бабин Олег via Tarantool-patches
2021-03-18 8:51 [Tarantool-patches] [PATCH 0/3] Install iibCURL headers and export libCURL symbols for 1.10 Roman Khabibov via Tarantool-patches
2021-03-18 8:51 ` [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols Roman Khabibov via Tarantool-patches
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=20210319141308.98726-2-roman.habibov@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=alexander.turenko@tarantool.org \
--cc=roman.habibov@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols' \
/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