Skip to content

Commit 0de92b0

Browse files
Fix the OpenSSL 3.x symbols not found on macOS build (#145)
### Motivation Recently after the runner image was upgraded, the macOS build failed with `symbol not found in flat namespace (_EVP_PKEY_get_bn_param)`. See https://github.com/apache/pulsar-client-python/actions/runs/5805986979/job/15740588663?pr=134 There are actually two issues. One is that when building the C++ client on macOS, `/usr/local/opt/openssl/` will be firstly searched if `OPENSSL_ROOT_DIR` is not defined. https://github.com/apache/pulsar-client-cpp/blob/1e7d259bb94379ef6e4618fdac283912d0be6861/CMakeLists.txt#L136 It should be fixed at the C++ client side but we can also have a workaround here by defining the `OPENSSL_ROOT_DIR` variable. The other is that when building the libcurl, the headers from `/usr/local/include/openssl/` were included, see the logs: ``` /usr/local/include/openssl/macros.h:193:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0' # define OSSL_DEPRECATEDIN_3_0 OSSL_DEPRECATED(3.0) ``` It's a strange error because we have already configured the `--with-ssl` option to specify the OpenSSL directory. I tried adding `-I/path/to/my/openssl` to the `CFLAGS` env variable but it didn't work. ### Modifications To resolve the 1st issue, specifying `OPENSSL_ROOT_DIR` to the `DEPS_PREFIX` path when building the C++ client. To resolve the 2nd issue, since I cannot find an elegant way to do that, I just copied the OpenSSL headers from the dependency header directory to the libcurl include directory.
1 parent 4c28ed5 commit 0de92b0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pkg/mac/build-dependencies.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ if [ ! -f curl-${CURL_VERSION}/.done ]; then
194194
CURL_VERSION_=${CURL_VERSION//./_}
195195
download_dependency $ROOT_DIR/dependencies.yaml curl
196196
pushd curl-${CURL_VERSION}
197-
CFLAGS="-fPIC -arch arm64 -arch x86_64 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
197+
# Force the compiler to find the OpenSSL headers instead of the headers in the system path like /usr/local/include/openssl.
198+
cp -rf $PREFIX/include/openssl include/
199+
CFLAGS="-I$PREFIX/include -fPIC -arch arm64 -arch x86_64 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
198200
./configure --with-ssl=$PREFIX \
199201
--without-nghttp2 \
200202
--without-libidn2 \

pkg/mac/build-pulsar-cpp.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ if [ ! -f apache-pulsar-client-cpp-${PULSAR_CPP_VERSION}/.done ]; then
4545
ARCHS='arm64;x86_64'
4646

4747
cmake . \
48+
-DCMAKE_CXX_STANDARD=11 \
4849
-DCMAKE_OSX_ARCHITECTURES=${ARCHS} \
4950
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
5051
-DCMAKE_INSTALL_PREFIX=$PREFIX \
5152
-DCMAKE_BUILD_TYPE=Release \
5253
-DCMAKE_PREFIX_PATH=${DEPS_PREFIX} \
5354
-DCMAKE_CXX_FLAGS=-I${DEPS_PREFIX}/include \
55+
-DOPENSSL_ROOT_DIR=${DEPS_PREFIX} \
5456
-DLINK_STATIC=OFF \
5557
-DBUILD_TESTS=OFF \
5658
-DBUILD_WIRESHARK=OFF \

0 commit comments

Comments
 (0)