Details
-
Bug
-
Resolution: Unresolved
-
Major - P3
-
None
-
None
-
None
-
None
Description
On Ubuntu 18.04 (and possibly other Linux systems) linking to dl and pthread is a requirement for linking to static OpenSSL.
pkg-config lists these as static dependencies:
$ pkg-config --libs --cflags --static openssl
|
-lssl -lcrypto -ldl -pthread
|
But some libmongocrypt targets that require them do not. For example, building test_kms_request with static OpenSSL on Ubuntu 18.04 results in linker errors:
$ cd libmongocrypt
|
$ mkdir cmake-build
|
$ cd cmake-build
|
$ cmake -DOPENSSL_USE_STATIC_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=ON ..
|
$ cmake --build . --target test_kms_request
|
# ...
|
7%] Linking C executable test_kms_request
|
cd /home/ubuntu/libmongocrypt/cmake-build/kms-message && /opt/cmake-3.11.0-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/test_kms_request.dir/link.txt --verbose=1
|
/usr/bin/cc -Wall -Werror -Wno-missing-braces -Wall -Wno-unused-function -Wsign-compare -Werror CMakeFiles/test_kms_request.dir/src/kms_b64.c.o CMakeFiles/test_kms_request.dir/src/hexlify.c.o CMakeFiles/test_kms_request.dir/src/kms_azure_request.c.o CMakeFiles/test_kms_request.dir/src/kms_crypto_none.c.o CMakeFiles/test_kms_request.dir/src/kms_crypto_windows.c.o CMakeFiles/test_kms_request.dir/src/kms_crypto_apple.c.o CMakeFiles/test_kms_request.dir/src/kms_crypto_libcrypto.c.o CMakeFiles/test_kms_request.dir/src/kms_caller_identity_request.c.o CMakeFiles/test_kms_request.dir/src/kms_decrypt_request.c.o CMakeFiles/test_kms_request.dir/src/kms_encrypt_request.c.o CMakeFiles/test_kms_request.dir/src/kms_gcp_request.c.o CMakeFiles/test_kms_request.dir/src/kms_kv_list.c.o CMakeFiles/test_kms_request.dir/src/kms_message.c.o CMakeFiles/test_kms_request.dir/src/kms_port.c.o CMakeFiles/test_kms_request.dir/src/kms_request.c.o CMakeFiles/test_kms_request.dir/src/kms_request_opt.c.o CMakeFiles/test_kms_request.dir/src/kms_request_str.c.o CMakeFiles/test_kms_request.dir/src/kms_response.c.o CMakeFiles/test_kms_request.dir/src/kms_response_parser.c.o CMakeFiles/test_kms_request.dir/src/sort.c.o CMakeFiles/test_kms_request.dir/test/test_kms_request.c.o -o test_kms_request /usr/lib/x86_64-linux-gnu/libssl.a /usr/lib/x86_64-linux-gnu/libcrypto.a
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_lock_new':
|
(.text+0x45): undefined reference to `pthread_rwlock_init'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_read_lock':
|
(.text+0x75): undefined reference to `pthread_rwlock_rdlock'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_write_lock':
|
(.text+0x95): undefined reference to `pthread_rwlock_wrlock'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_unlock':
|
(.text+0xb5): undefined reference to `pthread_rwlock_unlock'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_lock_free':
|
(.text+0xda): undefined reference to `pthread_rwlock_destroy'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_run_once':
|
(.text+0x105): undefined reference to `pthread_once'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_init_local':
|
(.text+0x125): undefined reference to `pthread_key_create'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_set_local':
|
(.text+0x157): undefined reference to `pthread_setspecific'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_cleanup_local':
|
(.text+0x177): undefined reference to `pthread_key_delete'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `openssl_init_fork_handlers':
|
(.text+0x1d3): undefined reference to `pthread_once'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `fork_once_func':
|
(.text+0x16): undefined reference to `pthread_atfork'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_get_local':
|
(.text+0x143): undefined reference to `pthread_getspecific'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
|
(.text+0x11): undefined reference to `dlopen'
|
(.text+0x24): undefined reference to `dlsym'
|
(.text+0x2f): undefined reference to `dlclose'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
|
(.text+0x1c4): undefined reference to `dlsym'
|
(.text+0x282): undefined reference to `dlerror'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
|
(.text+0x2e8): undefined reference to `dlopen'
|
(.text+0x359): undefined reference to `dlclose'
|
(.text+0x395): undefined reference to `dlerror'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
|
(.text+0x461): undefined reference to `dladdr'
|
(.text+0x4c6): undefined reference to `dlerror'
|
/usr/lib/x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
|
(.text+0x6a2): undefined reference to `dlclose'
|
collect2: error: ld returned 1 exit status
|
kms-message/CMakeFiles/test_kms_request.dir/build.make:388: recipe for target 'kms-message/test_kms_request' failed
|
make[3]: *** [kms-message/test_kms_request] Error 1
|
make[3]: Leaving directory '/home/ubuntu/libmongocrypt/cmake-build'
|
CMakeFiles/Makefile2:299: recipe for target 'kms-message/CMakeFiles/test_kms_request.dir/all' failed
|
make[2]: *** [kms-message/CMakeFiles/test_kms_request.dir/all] Error 2
|
make[2]: Leaving directory '/home/ubuntu/libmongocrypt/cmake-build'
|
CMakeFiles/Makefile2:311: recipe for target 'kms-message/CMakeFiles/test_kms_request.dir/rule' failed
|
make[1]: *** [kms-message/CMakeFiles/test_kms_request.dir/rule] Error 2
|
make[1]: Leaving directory '/home/ubuntu/libmongocrypt/cmake-build'
|
Makefile:243: recipe for target 'test_kms_request' failed
|
make: *** [test_kms_request] Error 2
|