Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Fix openssl static linking error #2369

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ option(ENABLE_CODE_COVERAGE "Enable code coverage reporting" OFF)
option(ENABLE_MONOTONIC_CLOCK "Enforced clock_gettime with monotonic clock on GC CV" ${ENABLE_MONOTONIC_CLOCK_DEFAULT})
option(ENABLE_STDCXX_SYNC "Use C++11 chrono and threads for timing instead of pthreads" ${ENABLE_STDCXX_SYNC_DEFAULT})
option(USE_OPENSSL_PC "Use pkg-config to find OpenSSL libraries" ON)
option(OPENSSL_USE_STATIC_LIBS "Use static libraries of openssl, affects `USE_OPENSSL_PC` found openssl or on Windows" OFF)
wangyoucao577 marked this conversation as resolved.
Show resolved Hide resolved
option(USE_BUSY_WAITING "Enable more accurate sending times at a cost of potentially higher CPU load" OFF)
option(USE_GNUSTL "Get c++ library/headers from the gnustl.pc" OFF)
option(ENABLE_SOCK_CLOEXEC "Enable setting SOCK_CLOEXEC on a socket" ON)
Expand Down Expand Up @@ -345,6 +346,10 @@ if (ENABLE_ENCRYPTION)
# fall back to find_package method otherwise
if (USE_OPENSSL_PC)
pkg_check_modules(SSL ${SSL_REQUIRED_MODULES})
if (OPENSSL_USE_STATIC_LIBS)
# use `pkg-config --static xxx` found libs
set(SSL_LIBRARIES ${SSL_STATIC_LIBRARIES})
endif()
endif()
if (SSL_FOUND)
# We have some cases when pkg-config is improperly configured
Expand Down
1 change: 1 addition & 0 deletions configure-data.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ set cmake_options {
enable-thread-check "Enable #include <threadcheck.h> that implements THREAD_* macros"
enable-stdc++-sync "Use standard C++11 chrono/threads instead of pthread wrapper (default: OFF, on Windows: ON)"
use-openssl-pc "Use pkg-config to find OpenSSL libraries (default: ON)"
openssl-use-static-libs "Use static libraries of openssl, affects `USE_OPENSSL_PC` found openssl or on Windows (default: OFF)"
wangyoucao577 marked this conversation as resolved.
Show resolved Hide resolved
use-busy-waiting "Enable more accurate sending times at a cost of potentially higher CPU load (default: OFF)"
use-gnustl "Get c++ library/headers from the gnustl.pc"
enable-sock-cloexec "Enable setting SOCK_CLOEXEC on a socket (default: ON)"
Expand Down
5 changes: 5 additions & 0 deletions docs/build/build-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Option details are given further below.
| [`USE_ENCLIB`](#use_enclib) | 1.3.3 | `STRING` | openssl | Encryption library to be used (`openssl`, `gnutls`, `mbedtls`). |
| [`USE_GNUSTL`](#use_gnustl) | 1.3.4 | `BOOL` | OFF | Use `pkg-config` with the `gnustl` package name to extract the header and library path for the C++ standard library. |
| [`USE_OPENSSL_PC`](#use_openssl_pc) | 1.3.0 | `BOOL` | ON | Use `pkg-config` to find OpenSSL libraries. |
| [`OPENSSL_USE_STATIC_LIBS`](#openssl_use_static_libs) | 1.5.0 | `BOOL` | OFF | Use static libraries of openssl, affects `USE_OPENSSL_PC` found openssl or on Windows. |
wangyoucao577 marked this conversation as resolved.
Show resolved Hide resolved
| [`USE_STATIC_LIBSTDCXX`](#use_static_libstdcxx) | 1.2.0 | `BOOL` | OFF | Enforces linking the SRT library against the static libstdc++ library. |
| [`WITH_COMPILER_PREFIX`](#with_compiler_prefix) | 1.3.0 | `STRING` | OFF | Sets C/C++ toolchains as `<prefix><c-compiler>` and `<prefix><c++-compiler>`, overriding the default compiler. |
| [`WITH_COMPILER_TYPE`](#with_compiler_type) | 1.3.0 | `STRING` | OFF | Sets the compiler type to be used (values: gcc, cc, clang, etc.). |
Expand Down Expand Up @@ -551,6 +552,10 @@ built-in one).
When ON, uses `pkg-config` to find OpenSSL libraries. You can turn this OFF to
force `cmake` to find OpenSSL by its own preferred method.

### OPENSSL_USE_STATIC_LIBS
**`--openssl-use-static-libs`** (default: OFF)

When ON, static linking of openssl will be used, affects the openssl found by `pkg-config`(`-DUSE_OPENSSL_PC=ON`) or on Windows.
wangyoucao577 marked this conversation as resolved.
Show resolved Hide resolved

#### USE_STATIC_LIBSTDCXX
**`--use-static-libstdc++`** (default: OFF)
Expand Down
1 change: 1 addition & 0 deletions scripts/ShowProjectConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ function(ShowProjectConfig)
" ENABLE_MONOTONIC_CLOCK: ${ENABLE_MONOTONIC_CLOCK}\n"
" ENABLE_STDCXX_SYNC: ${ENABLE_STDCXX_SYNC}\n"
" USE_OPENSSL_PC: ${USE_OPENSSL_PC}\n"
" OPENSSL_USE_STATIC_LIBS: ${OPENSSL_USE_STATIC_LIBS}\n"
" USE_BUSY_WAITING: ${USE_BUSY_WAITING}\n"
" USE_GNUSTL: ${USE_GNUSTL}\n"
" ENABLE_SOCK_CLOEXEC: ${ENABLE_SOCK_CLOEXEC}\n"
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-android/mksrt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ done

cd $SRC_DIR
./configure --use-enclib=$ENC_LIB \
--use-openssl-pc=OFF --OPENSSL_USE_STATIC_LIBS=TRUE \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergeiignatov Could you please verify this change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, merging as is. We can have a follow-up fix later if needed. At least Android CI build is passing.

--use-openssl-pc=OFF \
--OPENSSL_INCLUDE_DIR=$INSTALL_DIR/include \
--OPENSSL_CRYPTO_LIBRARY=$INSTALL_DIR/lib/libcrypto.a --OPENSSL_SSL_LIBRARY=$INSTALL_DIR/lib/libssl.a \
--STATIC_MBEDTLS=FALSE \
Expand Down