-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Who would statically link OpenSSL but dynamically link Poco and the pthread library? Sorry, then, to raise such a minority-interest thing, but without a patch like:
===== Crypto/Makefile 1.1 vs edited =====
--- 1.1/Crypto/Makefile 2017-01-05 05:35:12 -08:00
+++ edited/Crypto/Makefile 2020-08-14 00:30:38 -07:00
@@ -8,7 +8,10 @@
include $(POCO_BASE)/build/rules/global
+GLOBAL_SYSLIBS := $(SYSLIBS)
+SYSLIBS =
SYSLIBS += -lssl -lcrypto
+SYSLIBS += $(GLOBAL_SYSLIBS)
objects = Cipher CipherFactory CipherImpl CipherKey CipherKeyImpl CryptoStream CryptoTransform \
RSACipherImpl RSAKey RSAKeyImpl RSADigestEngine DigestEngine \
... Poco seems to be linking the pthread library before OpenSSL's crypto library, with its new-in-1.1 dependency on the pthread library. I end up with a library where one of the pthread imports - pthread_atfork - is not like the others:
$ objdump --dynamic-syms libPocoCrypto.so | grep pthread
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_key_create
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_destroy
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_unlock
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_wrlock
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_self
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_rdlock
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_key_delete
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_getspecific
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_lock
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_unlock
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_init
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_once
0000000000000000 w DF *UND* 0000000000000000 GLIBC_2.2.5 __pthread_key_create
0000000000000000 D *UND* 0000000000000000 pthread_atfork
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_setspecific
$
When I try to link a program with libPocoCrypto.so, that's when I get the titular undefined reference. I can solve this by giving -lpthread to that linker, but that feels like a hack. With the patch above, the pthread_atfork reference goes away without requiring changes to each program using libPocoCrypto.so.
I could have just done:
SYSLIBS := $(SYSLIBS) -lssl -lcrypto
... but I preferred to leave the variable with "recursive evaluation" (as https://www.gnu.org/software/make/manual/html_node/Flavors.html#Flavors seems to be calling it), for no strong reason.