Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH 0/3] Export curl symbols, enable smtp and install headers
@ 2021-03-19 14:13 Roman Khabibov via Tarantool-patches
  2021-03-19 14:13 ` [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols Roman Khabibov via Tarantool-patches
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Roman Khabibov via Tarantool-patches @ 2021-03-19 14:13 UTC (permalink / raw)
  To: tarantool-patches; +Cc: alexander.turenko

The patchset is for 1.10 only.

Issue: https://github.com/tarantool/smtp/issues/24
Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/curl-smtp_1_10

Roman Khabibov (3):
  build: export libCURL symbols
  build: enable smtp in libCURL
  build: install libCURL headers

 CMakeLists.txt                   |  17 ++++
 cmake/BuildLibCURL.cmake         |   2 +-
 extra/curl_symbols               |  81 ++++++++++++++++
 extra/mkexports                  |  14 ++-
 rpm/tarantool.spec               |   9 ++
 src/CMakeLists.txt               |   5 +-
 test/box-tap/curl-build.test.lua | 160 +++++++++++++++++++++++++++++++
 7 files changed, 282 insertions(+), 6 deletions(-)
 create mode 100755 extra/curl_symbols
 create mode 100755 test/box-tap/curl-build.test.lua

-- 
2.24.3 (Apple Git-128)


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols
  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
  2021-03-31 23:56   ` Alexander Turenko 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
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 15+ messages in thread
From: Roman Khabibov via Tarantool-patches @ 2021-03-19 14:13 UTC (permalink / raw)
  To: tarantool-patches; +Cc: alexander.turenko

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 +++
 extra/curl_symbols               |  81 ++++++++++++++++++++
 extra/mkexports                  |  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
 #
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..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)


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Tarantool-patches] [PATCH 2/3] build: enable smtp in libCURL
  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 ` [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols Roman Khabibov via Tarantool-patches
@ 2021-03-19 14:13 ` Roman Khabibov via Tarantool-patches
  2021-04-01  0:52   ` Alexander Turenko via Tarantool-patches
  2021-03-19 14:13 ` [Tarantool-patches] [PATCH 3/3] build: install libCURL headers 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
  3 siblings, 1 reply; 15+ messages in thread
From: Roman Khabibov via Tarantool-patches @ 2021-03-19 14:13 UTC (permalink / raw)
  To: tarantool-patches; +Cc: alexander.turenko

Enable smtp protocol in bundled libCURL.
---
 cmake/BuildLibCURL.cmake         |  2 +-
 test/box-tap/curl-build.test.lua | 38 +++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake
index 5f8b15a63..313adfb97 100644
--- a/cmake/BuildLibCURL.cmake
+++ b/cmake/BuildLibCURL.cmake
@@ -124,6 +124,7 @@ macro(curl_build)
                 --enable-http-auth
                 --enable-mime
                 --enable-dateparse
+                --enable-smtp
 
                 ${DISABLED_DNS_OPT}
                 --disable-ftp
@@ -137,7 +138,6 @@ macro(curl_build)
                 --disable-pop3
                 --disable-imap
                 --disable-smb
-                --disable-smtp
                 --disable-gopher
                 --disable-manual
                 --disable-sspi
diff --git a/test/box-tap/curl-build.test.lua b/test/box-tap/curl-build.test.lua
index ab58efffa..e4ec49c19 100755
--- a/test/box-tap/curl-build.test.lua
+++ b/test/box-tap/curl-build.test.lua
@@ -4,10 +4,22 @@ 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 */
+        const char * const *protocols; /* protocols */
+    };
+    struct curl_version_info_data *curl_version_info(int age);
 ]])
 
 local test = tap.test('curl-symbols')
-test:plan(1)
+test:plan(2)
 
 local RTLD_DEFAULT
 -- See `man 3 dlsym`:
@@ -121,4 +133,28 @@ test:test('curl_symbols', function(t)
     end
 end)
 
+--
+-- Check if smtp protocol is enabled.
+--
+local function has_smtp()
+    local i = 0
+    -- curl_version_info_data.protocols is a null terminated array
+    -- of pointers to char.
+    -- See curl/lib/version.c:
+    --   static const char * const protocols[]
+    local info = ffi.C.curl_version_info(7)
+    local protocol = info.protocols[i]
+    while protocol ~= nil do
+        if ffi.string(protocol) == 'smtp' then
+            return true
+        end
+        i = i + 1
+        protocol = info.protocols[i]
+    end
+
+    return false
+end
+
+test:ok(has_smtp(), 'smtp protocol is supported')
+
 os.exit(test:check() and 0 or 1)
-- 
2.24.3 (Apple Git-128)


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Tarantool-patches] [PATCH 3/3] build: install libCURL headers
  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 ` [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols Roman Khabibov via Tarantool-patches
  2021-03-19 14:13 ` [Tarantool-patches] [PATCH 2/3] build: enable smtp in libCURL Roman Khabibov via Tarantool-patches
@ 2021-03-19 14:13 ` Roman Khabibov via Tarantool-patches
  2021-04-01  0:10   ` Alexander Turenko 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
  3 siblings, 1 reply; 15+ messages in thread
From: Roman Khabibov via Tarantool-patches @ 2021-03-19 14:13 UTC (permalink / raw)
  To: tarantool-patches; +Cc: alexander.turenko

Ship libCURL headers to system path "include/tarantool" in the
case of libCURL included as bundled library.
---
 CMakeLists.txt     | 7 +++++++
 rpm/tarantool.spec | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e2ddb503..263d455fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -347,6 +347,13 @@ else()
     find_package(CURL)
 endif()
 
+# Install headers.
+if (ENABLE_BUNDLED_LIBCURL)
+    install(DIRECTORY "${CURL_INCLUDE_DIRS}/curl"
+            DESTINATION ${MODULE_FULL_INCLUDEDIR}
+            FILES_MATCHING PATTERN "*.h")
+endif()
+
 #
 # Export libcurl symbols if the library is bundled.
 #
diff --git a/rpm/tarantool.spec b/rpm/tarantool.spec
index cbc97606b..12997f191 100644
--- a/rpm/tarantool.spec
+++ b/rpm/tarantool.spec
@@ -251,6 +251,15 @@ fi
 %{_includedir}/tarantool/luajit.h
 %{_includedir}/tarantool/lualib.h
 %{_includedir}/tarantool/module.h
+%{_includedir}/tarantool/curl/curl.h
+%{_includedir}/tarantool/curl/curlver.h
+%{_includedir}/tarantool/curl/easy.h
+%{_includedir}/tarantool/curl/mprintf.h
+%{_includedir}/tarantool/curl/multi.h
+%{_includedir}/tarantool/curl/stdcheaders.h
+%{_includedir}/tarantool/curl/system.h
+%{_includedir}/tarantool/curl/typecheck-gcc.h
+%{_includedir}/tarantool/curl/urlapi.h
 
 %changelog
 * Tue Sep 12 2017 Roman Tsisyk <roman@tarantool.org> 1.7.5.46-1
-- 
2.24.3 (Apple Git-128)


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols
  2021-03-19 14:13 ` [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols Roman Khabibov via Tarantool-patches
@ 2021-03-31 23:56   ` 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
  1 sibling, 1 reply; 15+ messages in thread
From: Alexander Turenko via Tarantool-patches @ 2021-03-31 23:56 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches

On Fri, Mar 19, 2021 at 05:13:06PM +0300, Roman Khabibov wrote:
> 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>.

The commit hash you reference is not reachable from the master branch.

Aside of this, some logic arrives from
47c19eeb4f67cb7257ce32542443c09410b6e752 ('build: don't re-export
libcurl.so/dylib symbols').

> 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

It is the part of extra/exports, so I would name it
extra/exports_libcurl.

I would also keep Yaroslav's comment at the start:

 | # The following list was obtained by parsing libcurl.a static library:
 | # nm libcurl.a | grep -oP 'T \K(curl_.+)$' | sort
 |
 | curl_easy_cleanup
 | curl_easy_duphandle
 | <...>

> diff --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

I would just pass one or two files (extra/exports,
extra/exports_libcurl) in $1: it'll be easier to read.

My diff (from 1.10):

 | diff --git a/extra/mkexports b/extra/mkexports
 | index 145e5b8ce..95c3f8eed 100755
 | --- a/extra/mkexports
 | +++ b/extra/mkexports
 | @@ -1,5 +1,5 @@
 |  #! /bin/sh
 | -# $1 - in  file
 | +# $1 - in file(s)
 |  # $2 - out file
 |  # $3 - os
 |  # $4 - export templates
 | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
 | index 1e840aab9..db771cce9 100644
 | --- a/src/CMakeLists.txt
 | +++ b/src/CMakeLists.txt
 | @@ -301,6 +301,13 @@ if(BUILD_STATIC)
 |      endif()
 |  endif()
 |  
 | +set(exports_file_sources ${CMAKE_SOURCE_DIR}/extra/exports)
 | +if (EXPORT_LIBCURL_SYMBOLS)
 | +    set(exports_file_sources ${exports_file_sources}
 | +        ${CMAKE_SOURCE_DIR}/extra/exports_libcurl)
 | +endif()
 | +string(REPLACE ";" " " exports_file_sources "${exports_file_sources}")
 | +
 |  # Exports syntax is toolchain-dependent, preprocessing is necessary
 |  set(exports_file ${CMAKE_BINARY_DIR}/extra/exports.${CMAKE_SYSTEM_NAME})
 |  add_custom_target(preprocess_exports
 | @@ -309,7 +316,7 @@ add_custom_command(
 |      OUTPUT  ${exports_file}
 |      DEPENDS ${CMAKE_SOURCE_DIR}/extra/exports
 |      COMMAND ${CMAKE_SOURCE_DIR}/extra/mkexports
 | -            ${CMAKE_SOURCE_DIR}/extra/exports
 | +            ${exports_file_sources}
 |              ${exports_file} ${CMAKE_SYSTEM_NAME}
 |              ${EXPORT_LIST}
 |  )

----

Just for the record: I also tried another implementation variant:

 | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
 | index 1e840aab9..6804ba301 100644
 | --- a/src/CMakeLists.txt
 | +++ b/src/CMakeLists.txt
 | @@ -284,8 +284,9 @@ if(BUILD_STATIC)
 |              list(APPEND EXPORT_LIST ${SYMBOLS_LIB})
 |              # set variable to allow rescan (CMake depended)
 |              set(SYMBOLS_LIB "SYMBOLS_LIB-NOTFOUND")
 | -        elseif (${libstatic} STREQUAL bundled-libcurl OR
 | -                ${libstatic} STREQUAL bundled-ares)
 | +        elseif (${libstatic} STREQUAL bundled-libcurl)
 | +            # Handled below.
 | +        elseif (${libstatic} STREQUAL bundled-ares)
 |              message("We don't need to export symbols from statically linked ${libstatic}, skipped")
 |          else()
 |              message(WARNING "${libstatic} should be a static")
 | @@ -301,10 +302,24 @@ if(BUILD_STATIC)
 |      endif()
 |  endif()
 |  
 | +# Expose libcurl symbols.
 | +if(ENABLE_BUNDLED_LIBCURL OR BUILD_STATIC)
 | +    set(reexport_libraries ${reexport_libraries} ${CURL_LIBRARIES})
 | +
 | +    if (ENABLE_BUNDLED_LIBCURL)
 | +        get_target_property(libstatic bundled-libcurl IMPORTED_LOCATION)
 | +        string(REGEX REPLACE "libcurl.a" "libcurl.so" libdynamic ${libstatic})
 | +    else()
 | +        find_library(libdynamic NAMES curl)
 | +    endif()
 | +
 | +    set(EXPORT_LIST ${EXPORT_LIST} ${libdynamic})
 | +endif()
 | +
 |  # Exports syntax is toolchain-dependent, preprocessing is necessary
 |  set(exports_file ${CMAKE_BINARY_DIR}/extra/exports.${CMAKE_SYSTEM_NAME})
 |  add_custom_target(preprocess_exports
 | -                  DEPENDS ${exports_file})
 | +                  DEPENDS ${exports_file} build_bundled_libs)
 |  add_custom_command(
 |      OUTPUT  ${exports_file}
 |      DEPENDS ${CMAKE_SOURCE_DIR}/extra/exports

(At least it works for libcurl bundling, but I didn't verified it with static
build.)

However explicit listing of public libcurl symbols looks easier to understand
and in tune with master.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols
  2021-03-19 14:13 ` [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols Roman Khabibov via Tarantool-patches
  2021-03-31 23:56   ` Alexander Turenko via Tarantool-patches
@ 2021-04-01  0:01   ` Alexander Turenko via Tarantool-patches
  1 sibling, 0 replies; 15+ messages in thread
From: Alexander Turenko via Tarantool-patches @ 2021-04-01  0:01 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches

> 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

Can we just copy test/box-tap/gh-5223-curl-exports.test.lua from
29ec628918bd7279de08e47becc070420775c2eb ('Ensure all curl symbols are
exported') without changes?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Tarantool-patches] [PATCH 3/3] build: install libCURL headers
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Turenko via Tarantool-patches @ 2021-04-01  0:10 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches

On Fri, Mar 19, 2021 at 05:13:08PM +0300, Roman Khabibov wrote:
> Ship libCURL headers to system path "include/tarantool" in the
> case of libCURL included as bundled library.
> ---

Is it quite straigtforward backport of [1], so it is okay too after the
proposed fixes [2].

Only one note for the backport: it seems, a changelog entry was
forgotten here.

[1]: https://lists.tarantool.org/pipermail/tarantool-patches/2021-March/022798.html
[2]: https://lists.tarantool.org/pipermail/tarantool-patches/2021-March/023178.html

WBR, Alexander Turenko.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/3] build: enable smtp in libCURL
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Turenko via Tarantool-patches @ 2021-04-01  0:52 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches

On Fri, Mar 19, 2021 at 05:13:07PM +0300, Roman Khabibov wrote:
> Enable smtp protocol in bundled libCURL.
> ---
>  cmake/BuildLibCURL.cmake         |  2 +-
>  test/box-tap/curl-build.test.lua | 38 +++++++++++++++++++++++++++++++-
>  2 files changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake
> index 5f8b15a63..313adfb97 100644
> --- a/cmake/BuildLibCURL.cmake
> +++ b/cmake/BuildLibCURL.cmake
> @@ -124,6 +124,7 @@ macro(curl_build)
>                  --enable-http-auth
>                  --enable-mime
>                  --enable-dateparse
> +                --enable-smtp
>  
>                  ${DISABLED_DNS_OPT}
>                  --disable-ftp
> @@ -137,7 +138,6 @@ macro(curl_build)
>                  --disable-pop3
>                  --disable-imap
>                  --disable-smb
> -                --disable-smtp
>                  --disable-gopher
>                  --disable-manual
>                  --disable-sspi

It seems, it is quite straightforward backport of [1], so it is okay
after comments from the original patch ([2]).

Don't miss changelog entries on 1.10.

[1]: https://lists.tarantool.org/pipermail/tarantool-patches/2021-March/022797.html
[2]: https://lists.tarantool.org/pipermail/tarantool-patches/2021-March/023177.html

I performed tests 2 and 3 from [2] and the result looks the same. It
seems, we don't enable or disable something unintentionally here as
well.

WBR, Alexander Turenko.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/3] build: enable smtp in libCURL
  2021-04-01  0:52   ` Alexander Turenko via Tarantool-patches
@ 2021-04-09 19:54     ` Roman Khabibov via Tarantool-patches
  0 siblings, 0 replies; 15+ messages in thread
From: Roman Khabibov via Tarantool-patches @ 2021-04-09 19:54 UTC (permalink / raw)
  To: Alexander Turenko, Leonid Vasiliev; +Cc: tarantool-patches



> On Apr 1, 2021, at 03:52, Alexander Turenko <alexander.turenko@tarantool.org> wrote:
> 
> On Fri, Mar 19, 2021 at 05:13:07PM +0300, Roman Khabibov wrote:
>> Enable smtp protocol in bundled libCURL.
>> ---
>> cmake/BuildLibCURL.cmake         |  2 +-
>> test/box-tap/curl-build.test.lua | 38 +++++++++++++++++++++++++++++++-
>> 2 files changed, 38 insertions(+), 2 deletions(-)
>> 
>> diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake
>> index 5f8b15a63..313adfb97 100644
>> --- a/cmake/BuildLibCURL.cmake
>> +++ b/cmake/BuildLibCURL.cmake
>> @@ -124,6 +124,7 @@ macro(curl_build)
>>                 --enable-http-auth
>>                 --enable-mime
>>                 --enable-dateparse
>> +                --enable-smtp
>> 
>>                 ${DISABLED_DNS_OPT}
>>                 --disable-ftp
>> @@ -137,7 +138,6 @@ macro(curl_build)
>>                 --disable-pop3
>>                 --disable-imap
>>                 --disable-smb
>> -                --disable-smtp
>>                 --disable-gopher
>>                 --disable-manual
>>                 --disable-sspi
> 
> It seems, it is quite straightforward backport of [1], so it is okay
> after comments from the original patch ([2]).
> 
> Don't miss changelog entries on 1.10.
> 
> [1]: https://lists.tarantool.org/pipermail/tarantool-patches/2021-March/022797.html
> [2]: https://lists.tarantool.org/pipermail/tarantool-patches/2021-March/023177.html
> 
> I performed tests 2 and 3 from [2] and the result looks the same. It
> seems, we don't enable or disable something unintentionally here as
> well.
> 
> WBR, Alexander Turenko.

commit 41fb2d2ae39007ee47d90c49de77120c337ee267
Author: Roman Khabibov <roman.habibov@tarantool.org>
Date:   Mon Jan 18 21:48:35 2021 +0300

    build: enable smtp in libcurl
    
    Enable smtp protocol in bundled libcurl.
    
    Part of #4559

diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake
index 5f8b15a63..313adfb97 100644
--- a/cmake/BuildLibCURL.cmake
+++ b/cmake/BuildLibCURL.cmake
@@ -124,6 +124,7 @@ macro(curl_build)
                 --enable-http-auth
                 --enable-mime
                 --enable-dateparse
+                --enable-smtp
 
                 ${DISABLED_DNS_OPT}
                 --disable-ftp
@@ -137,7 +138,6 @@ macro(curl_build)
                 --disable-pop3
                 --disable-imap
                 --disable-smb
-                --disable-smtp
                 --disable-gopher
                 --disable-manual
                 --disable-sspi
diff --git a/test/box-tap/curl-build.test.lua b/test/box-tap/curl-build.test.lua
index 300d60b07..640d5d143 100755
--- a/test/box-tap/curl-build.test.lua
+++ b/test/box-tap/curl-build.test.lua
@@ -56,7 +56,7 @@ ffi.cdef([[
 
 local info = ffi.C.curl_version_info(7)
 local test = tap.test('curl-features')
-test:plan(3)
+test:plan(5)
 
 if test:ok(info.ssl_version ~= nil, 'Curl built with SSL support') then
     test:diag('ssl_version: ' .. ffi.string(info.ssl_version))
@@ -174,4 +174,29 @@ test:test('curl_symbols', function(t)
     end
 end)
 
+local function has_protocol(protocol_str)
+    local i = 0
+    -- curl_version_info_data.protocols is a null terminated array
+    -- of pointers to char.
+    -- See curl/lib/version.c:
+    --   static const char * const protocols[]
+    local info = ffi.C.curl_version_info(7)
+    local protocol = info.protocols[i]
+    while protocol ~= nil do
+        if ffi.string(protocol) == protocol_str then
+            return true
+        end
+        i = i + 1
+        protocol = info.protocols[i]
+    end
+
+    return false
+end
+
+--
+-- gh-4559: check if smtp and smtps protocols are enabled.
+--
+test:ok(has_protocol('smtp'), 'smtp protocol is supported')
+test:ok(has_protocol('smtps'), 'smtps protocol is supported')
+
 os.exit(test:check() and 0 or 1)


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols
  2021-03-31 23:56   ` Alexander Turenko via Tarantool-patches
@ 2021-04-09 19:54     ` Roman Khabibov via Tarantool-patches
  0 siblings, 0 replies; 15+ messages in thread
From: Roman Khabibov via Tarantool-patches @ 2021-04-09 19:54 UTC (permalink / raw)
  To: Alexander Turenko, Leonid Vasiliev; +Cc: tarantool-patches



> On Apr 1, 2021, at 02:56, Alexander Turenko <alexander.turenko@tarantool.org> wrote:
> 
> On Fri, Mar 19, 2021 at 05:13:06PM +0300, Roman Khabibov wrote:
>> 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>.
> 
> The commit hash you reference is not reachable from the master branch.
Fixed.

> Aside of this, some logic arrives from
> 47c19eeb4f67cb7257ce32542443c09410b6e752 ('build: don't re-export
> libcurl.so/dylib symbols').
> 
>> 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
> 
> It is the part of extra/exports, so I would name it
> extra/exports_libcurl.
> 
> I would also keep Yaroslav's comment at the start:
> 
> | # The following list was obtained by parsing libcurl.a static library:
> | # nm libcurl.a | grep -oP 'T \K(curl_.+)$' | sort
> |
> | curl_easy_cleanup
> | curl_easy_duphandle
> | <...>
diff --git a/extra/exports_libcurl b/extra/exports_libcurl
new file mode 100755
index 000000000..d9f420d03
--- /dev/null
+++ b/extra/exports_libcurl
@@ -0,0 +1,84 @@
+# The following list was obtained by parsing libcurl.a static
+# library: nm libcurl.a | grep -oP 'T \K(curl_.+)$' | sort
+

>> diff --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
> 
> I would just pass one or two files (extra/exports,
> extra/exports_libcurl) in $1: it'll be easier to read.
> 
> My diff (from 1.10):
> 
> | diff --git a/extra/mkexports b/extra/mkexports
> | index 145e5b8ce..95c3f8eed 100755
> | --- a/extra/mkexports
> | +++ b/extra/mkexports
> | @@ -1,5 +1,5 @@
> |  #! /bin/sh
> | -# $1 - in  file
> | +# $1 - in file(s)
> |  # $2 - out file
> |  # $3 - os
> |  # $4 - export templates
> | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
> | index 1e840aab9..db771cce9 100644
> | --- a/src/CMakeLists.txt
> | +++ b/src/CMakeLists.txt
> | @@ -301,6 +301,13 @@ if(BUILD_STATIC)
> |      endif()
> |  endif()
> |  
> | +set(exports_file_sources ${CMAKE_SOURCE_DIR}/extra/exports)
> | +if (EXPORT_LIBCURL_SYMBOLS)
> | +    set(exports_file_sources ${exports_file_sources}
> | +        ${CMAKE_SOURCE_DIR}/extra/exports_libcurl)
> | +endif()
> | +string(REPLACE ";" " " exports_file_sources "${exports_file_sources}")
> | +
> |  # Exports syntax is toolchain-dependent, preprocessing is necessary
> |  set(exports_file ${CMAKE_BINARY_DIR}/extra/exports.${CMAKE_SYSTEM_NAME})
> |  add_custom_target(preprocess_exports
> | @@ -309,7 +316,7 @@ add_custom_command(
> |      OUTPUT  ${exports_file}
> |      DEPENDS ${CMAKE_SOURCE_DIR}/extra/exports
> |      COMMAND ${CMAKE_SOURCE_DIR}/extra/mkexports
> | -            ${CMAKE_SOURCE_DIR}/extra/exports
> | +            ${exports_file_sources}
> |              ${exports_file} ${CMAKE_SYSTEM_NAME}
> |              ${EXPORT_LIST}
> |  )
I choose it.

> ----
> 
> Just for the record: I also tried another implementation variant:
> 
> | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
> | index 1e840aab9..6804ba301 100644
> | --- a/src/CMakeLists.txt
> | +++ b/src/CMakeLists.txt
> | @@ -284,8 +284,9 @@ if(BUILD_STATIC)
> |              list(APPEND EXPORT_LIST ${SYMBOLS_LIB})
> |              # set variable to allow rescan (CMake depended)
> |              set(SYMBOLS_LIB "SYMBOLS_LIB-NOTFOUND")
> | -        elseif (${libstatic} STREQUAL bundled-libcurl OR
> | -                ${libstatic} STREQUAL bundled-ares)
> | +        elseif (${libstatic} STREQUAL bundled-libcurl)
> | +            # Handled below.
> | +        elseif (${libstatic} STREQUAL bundled-ares)
> |              message("We don't need to export symbols from statically linked ${libstatic}, skipped")
> |          else()
> |              message(WARNING "${libstatic} should be a static")
> | @@ -301,10 +302,24 @@ if(BUILD_STATIC)
> |      endif()
> |  endif()
> |  
> | +# Expose libcurl symbols.
> | +if(ENABLE_BUNDLED_LIBCURL OR BUILD_STATIC)
> | +    set(reexport_libraries ${reexport_libraries} ${CURL_LIBRARIES})
> | +
> | +    if (ENABLE_BUNDLED_LIBCURL)
> | +        get_target_property(libstatic bundled-libcurl IMPORTED_LOCATION)
> | +        string(REGEX REPLACE "libcurl.a" "libcurl.so" libdynamic ${libstatic})
> | +    else()
> | +        find_library(libdynamic NAMES curl)
> | +    endif()
> | +
> | +    set(EXPORT_LIST ${EXPORT_LIST} ${libdynamic})
> | +endif()
> | +
> |  # Exports syntax is toolchain-dependent, preprocessing is necessary
> |  set(exports_file ${CMAKE_BINARY_DIR}/extra/exports.${CMAKE_SYSTEM_NAME})
> |  add_custom_target(preprocess_exports
> | -                  DEPENDS ${exports_file})
> | +                  DEPENDS ${exports_file} build_bundled_libs)
> |  add_custom_command(
> |      OUTPUT  ${exports_file}
> |      DEPENDS ${CMAKE_SOURCE_DIR}/extra/exports
> 
> (At least it works for libcurl bundling, but I didn't verified it with static
> build.)
> 
> However explicit listing of public libcurl symbols looks easier to understand
> and in tune with master.

commit aee16d72d6740f2b5b18c034ab0ec0f0379745f3
Author: Roman Khabibov <roman.habibov@tarantool.org>
Date:   Fri Jan 15 01:07:55 2021 +0300

    build: export libcurl symbols
    
    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 29ec628
    performed by Yaroslav Dynnikov <yaroslav.dynnikov@gmail.com>.

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
 #
diff --git a/extra/exports_libcurl b/extra/exports_libcurl
new file mode 100755
index 000000000..d9f420d03
--- /dev/null
+++ b/extra/exports_libcurl
@@ -0,0 +1,84 @@
+# The following list was obtained by parsing libcurl.a static
+# library: nm libcurl.a | grep -oP 'T \K(curl_.+)$' | sort
+
+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..15bd8e727 100755
--- a/extra/mkexports
+++ b/extra/mkexports
@@ -1,6 +1,6 @@
 #! /bin/sh
 # $1 - in  file
-# $2 - out file
+# $2 - out file(s)
 # $3 - os
 # $4 - export templates
 if [ "x$3x" = xDarwinx ]; then
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 04289af3d..c2d3e7fcd 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}
 )
@@ -300,6 +299,13 @@ if(BUILD_STATIC)
     endif()
 endif()
 
+set(exports_file_sources ${CMAKE_SOURCE_DIR}/extra/exports)
+if (EXPORT_LIBCURL_SYMBOLS)
+    set(exports_file_sources ${exports_file_sources}
+        ${CMAKE_SOURCE_DIR}/extra/exports_libcurl)
+endif()
+string(REPLACE ";" " " exports_file_sources "${exports_file_sources}")
+
 # Exports syntax is toolchain-dependent, preprocessing is necessary
 set(exports_file ${CMAKE_BINARY_DIR}/extra/exports.${CMAKE_SYSTEM_NAME})
 add_custom_target(preprocess_exports
@@ -308,7 +314,7 @@ add_custom_command(
     OUTPUT  ${exports_file}
     DEPENDS ${CMAKE_SOURCE_DIR}/extra/exports
     COMMAND ${CMAKE_SOURCE_DIR}/extra/mkexports
-            ${CMAKE_SOURCE_DIR}/extra/exports
+            ${exports_file_sources}
             ${exports_file} ${CMAKE_SYSTEM_NAME}
             ${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..300d60b07
--- /dev/null
+++ b/test/box-tap/curl-build.test.lua
@@ -0,0 +1,177 @@
+#!/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 */
+        const char * const *protocols; /* protocols */
+
+        /* when 'age' is CURLVERSION_SECOND or higher, the members below exist */
+        const char *ares;         /* human readable string */
+        int ares_num;             /* number */
+
+        /* when 'age' is CURLVERSION_THIRD or higher, the members below exist */
+        const char *libidn;       /* human readable string */
+
+        /* when 'age' is CURLVERSION_FOURTH or higher (>= 7.16.1), the members
+           below exist */
+        int iconv_ver_num;       /* '_libiconv_version' if iconv support enabled */
+
+        const char *libssh_version; /* human readable string */
+
+        /* when 'age' is CURLVERSION_FIFTH or higher (>= 7.57.0), the members
+           below exist */
+        unsigned int brotli_ver_num; /* Numeric Brotli version
+                                        (MAJOR << 24) | (MINOR << 12) | PATCH */
+        const char *brotli_version; /* human readable string. */
+
+        /* when 'age' is CURLVERSION_SIXTH or higher (>= 7.66.0), the members
+           below exist */
+        unsigned int nghttp2_ver_num; /* Numeric nghttp2 version
+                                         (MAJOR << 16) | (MINOR << 8) | PATCH */
+        const char *nghttp2_version; /* human readable string. */
+
+        const char *quic_version;    /* human readable quic (+ HTTP/3) library +
+                                        version or NULL */
+
+        /* when 'age' is CURLVERSION_SEVENTH or higher (>= 7.70.0), the members
+           below exist */
+        const char *cainfo;          /* the built-in default CURLOPT_CAINFO, might
+                                        be NULL */
+        const char *capath;          /* the built-in default CURLOPT_CAPATH, might
+                                        be NULL */
+    };
+
+    struct curl_version_info_data *curl_version_info(int age);
+]])
+
+local info = ffi.C.curl_version_info(7)
+local test = tap.test('curl-features')
+test:plan(3)
+
+if test:ok(info.ssl_version ~= nil, 'Curl built with SSL support') then
+    test:diag('ssl_version: ' .. ffi.string(info.ssl_version))
+end
+if test:ok(info.libz_version ~= nil, 'Curl built with LIBZ') then
+    test:diag('libz_version: ' .. ffi.string(info.libz_version))
+end
+
+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)


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Tarantool-patches] [PATCH 3/3] build: install libCURL headers
  2021-04-01  0:10   ` Alexander Turenko via Tarantool-patches
@ 2021-04-09 19:54     ` Roman Khabibov via Tarantool-patches
  0 siblings, 0 replies; 15+ messages in thread
From: Roman Khabibov via Tarantool-patches @ 2021-04-09 19:54 UTC (permalink / raw)
  To: Alexander Turenko, Leonid Vasiliev; +Cc: tarantool-patches



> On Apr 1, 2021, at 03:10, Alexander Turenko <alexander.turenko@tarantool.org> wrote:
> 
> On Fri, Mar 19, 2021 at 05:13:08PM +0300, Roman Khabibov wrote:
>> Ship libCURL headers to system path "include/tarantool" in the
>> case of libCURL included as bundled library.
>> ---
> 
> Is it quite straigtforward backport of [1], so it is okay too after the
> proposed fixes [2].
> 
> Only one note for the backport: it seems, a changelog entry was
> forgotten here.
> 
> [1]: https://lists.tarantool.org/pipermail/tarantool-patches/2021-March/022798.html
> [2]: https://lists.tarantool.org/pipermail/tarantool-patches/2021-March/023178.html
> 
> WBR, Alexander Turenko.

commit 3fd88650bd4bbe6d0bbbfa5fbedd38dc5d9f1578
Author: Roman Khabibov <roman.habibov@tarantool.org>
Date:   Sun Dec 20 13:08:40 2020 +0500

    build: install libcurl headers
    
    Ship libcurl headers to system path "${PREFIX}/include/tarantool"
    in the case of libcurl included as bundled library.
    
    Closes #4559

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e2ddb503..263d455fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -347,6 +347,13 @@ else()
     find_package(CURL)
 endif()
 
+# Install headers.
+if (ENABLE_BUNDLED_LIBCURL)
+    install(DIRECTORY "${CURL_INCLUDE_DIRS}/curl"
+            DESTINATION ${MODULE_FULL_INCLUDEDIR}
+            FILES_MATCHING PATTERN "*.h")
+endif()
+
 #
 # Export libcurl symbols if the library is bundled.
 #
diff --git a/rpm/tarantool.spec b/rpm/tarantool.spec
index cbc97606b..fa521e47b 100644
--- a/rpm/tarantool.spec
+++ b/rpm/tarantool.spec
@@ -251,6 +251,7 @@ fi
 %{_includedir}/tarantool/luajit.h
 %{_includedir}/tarantool/lualib.h
 %{_includedir}/tarantool/module.h
+%{_includedir}/tarantool/curl
 
 %changelog
 * Tue Sep 12 2017 Roman Tsisyk <roman@tarantool.org> 1.7.5.46-1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Tarantool-patches] [PATCH 0/3] Export curl symbols, enable smtp and install headers
  2021-03-19 14:13 [Tarantool-patches] [PATCH 0/3] Export curl symbols, enable smtp and install headers Roman Khabibov via Tarantool-patches
                   ` (2 preceding siblings ...)
  2021-03-19 14:13 ` [Tarantool-patches] [PATCH 3/3] build: install libCURL headers Roman Khabibov via Tarantool-patches
@ 2021-04-13 13:14 ` Leonid Vasiliev via Tarantool-patches
  2021-04-14 17:52   ` Roman Khabibov via Tarantool-patches
  3 siblings, 1 reply; 15+ messages in thread
From: Leonid Vasiliev via Tarantool-patches @ 2021-04-13 13:14 UTC (permalink / raw)
  To: Roman Khabibov, tarantool-patches; +Cc: alexander.turenko

Hi! Thank you for the patchset.
Generally LGTM.
See several commits below:
1) Add changelogs.
2) Have you checked the patch on some deb and rpm based distributions?


On 3/19/21 5:13 PM, Roman Khabibov via Tarantool-patches wrote:
> The patchset is for 1.10 only.
> 
> Issue: https://github.com/tarantool/smtp/issues/24
> Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/curl-smtp_1_10
> 
> Roman Khabibov (3):
>    build: export libCURL symbols
>    build: enable smtp in libCURL
>    build: install libCURL headers
> 
>   CMakeLists.txt                   |  17 ++++
>   cmake/BuildLibCURL.cmake         |   2 +-
>   extra/curl_symbols               |  81 ++++++++++++++++
>   extra/mkexports                  |  14 ++-
>   rpm/tarantool.spec               |   9 ++
>   src/CMakeLists.txt               |   5 +-
>   test/box-tap/curl-build.test.lua | 160 +++++++++++++++++++++++++++++++
>   7 files changed, 282 insertions(+), 6 deletions(-)
>   create mode 100755 extra/curl_symbols
>   create mode 100755 test/box-tap/curl-build.test.lua
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Tarantool-patches] [PATCH 0/3] Export curl symbols, enable smtp and install headers
  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
  0 siblings, 0 replies; 15+ messages in thread
From: Roman Khabibov via Tarantool-patches @ 2021-04-14 17:52 UTC (permalink / raw)
  To: Leonid Vasiliev; +Cc: tarantool-patches, Alexander Turenko

Hi!

> On Apr 13, 2021, at 16:14, Leonid Vasiliev <lvasiliev@tarantool.org> wrote:
> 
> Hi! Thank you for the patchset.
> Generally LGTM.
> See several commits below:
> 1) Add changelogs.
> 2) Have you checked the patch on some deb and rpm based distributions?
> 
> 
> On 3/19/21 5:13 PM, Roman Khabibov via Tarantool-patches wrote:
>> The patchset is for 1.10 only.
>> Issue: https://github.com/tarantool/smtp/issues/24
>> Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/curl-smtp_1_10
>> Roman Khabibov (3):
>>   build: export libCURL symbols
>>   build: enable smtp in libCURL
>>   build: install libCURL headers
>>  CMakeLists.txt                   |  17 ++++
>>  cmake/BuildLibCURL.cmake         |   2 +-
>>  extra/curl_symbols               |  81 ++++++++++++++++
>>  extra/mkexports                  |  14 ++-
>>  rpm/tarantool.spec               |   9 ++
>>  src/CMakeLists.txt               |   5 +-
>>  test/box-tap/curl-build.test.lua | 160 +++++++++++++++++++++++++++++++
>>  7 files changed, 282 insertions(+), 6 deletions(-)
>>  create mode 100755 extra/curl_symbols
>>  create mode 100755 test/box-tap/curl-build.test.lua
All is done. On two branches.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Tarantool-patches]  [PATCH 1/3] build: export libCURL symbols
@ 2021-03-18 11:33 Бабин Олег via Tarantool-patches
  0 siblings, 0 replies; 15+ messages in thread
From: Бабин Олег via Tarantool-patches @ 2021-03-18 11:33 UTC (permalink / raw)
  To: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 9282 bytes --]


Hi! Thanks for your patch. This patch was followed [1], so maybe it's better to include it in this patchset.
    [1]  https://github.com/tarantool/tarantool/commit/0bb2c945aaef2830b7951eaaa0c4b02a08b80443
On 18.03.2021 11:51, Roman Khabibov via Tarantool-patches wrote:
>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 <yaroslav.dynnikov@gmail.com>.
>---
> 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)
>
 

[-- Attachment #2: Type: text/html, Size: 9639 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols
  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 ` Roman Khabibov via Tarantool-patches
  0 siblings, 0 replies; 15+ messages in thread
From: Roman Khabibov via Tarantool-patches @ 2021-03-18  8:51 UTC (permalink / raw)
  To: tarantool-patches; +Cc: alexander.turenko

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 <yaroslav.dynnikov@gmail.com>.
---
 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)


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-04-14 17:52 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [Tarantool-patches] [PATCH 1/3] build: export libCURL symbols Roman Khabibov via Tarantool-patches
2021-03-31 23:56   ` 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

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