Skip to content

Commit 39b5248

Browse files
committed
CDRIVER-3493 fix libmongocrypt dep for static
1 parent 7353402 commit 39b5248

File tree

11 files changed

+32
-19
lines changed

11 files changed

+32
-19
lines changed

.evergreen/check-release-archive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ python build/calc_release_version.py -p > VERSION_RELEASED
2424
# file checks.
2525
mkdir cmake_build
2626
cd cmake_build
27-
$CMAKE -DENABLE_MAN_PAGES=ON -DENABLE_HTML_DOCS=ON -DENABLE_ZLIB=BUNDLED -DENABLE_BSON=ON -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF ../
27+
$CMAKE -DENABLE_MAN_PAGES=ON -DENABLE_HTML_DOCS=ON -DENABLE_ZLIB=BUNDLED -DENABLE_BSON=ON ../
2828
make DISTCHECK_BUILD_OPTS="-j 8" distcheck
2929

3030
# Check that docs were included, but sphinx temp files weren't.

.evergreen/compile-unix.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,6 @@ if [ "$COMPILE_LIBMONGOCRYPT" = "ON" ]; then
208208
$CMAKE -DENABLE_SHARED_BSON=ON -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DCMAKE_PREFIX_PATH="$INSTALL_DIR" ../
209209
make install
210210
cd ../../
211-
else
212-
# Hosts may have libmongocrypt installed from apt/yum. We do not want to pick those up
213-
# since those libmongocrypt packages statically link libbson.
214-
CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF"
215211
fi
216212

217213
if [ "$ANALYZE" = "ON" ]; then

.evergreen/config.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,14 @@ functions:
432432
# Hide credentials.
433433
set +o xtrace
434434
set +o errexit
435-
export MONGOC_TEST_AWS_SECRET_ACCESS_KEY="${client_side_encryption_aws_secret_access_key}"
436-
export MONGOC_TEST_AWS_ACCESS_KEY_ID="${client_side_encryption_aws_access_key_id}"
435+
# Only set creds if testing with Client Side Encryption.
436+
# libmongoc may build with CSE enabled (if the host has libmongocrypt installed)
437+
# and will try to run those tests (which fail on ASAN unless spawning is bypassed).
438+
if [ -n "$CLIENT_SIDE_ENCRYPTION" ]; then
439+
echo "testing with CSE"
440+
export MONGOC_TEST_AWS_SECRET_ACCESS_KEY="${client_side_encryption_aws_secret_access_key}"
441+
export MONGOC_TEST_AWS_ACCESS_KEY_ID="${client_side_encryption_aws_access_key_id}"
442+
fi
437443
set -o errexit
438444
set -o xtrace
439445
sh .evergreen/run-tests.sh

.evergreen/install-uninstall-check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ else
4747
fi
4848

4949

50-
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $BSON_ONLY_OPTION -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF .
50+
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $BSON_ONLY_OPTION .
5151
make
5252
if [ "$DESTDIR" ]; then
5353
make DESTDIR=$DESTDIR install

.evergreen/link-sample-program-bson.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ $TAR xf ../../mongoc.tar.gz -C . --strip-components=1
4949

5050
if [ "$LINK_STATIC" ]; then
5151
# Our CMake system builds shared and static by default.
52-
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF -DENABLE_BSON=ON -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF .
52+
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF -DENABLE_BSON=ON .
5353
make
5454
make install
5555
else
56-
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF -DENABLE_BSON=ON -DENABLE_STATIC=OFF -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF .
56+
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF -DENABLE_BSON=ON -DENABLE_STATIC=OFF .
5757
make
5858
make install
5959

.evergreen/link-sample-program.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ else
8282
fi
8383

8484

85-
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $SSL_CMAKE_OPTION $SNAPPY_CMAKE_OPTION $STATIC_CMAKE_OPTION -DENABLE_BSON=ON -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF -DENABLE_ZSTD=$ZSTD .
85+
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $SSL_CMAKE_OPTION $SNAPPY_CMAKE_OPTION $STATIC_CMAKE_OPTION -DENABLE_BSON=ON -DENABLE_ZSTD=$ZSTD .
8686
make
8787
make install
8888

build/cmake/make_dist/MakeDistCheck.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ function (RUN_DIST_CHECK PACKAGE_PREFIX EXT)
5252
-D ENABLE_MAINTAINER_FLAGS=ON
5353
-D ENABLE_SNAPPY=AUTO
5454
-D ENABLE_ZLIB=BUNDLED
55-
-D ENABLE_CLIENT_SIDE_ENCRYPTION=OFF
5655
../${PACKAGE_PREFIX}
5756
WORKING_DIRECTORY ${BUILD_DIR}
5857
ERROR_MSG "CMake configure command failed."

build/evergreen_config_lib/functions.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,14 @@
296296
# Hide credentials.
297297
set +o xtrace
298298
set +o errexit
299-
export MONGOC_TEST_AWS_SECRET_ACCESS_KEY="${client_side_encryption_aws_secret_access_key}"
300-
export MONGOC_TEST_AWS_ACCESS_KEY_ID="${client_side_encryption_aws_access_key_id}"
299+
# Only set creds if testing with Client Side Encryption.
300+
# libmongoc may build with CSE enabled (if the host has libmongocrypt installed)
301+
# and will try to run those tests (which fail on ASAN unless spawning is bypassed).
302+
if [ -n "$CLIENT_SIDE_ENCRYPTION" ]; then
303+
echo "testing with CSE"
304+
export MONGOC_TEST_AWS_SECRET_ACCESS_KEY="${client_side_encryption_aws_secret_access_key}"
305+
export MONGOC_TEST_AWS_ACCESS_KEY_ID="${client_side_encryption_aws_access_key_id}"
306+
fi
301307
set -o errexit
302308
set -o xtrace
303309
sh .evergreen/run-tests.sh

src/libmongoc/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,9 @@ elseif (NOT ENABLE_CLIENT_SIDE_ENCRYPTION STREQUAL OFF)
421421

422422
if (mongocrypt_FOUND)
423423
set (LIBMONGOCRYPT_TARGET mongo::mongocrypt)
424-
get_target_property (LIBMONGOCRYPT_LIBRARY mongo::mongocrypt LOCATION)
424+
get_target_property (LIBMONGOCRYPT_RUNTIME_LIBRARY mongo::mongocrypt LOCATION)
425+
get_filename_component(LIBMONGOCRYPT_LIBRARY_LOCATION ${LIBMONGOCRYPT_RUNTIME_LIBRARY} DIRECTORY)
426+
find_library (LIBMONGOCRYPT_LIBRARY NAMES mongocrypt PATHS ${LIBMONGOCRYPT_LIBRARY_LOCATION})
425427
get_target_property (LIBMONGOCRYPT_INCLUDE_DIRECTORIES mongo::mongocrypt INTERFACE_INCLUDE_DIRECTORIES)
426428
message ("-- libmongocrypt found at ${LIBMONGOCRYPT_LIBRARY}")
427429
message ("-- libmongocrypt include path ${LIBMONGOCRYPT_INCLUDE_DIRECTORIES}")
@@ -681,11 +683,11 @@ endif ()
681683

682684
set (LIBRARIES
683685
${SASL_LIBRARIES} ${SSL_LIBRARIES} ${SHM_LIBRARIES} ${RESOLV_LIBRARIES}
684-
${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} Threads::Threads ${ICU_LIBRARIES} ${LIBMONGOCRYPT_TARGET}
686+
${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} Threads::Threads ${ICU_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY}
685687
)
686688
set (STATIC_LIBRARIES
687689
${SASL_LIBRARIES} ${SSL_LIBRARIES} ${SHM_LIBRARIES} ${RESOLV_LIBRARIES}
688-
${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ICU_LIBRARIES} ${LIBMONGOCRYPT_TARGET}
690+
${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ICU_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY}
689691
)
690692

691693
if (WIN32)
@@ -697,6 +699,7 @@ set_target_properties (mongoc_shared PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidd
697699
target_link_libraries (mongoc_shared PRIVATE ${LIBRARIES} PUBLIC ${BSON_LIBRARIES})
698700
target_include_directories (mongoc_shared BEFORE PUBLIC ${MONGOC_INTERNAL_INCLUDE_DIRS})
699701
target_include_directories (mongoc_shared PRIVATE ${PRIVATE_ZLIB_INCLUDES})
702+
target_include_directories (mongoc_shared PRIVATE ${LIBMONGOCRYPT_INCLUDE_DIRECTORIES})
700703
target_compile_definitions (mongoc_shared PRIVATE MONGOC_COMPILATION)
701704

702705
set_target_properties (mongoc_shared PROPERTIES VERSION 0.0.0 SOVERSION 0)
@@ -707,6 +710,7 @@ if (MONGOC_ENABLE_STATIC)
707710
target_link_libraries (mongoc_static ${STATIC_LIBRARIES} ${BSON_STATIC_LIBRARIES})
708711
target_include_directories (mongoc_static BEFORE PUBLIC ${MONGOC_INTERNAL_INCLUDE_DIRS})
709712
target_include_directories (mongoc_static PRIVATE ${PRIVATE_ZLIB_INCLUDES})
713+
target_include_directories (mongoc_static PRIVATE ${LIBMONGOCRYPT_INCLUDE_DIRECTORIES})
710714
target_compile_definitions (mongoc_static
711715
PUBLIC MONGOC_STATIC ${BSON_STATIC_PUBLIC_DEFINITIONS}
712716
PRIVATE MONGOC_COMPILATION

src/libmongoc/src/mongoc/mongoc-client-side-encryption.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,7 @@ _spawn_mongocryptd (const char *mongocryptd_spawn_path,
10251025
bool passed_idle_shutdown_timeout_secs = false;
10261026
int num_args = 2; /* for leading "mongocrypt" and trailing NULL */
10271027
int i;
1028+
bool ret;
10281029

10291030
/* iterate once to get length and validate all are strings */
10301031
if (mongocryptd_spawn_args) {
@@ -1073,7 +1074,9 @@ _spawn_mongocryptd (const char *mongocryptd_spawn_path,
10731074
BSON_ASSERT (i == num_args - 1);
10741075
args[i++] = NULL;
10751076

1076-
return _do_spawn (mongocryptd_spawn_path, args, error);
1077+
ret = _do_spawn (mongocryptd_spawn_path, args, error);
1078+
bson_free (args);
1079+
return ret;
10771080
}
10781081

10791082
static bool

0 commit comments

Comments
 (0)