NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/59685: libcrypto should not depend on libpthread



> Date: Thu, 02 Oct 2025 11:39:28 -0400
> From: Christos Zoulas <christos%zoulas.com@localhost>
> 
> Problem is:
> 
> [11:36am] 79>nm obj.amd64-x86_64/libcrypto.a | grep pthread_
>                   U pthread_attr_destroy
>                   U pthread_attr_init
>                   U pthread_attr_setdetachstate
>                   U pthread_create
>                   U pthread_join
> 
> That the new libcrypto needs pthread_create and we decided
> a long time ago not to provide a libc stub for pthread_create
> with the presumption that someone who calls pthread_create
> really needs threads, and can't use stubs.

What decision was that?  Where was it written down?  What was the
rationale?

I can't find any record of rationale.  I can't think of a good reason
why a library like libcrypto shouldn't be able to have a call to
pthread_create that is dynamically gated on thread configuration, so
that multithreaded applications linking against libpthread will work
but single-threaded applications can still use it without linking
against libpthread.  For libcrypto, as long as you don't call
OSSL_set_max_threads, it won't ever try calling pthread_create or the
others.

The attached draft patch series implements that -- one patch to add
the stubs to libc, one patch to undo all the makefile churn and stop
linking everything and the kitchen sink against libpthread so
single-threaded applications get their performance advantage back.

We could add more stubs as needed (e.g., more pthread_attr_*
functions) but these ones should suffice for now.
# HG changeset patch
# User Taylor R Campbell <riastradh%NetBSD.org@localhost>
# Date 1759546071 0
#      Sat Oct 04 02:47:51 2025 +0000
# Branch trunk
# Node ID 66d81a37c965663ebb7a1a57b6049266768f26a4
# Parent  a0306dcafaf26c32d79b45df1e2a5c7fbf8b84e1
# EXP-Topic riastradh-pr59685-libcryptolibpthreadstubs
libc: Expose some more pthread stubs.

Provide macros to refer to these in pthread.h.  This allows libraries
to use the functions without linking against libpthread for
applications that don't need threads.  For example, with OpenSSL's
libcrypto, as long as you don't try to raise OSSL_set_max_threads
above 0, it won't ever try pthread_create.

New pthread macros defined:

pthread_attr_destroy		__libc_thr_attr_destroy
pthread_attr_init		__libc_thr_attr_init
pthread_attr_setdetachstate	__libc_thr_attr_setdetachstate
pthread_create			__libc_thr_create
pthread_detach			__libc_thr_detach
pthread_join			__libc_thr_join

New symbols defined by libc as weak aliases for stubs that always
fail but can be overridden by libpthread:

__libc_thr_attr_destroy
__libc_thr_attr_init
__libc_thr_attr_setdetachstate
__libc_thr_detach
__libc_thr_join

Note that libc already defined __libc_thr_create.

New internal stubs, not for overriding:

__libc_thr_detach_stub
__libc_thr_join_stub

These were formerly called __libc_pthread_detach and
__libc_pthread_join, respectively, and libc has defined weak aliases
pthread_detach and pthread_join for them since 2013.  I retained all
four of those symbols, but defined new ones in the __ namespace that
match the pattern for other thread stubs to avoid raising questions
about why the pattern seems to be broken.  I left a comment noting
this fact too.

New pthread strong aliases to override the libc symbols:

__libc_thr_attr_destroy
__libc_thr_attr_init
__libc_thr_attr_setdetachstate
__libc_thr_detach
__libc_thr_join

Note that pthread already defined a strong __libc_thr_create alias,
so there is no need to add a new one.

PR lib/59685: libcrypto should not depend on libpthread

diff -r a0306dcafaf2 -r 66d81a37c965 lib/libc/include/reentrant.h
--- a/lib/libc/include/reentrant.h	Sat May 17 00:34:43 2025 +0000
+++ b/lib/libc/include/reentrant.h	Sat Oct 04 02:47:51 2025 +0000
@@ -204,8 +204,6 @@ int	__libc_thr_once(once_t *, void (*)(v
 int	__libc_thr_sigsetmask(int, const sigset_t *, sigset_t *);
 thr_t	__libc_thr_self(void);
 int	__libc_thr_yield(void);
-void	__libc_thr_create(thr_t *, const thrattr_t *,
-	    void *(*)(void *), void *);
 void	__libc_thr_exit(void *) __attribute__((__noreturn__));
 int	*__libc_thr_errno(void);
 int	__libc_thr_setcancelstate(int, int *);
@@ -267,6 +265,8 @@ thr_t	__libc_thr_self_stub(void);
 int	__libc_thr_yield_stub(void);
 int	__libc_thr_create_stub(thr_t *, const thrattr_t *,
 	    void *(*)(void *), void *);
+int	__libc_thr_detach_stub(thr_t);
+int	__libc_thr_join_stub(thr_t, void **);
 void	__libc_thr_exit_stub(void *) __dead;
 int	*__libc_thr_errno_stub(void);
 int	__libc_thr_setcancelstate_stub(int, int *);
diff -r a0306dcafaf2 -r 66d81a37c965 lib/libc/thread-stub/thread-stub.c
--- a/lib/libc/thread-stub/thread-stub.c	Sat May 17 00:34:43 2025 +0000
+++ b/lib/libc/thread-stub/thread-stub.c	Sat Oct 04 02:47:51 2025 +0000
@@ -43,8 +43,6 @@
 
 #define	__LIBC_THREAD_STUBS
 
-#define pthread_join	__libc_pthread_join
-#define pthread_detach	__libc_pthread_detach
 #include "namespace.h"
 #include "reentrant.h"
 #include "tsd.h"
@@ -70,11 +68,33 @@ do {					\
 #define	CHECK_NOT_THREADED()	/* nothing */
 #endif
 
-__weak_alias(pthread_join, __libc_pthread_join)
-__weak_alias(pthread_detach, __libc_pthread_detach)
+/*
+ * These aliases are probably not necessary but have been there
+ * historically, probably by mistake.
+ */
+__weak_alias(pthread_join, __libc_thr_join)
+__weak_alias(pthread_detach, __libc_thr_detach)
+
+/*
+ * These aliases appear to have been an accident -- nothing has ever
+ * exposed them in a .h file, and they have probably never been used.
+ */
+__weak_alias(__libc_pthread_join, __libc_thr_join)
+__weak_alias(__libc_pthread_detach, __libc_thr_detach)
+
+/*
+ * These aliases are exposed by pthread.h and overridden by libpthread.
+ * This way libraries can have calls to pthread_create/join/detach
+ * without linking against libpthread, but they will fail at runtime in
+ * applications not linked against libpthread.  (Libraries linked
+ * against libpthread themselves, of course, will work, and carry the
+ * dependency to the application.)
+ */
+__weak_alias(__libc_thr_join, __libc_thr_join_stub)
+__weak_alias(__libc_thr_detach, __libc_thr_detach_stub)
 
 int
-pthread_join(pthread_t thread, void **valptr)
+__libc_thr_join_stub(pthread_t thread, void **valptr)
 {
 
 	if (thread == pthread_self())
@@ -83,7 +103,7 @@ pthread_join(pthread_t thread, void **va
 }
 
 int
-pthread_detach(pthread_t thread)
+__libc_thr_detach_stub(pthread_t thread)
 {
 
 	if (thread == pthread_self())
@@ -94,6 +114,12 @@ pthread_detach(pthread_t thread)
 __weak_alias(pthread_setname_np, __libc_mutex_catchall_stub)
 __weak_alias(pthread_setaffinity_np, __libc_mutex_catchall_stub)
 
+/* thread creation attributes */
+
+__weak_alias(__libc_thr_attr_init, __libc_mutex_catchall_stub)
+__weak_alias(__libc_thr_attr_setdetachstate, __libc_mutex_catchall_stub)
+__weak_alias(__libc_thr_attr_destroy, __libc_mutex_catchall_stub)
+
 /* mutexes */
 
 int __libc_mutex_catchall_stub(mutex_t *);
diff -r a0306dcafaf2 -r 66d81a37c965 lib/libpthread/pthread.c
--- a/lib/libpthread/pthread.c	Sat May 17 00:34:43 2025 +0000
+++ b/lib/libpthread/pthread.c	Sat Oct 04 02:47:51 2025 +0000
@@ -142,6 +142,8 @@ int _sys___sigprocmask14(int, const sigs
 
 __strong_alias(__libc_thr_self,pthread_self)
 __strong_alias(__libc_thr_create,pthread_create)
+__strong_alias(__libc_thr_detach,pthread_detach)
+__strong_alias(__libc_thr_join,pthread_join)
 __strong_alias(__libc_thr_exit,pthread_exit)
 __strong_alias(__libc_thr_errno,pthread__errno)
 __strong_alias(__libc_thr_setcancelstate,pthread_setcancelstate)
diff -r a0306dcafaf2 -r 66d81a37c965 lib/libpthread/pthread.h
--- a/lib/libpthread/pthread.h	Sat May 17 00:34:43 2025 +0000
+++ b/lib/libpthread/pthread.h	Sat Oct 04 02:47:51 2025 +0000
@@ -303,17 +303,8 @@ int	pthread_cond_has_waiters_np(pthread_
  * program. This permits code, particularly libraries that do not
  * directly use threads but want to be thread-safe in the presence of
  * threaded callers, to use pthread mutexes and the like without
- * unnecessairly including libpthread in their linkage.
- *
- * Left out of this list are functions that can't sensibly be trivial
- * or no-op stubs in a single-threaded process (pthread_create,
- * pthread_kill, pthread_detach), functions that normally block and
- * wait for another thread to do something (pthread_join), and
- * functions that don't make sense without the previous functions
- * (pthread_attr_*). The pthread_cond_wait and pthread_cond_timedwait
- * functions are useful in implementing certain protection mechanisms,
- * though a non-buggy app shouldn't end up calling them in
- * single-threaded mode.
+ * unnecessarily including libpthread in their linkage.  Such
+ * applications just don't get a working pthread_create.
  *
  * The rename is done as:
  * #define pthread_foo	__libc_foo
@@ -331,6 +322,26 @@ int	pthread_cond_has_waiters_np(pthread_
 
 #ifndef __LIBPTHREAD_SOURCE__
 __BEGIN_DECLS
+int	__libc_thr_create(pthread_t * __restrict,
+	    const pthread_attr_t * __restrict, void *(*)(void *),
+	    void * __restrict);
+int	__libc_thr_detach(pthread_t);
+int	__libc_thr_join(pthread_t, void **);
+
+int	__libc_thr_attr_init(pthread_attr_t *);
+int	__libc_thr_attr_setdetachstate(pthread_attr_t *, int);
+int	__libc_thr_attr_destroy(pthread_attr_t *);
+__END_DECLS
+
+#define	pthread_create	__libc_thr_create
+#define	pthread_detach	__libc_thr_detach
+#define	pthread_join	__libc_thr_join
+
+#define	pthread_attr_init		__libc_thr_attr_init
+#define	pthread_attr_setdetachstate	__libc_thr_attr_setdetachstate
+#define	pthread_attr_destroy		__libc_thr_attr_destroy
+
+__BEGIN_DECLS
 int	__libc_mutex_init(pthread_mutex_t * __restrict, const pthread_mutexattr_t * __restrict);
 int	__libc_mutex_lock(pthread_mutex_t *);
 int	__libc_mutex_trylock(pthread_mutex_t *);
diff -r a0306dcafaf2 -r 66d81a37c965 lib/libpthread/pthread_attr.c
--- a/lib/libpthread/pthread_attr.c	Sat May 17 00:34:43 2025 +0000
+++ b/lib/libpthread/pthread_attr.c	Sat Oct 04 02:47:51 2025 +0000
@@ -48,6 +48,10 @@
 #include "pthread.h"
 #include "pthread_int.h"
 
+__strong_alias(__libc_thr_attr_init, pthread_attr_init)
+__strong_alias(__libc_thr_attr_setdetachstate, pthread_attr_setdetachstate)
+__strong_alias(__libc_thr_attr_destroy, pthread_attr_destroy)
+
 __weak_alias(pthread_attr_get_np, _pthread_attr_get_np)
 
 static struct pthread_attr_private *pthread__attr_init_private(
diff -r a0306dcafaf2 -r 66d81a37c965 lib/libpthread/pthread_mi.expsym
--- a/lib/libpthread/pthread_mi.expsym	Sat May 17 00:34:43 2025 +0000
+++ b/lib/libpthread/pthread_mi.expsym	Sat Oct 04 02:47:51 2025 +0000
@@ -23,13 +23,18 @@
 __libc_rwlock_trywrlock
 __libc_rwlock_unlock
 __libc_rwlock_wrlock
+__libc_thr_attr_destroy
+__libc_thr_attr_init
+__libc_thr_attr_setdetachstate
 __libc_thr_create
 __libc_thr_curcpu
+__libc_thr_detach
 __libc_thr_equal
 __libc_thr_errno
 __libc_thr_exit
 __libc_thr_getspecific
 __libc_thr_init
+__libc_thr_join
 __libc_thr_keycreate
 __libc_thr_keydelete
 __libc_thr_once
# HG changeset patch
# User Taylor R Campbell <riastradh%NetBSD.org@localhost>
# Date 1759545317 0
#      Sat Oct 04 02:35:17 2025 +0000
# Branch trunk
# Node ID 9dd49a563f8e4bd990ee13de2e1780bff15d25cf
# Parent  66d81a37c965663ebb7a1a57b6049266768f26a4
# EXP-Topic riastradh-pr59685-libcryptolibpthreadstubs
openssl: Stop dragging libpthread into every libcrypto user.

Now that libc has the necessary stubs for libcrypto to have an
optional call to pthread_create, it is not necessary to link all
libcrypto users againts libpthread too.

Applications that link against libcrypto but not libpthread can't use
threaded OpenSSL functionality, of course -- OSSL_set_max_threads
will always fail in such applications.

This reverts all the makefile churn that I found for unnecessary
libpthread linkage since the openssl 3.5 import.

PR lib/59685: libcrypto should not depend on libpthread

diff -r 66d81a37c965 -r 9dd49a563f8e crypto/external/apache2/openssl/bin/Makefile
--- a/crypto/external/apache2/openssl/bin/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/crypto/external/apache2/openssl/bin/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -65,7 +65,6 @@ verify.c \
 version.c \
 x509.c \
 
-CPPFLAGS+= -pthread
 CPPFLAGS+= -I${OPENSSLSRC} -I${.CURDIR}/../include
 CPPFLAGS+= -I${OPENSSLSRC}/include -I${OPENSSLSRC}/apps/include
 
@@ -74,8 +73,8 @@ PROGDPLIBS+=    apps ${OPENSSLSRC}/../li
 PROGDPLIBS+=    ssl ${OPENSSLSRC}/../lib/libssl
 PROGDPLIBS+=    crypto ${OPENSSLSRC}/../lib/libcrypto
 
-LDADD+=	-lcrypt -lpthread
-DPADD+=	${LIBCRYPT} ${LIBPTHREAD}
+LDADD+=	-lcrypt
+DPADD+=	${LIBCRYPT}
 
 CRYPTODIST=	${NETBSDSRCDIR}/crypto
 .include "${NETBSDSRCDIR}/crypto/Makefile.openssl"
diff -r 66d81a37c965 -r 9dd49a563f8e crypto/external/apache2/openssl/dist/crypto/thread/api.c
--- a/crypto/external/apache2/openssl/dist/crypto/thread/api.c	Sat Oct 04 02:47:51 2025 +0000
+++ b/crypto/external/apache2/openssl/dist/crypto/thread/api.c	Sat Oct 04 02:35:17 2025 +0000
@@ -62,6 +62,15 @@ int OSSL_set_max_threads(OSSL_LIB_CTX *c
     tdata = OSSL_LIB_CTX_GET_THREADS(ctx);
     if (tdata == NULL)
         return 0;
+#ifdef __NetBSD__
+    /*
+     * Applications must link against libpthread in order to enable
+     * openssl thread support.
+     */
+    extern int __isthreaded;	/* XXX */
+    if (!__isthreaded)
+        return 0;
+#endif
 
     ossl_crypto_mutex_lock(tdata->lock);
     tdata->max_threads = max_threads;
diff -r 66d81a37c965 -r 9dd49a563f8e crypto/external/apache2/openssl/lib/libcrypto/Makefile
--- a/crypto/external/apache2/openssl/lib/libcrypto/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/crypto/external/apache2/openssl/lib/libcrypto/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -25,7 +25,6 @@ USE_FIPS=	no
 .include <bsd.own.mk>
 .include <bsd.shlib.mk>
 
-CPPFLAGS+= -pthread
 CPPFLAGS+= -Dlib${LIB} -I. -I${OPENSSLSRC}/crypto -I${OPENSSLSRC}
 CPPFLAGS+= -I${OPENSSLSRC}/include -I${OPENSSLSRC}/crypto/include
 CPPFLAGS+= -I${OPENSSLSRC}/crypto/asn1 -I${OPENSSLSRC}/crypto/evp
@@ -51,7 +50,6 @@ CPPFLAGS+= -I${OPENSSLSRC}/providers/imp
 
 AFLAGS+=-DELF
 LIBDPLIBS+= crypt ${NETBSDSRCDIR}/lib/libcrypt
-LIBDPLIBS+= pthread ${NETBSDSRCDIR}/lib/libpthread
 
 OS_VERSION!= ${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
 
diff -r 66d81a37c965 -r 9dd49a563f8e crypto/external/bsd/heimdal/Makefile.inc
--- a/crypto/external/bsd/heimdal/Makefile.inc	Sat Oct 04 02:47:51 2025 +0000
+++ b/crypto/external/bsd/heimdal/Makefile.inc	Sat Oct 04 02:35:17 2025 +0000
@@ -22,8 +22,8 @@ DPLIBROKEN=	roken ${HEIMBASE}/lib/librok
 DPLIBSL=	sl ${HEIMBASE}/lib/libsl
 DPLIBVERS=	vers ${HEIMBASE}/lib/libvers
 DPLIBWIND=	wind ${HEIMBASE}/lib/libwind
-KRB5LDADD=	-lcrypto -lcrypt -lpthread
-KRB5DPADD=	${LIBCRYPTO} ${LIBCRYPT} ${LIBPTHREAD}
+KRB5LDADD=	-lcrypto -lcrypt
+KRB5DPADD=	${LIBCRYPTO} ${LIBCRYPT}
 HDBLDADD=	-lsqlite3 -lm
 HDBDPADD=	${LIBSQLITE3} ${LIBM}
 
diff -r 66d81a37c965 -r 9dd49a563f8e crypto/external/bsd/heimdal/bin/hxtool/Makefile
--- a/crypto/external/bsd/heimdal/bin/hxtool/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/crypto/external/bsd/heimdal/bin/hxtool/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -20,5 +20,5 @@ COPTS.hxtool.c+= -Wno-error=deprecated-d
 .include <${HEIMBASE}/Makefile.rules.inc>
 .include <bsd.prog.mk>
 
-LDADD+= -lcrypto -ledit -lterminfo -lpthread
-DPADD+= ${LIBCRYPTO} ${LIBEDIT} ${LIBTERMINFO} ${LIBPTHREAD}
+LDADD+= -lcrypto -ledit -lterminfo
+DPADD+= ${LIBCRYPTO} ${LIBEDIT} ${LIBTERMINFO}
diff -r 66d81a37c965 -r 9dd49a563f8e crypto/external/bsd/netpgp/bin/Makefile.inc
--- a/crypto/external/bsd/netpgp/bin/Makefile.inc	Sat Oct 04 02:47:51 2025 +0000
+++ b/crypto/external/bsd/netpgp/bin/Makefile.inc	Sat Oct 04 02:35:17 2025 +0000
@@ -12,5 +12,5 @@ LIBMJDIR!=	cd ${.PARSEDIR}/../libmj && $
 LDADD+=		-L${LIBMJDIR} -lmj
 DPADD+=		${LIBMJDIR}/libmj.a
 
-LDADD+=		-lcrypto -lz -lbz2 -lpthread
-DPADD+=		${LIBCRYPTO} ${LIBZ} ${LIBBZ2} ${LIBPTHREAD}
+LDADD+=		-lcrypto -lz -lbz2
+DPADD+=		${LIBCRYPTO} ${LIBZ} ${LIBBZ2}
diff -r 66d81a37c965 -r 9dd49a563f8e crypto/external/bsd/openssh/bin/Makefile.inc
--- a/crypto/external/bsd/openssh/bin/Makefile.inc	Sat Oct 04 02:47:51 2025 +0000
+++ b/crypto/external/bsd/openssh/bin/Makefile.inc	Sat Oct 04 02:35:17 2025 +0000
@@ -8,7 +8,6 @@ PROGDPLIBS+= \
     ssh ${CRYPTOBSD}/openssh/lib \
     crypto ${CRYPTOBSD:H}/${EXTERNAL_OPENSSL_SUBDIR}/lib/libcrypto \
     crypt ${NETBSDSRCDIR}/lib/libcrypt \
-    z ${NETBSDSRCDIR}/lib/libz \
-    pthread ${NETBSDSRCDIR}/lib/libpthread
+    z ${NETBSDSRCDIR}/lib/libz
 
 .include "${.PARSEDIR}/../Makefile.inc"
diff -r 66d81a37c965 -r 9dd49a563f8e external/bsd/libfido2/bin/Makefile.inc
--- a/external/bsd/libfido2/bin/Makefile.inc	Sat Oct 04 02:47:51 2025 +0000
+++ b/external/bsd/libfido2/bin/Makefile.inc	Sat Oct 04 02:35:17 2025 +0000
@@ -4,6 +4,5 @@
 
 .PATH: ${DIST}/tools ${DIST}/man ${DIST}/openbsd-compat
 
-LDADD+=-lfido2 -lcbor -lusbhid -lcrypto -lz -lm -lpthread
-DPADD+=${LIBFIDO2} ${LIBCBOR} ${LIBUSBHID} ${LIBCRYPTO} ${LIBZ} ${LIBM} \
-    ${LIBPTHREAD}
+LDADD+=-lfido2 -lcbor -lusbhid -lcrypto -lz -lm
+DPADD+=${LIBFIDO2} ${LIBCBOR} ${LIBUSBHID} ${LIBCRYPTO} ${LIBZ} ${LIBM}
diff -r 66d81a37c965 -r 9dd49a563f8e external/bsd/nsd/Makefile.inc
--- a/external/bsd/nsd/Makefile.inc	Sat Oct 04 02:47:51 2025 +0000
+++ b/external/bsd/nsd/Makefile.inc	Sat Oct 04 02:35:17 2025 +0000
@@ -23,7 +23,6 @@ DPLIBS+= ssl ${NETBSDSRCDIR}/crypto/exte
 DPLIBS+= crypto ${NETBSDSRCDIR}/crypto/external/${EXTERNAL_OPENSSL_SUBDIR}/lib/libcrypto
 DPLIBS+= crypt ${NETBSDSRCDIR}/lib/libcrypt
 DPLIBS+= util ${NETBSDSRCDIR}/lib/libutil
-DPLIBS+= pthread ${NETBSDSRCDIR}/lib/libpthread
 
 __subst: .USE
 	${TOOL_SED} \
diff -r 66d81a37c965 -r 9dd49a563f8e external/bsd/ntp/Makefile.inc
--- a/external/bsd/ntp/Makefile.inc	Sat Oct 04 02:47:51 2025 +0000
+++ b/external/bsd/ntp/Makefile.inc	Sat Oct 04 02:35:17 2025 +0000
@@ -35,8 +35,8 @@ LIBPARSE!=	cd ${.CURDIR}/../../lib/libpa
 LDADD+=		-L${LIBNTP} -lntp -L${LIBOPTS} -lopts
 DPADD+=		${LIBNTP}/libntp.a ${LIBOPTS}/libopts.a
 
-LDADD+=		-lcrypto -lcrypt -lpthread
-DPADD+=		${LIBCRYPTO} ${LIBCRYPT} ${LIBPTHREAD}
+LDADD+=		-lcrypto -lcrypt
+DPADD+=		${LIBCRYPTO} ${LIBCRYPT}
 
 .if ${MKMDNS:Uno} != "no"
 CPPFLAGS+=-DHAVE_DNSREGISTRATION=1
diff -r 66d81a37c965 -r 9dd49a563f8e external/bsd/pam-u2f/bin/pamu2fcfg/Makefile
--- a/external/bsd/pam-u2f/bin/pamu2fcfg/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/external/bsd/pam-u2f/bin/pamu2fcfg/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -16,9 +16,8 @@ PROG=pamu2fcfg
 SRCS=pamu2fcfg.c cmdline.c b64.c readpassphrase.c explicit_bzero.c util.c
 COPTS.util.c += -Wno-error=stack-protector
 
-LDADD+=-lpam -lfido2 -lcbor -lusbhid -lcrypto -lm -lpthread
-DPADD+=${LIBPAM} ${LIBFIDO2} ${LIBCBOR} ${LIBUSBHID} ${LIBCRYPTO} ${LIBM} \
-    ${LIBPTHREAD}
+LDADD+=-lpam -lfido2 -lcbor -lusbhid -lcrypto -lm
+DPADD+=${LIBPAM} ${LIBFIDO2} ${LIBCBOR} ${LIBUSBHID} ${LIBCRYPTO} ${LIBM}
 
 pamu2fcfg.1:
 	asciidoc -b docbook45 -d manpage -o pamu2fcfg.1.xml ../../dist/man/pamu2fcfg.1.txt
diff -r 66d81a37c965 -r 9dd49a563f8e external/bsd/ppp/usr.sbin/pppd/Makefile
--- a/external/bsd/ppp/usr.sbin/pppd/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/external/bsd/ppp/usr.sbin/pppd/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -64,8 +64,6 @@ DPADD+=${LIBPAM} ${PAM_STATIC_DPADD}
 
 LDADD+= -lpcap -lcrypt -lssl -lcrypto -lutil -Wl,--export-dynamic
 DPADD+= ${LIBPCAP} ${LIBCRYPT} ${LIBSSL} ${LIBCRYPTO} ${LIBUTIL}
-LDADD+= -lpthread
-DPADD+= ${LIBPTHREAD}
 
 .for f in chap-md5 chap_ms eap
 COPTS.${f}.c+=	-Wno-pointer-sign
diff -r 66d81a37c965 -r 9dd49a563f8e external/bsd/tcpdump/bin/Makefile
--- a/external/bsd/tcpdump/bin/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/external/bsd/tcpdump/bin/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -211,8 +211,8 @@ CPPFLAGS+=-DHAVE_OS_IPV6_SUPPORT=1
 .endif
 
 CPPFLAGS+=-DHAVE_LIBCRYPTO=1 -DHAVE_OPENSSL_EVP_H 
-LDADD+=	-lcrypto -lcrypt -lpthread
-DPADD+=	${LIBCRYPTO} ${LIBCRYPT} ${LIBPTHREAD}
+LDADD+=	-lcrypto -lcrypt
+DPADD+=	${LIBCRYPTO} ${LIBCRYPT}
 
 CLEANFILES+=	version.c tcpdump.8
 
diff -r 66d81a37c965 -r 9dd49a563f8e external/bsd/wpa/bin/hostapd/Makefile
--- a/external/bsd/wpa/bin/hostapd/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/external/bsd/wpa/bin/hostapd/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -251,8 +251,8 @@ ikev2.c \
 tncs.c
 
 
-DPADD+= ${LIBSSL} ${LIBCRYPTO} ${LIBDES} ${LIBPTHREAD}
-LDADD+= -lssl -lcrypto -ldes -lpthread
+DPADD+= ${LIBSSL} ${LIBCRYPTO} ${LIBDES}
+LDADD+= -lssl -lcrypto -ldes
 .else
 CPPFLAGS+= -DINTERNAL_AES -DINTERNAL_MD5 -DINTERNAL_SHA1 -DCONFIG_NO_PBKDF2
 CPPFLAGS+= -DCONFIG_CRYPTO_INTERNAL
diff -r 66d81a37c965 -r 9dd49a563f8e external/bsd/wpa/bin/wpa_passphrase/Makefile
--- a/external/bsd/wpa/bin/wpa_passphrase/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/external/bsd/wpa/bin/wpa_passphrase/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -14,8 +14,8 @@ wpabuf.c
 
 .if !defined(NO_CRYPT) && !defined(NO_OPENSSL) && !defined(RELEASE_CRUNCH)
 SRCS+= crypto_openssl.c
-DPADD+= ${LIBSSL} ${LIBCRYPTO} ${LIBDES} ${LIBPTHREAD}
-LDADD+= -lssl -lcrypto -ldes -lpthread
+DPADD+= ${LIBSSL} ${LIBCRYPTO} ${LIBDES}
+LDADD+= -lssl -lcrypto -ldes
 .else
 CPPFLAGS+= -DINTERNAL_AES -DINTERNAL_MD5 -DINTERNAL_SHA1
 CPPFLAGS+= -DCONFIG_CRYPTO_INTERNAL
diff -r 66d81a37c965 -r 9dd49a563f8e external/bsd/wpa/bin/wpa_supplicant/Makefile
--- a/external/bsd/wpa/bin/wpa_supplicant/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/external/bsd/wpa/bin/wpa_supplicant/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -176,8 +176,8 @@ aes-omac1.c \
 #CPPFLAGS+= -DEAP_FAST
 #SRCS+=	eap_fast.c
 
-DPADD+= ${LIBSSL} ${LIBCRYPTO} ${LIBDES} ${LIBPTHREAD}
-LDADD+= -lssl -lcrypto -ldes -lpthread
+DPADD+= ${LIBSSL} ${LIBCRYPTO} ${LIBDES}
+LDADD+= -lssl -lcrypto -ldes
 .else
 CPPFLAGS+= -DINTERNAL_AES -DINTERNAL_MD5 -DINTERNAL_SHA1 -DCONFIG_NO_PBKDF2
 SRCS+= tls_none.c sha1-internal.c md5-internal.c aes-xinternal.c rc4.c
diff -r 66d81a37c965 -r 9dd49a563f8e games/factor/Makefile
--- a/games/factor/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/games/factor/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -10,8 +10,8 @@ SRCS=	factor.c pr_tbl.c
 CPPFLAGS+=-I${PRIMES}
 
 CPPFLAGS+=-DHAVE_OPENSSL
-LDADD+=	-lcrypto -lcrypt -lpthread
-DPADD+=	${LIBCRYPTO} ${LIBCRYPT} ${LIBPTHREAD}
+LDADD+=	-lcrypto -lcrypt
+DPADD+=	${LIBCRYPTO} ${LIBCRYPT}
 
 COPTS.factor.c+= -Wno-error=deprecated-declarations
 
diff -r 66d81a37c965 -r 9dd49a563f8e libexec/httpd/Makefile
--- a/libexec/httpd/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/libexec/httpd/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -52,8 +52,8 @@ CPPFLAGS+=	-DHAVE_NBUTIL_H
 LDADD+=		-lnbutil
 .endif
 
-LDADD+=	-lssl -lcrypto -lpthread
-DPADD+=	${LIBSSL} ${LIBCRYPTO} ${LIBPTHREAD}
+LDADD+=	-lssl -lcrypto
+DPADD+=	${LIBSSL} ${LIBCRYPTO}
 
 #
 # Build release things.
diff -r 66d81a37c965 -r 9dd49a563f8e share/mk/bsd.prog.mk
--- a/share/mk/bsd.prog.mk	Sat Oct 04 02:47:51 2025 +0000
+++ b/share/mk/bsd.prog.mk	Sat Oct 04 02:35:17 2025 +0000
@@ -205,19 +205,19 @@ LIB${_lib:tu}=	${DESTDIR}/usr/lib/lib${_
 LIBKRB5_LDADD+= -lkrb5 -lcom_err \
 	-lhx509 -lcrypto -lasn1 \
 	-lwind -lheimbase -lcom_err -lroken \
-	-lcrypt -lutil -lpthread
+	-lcrypt -lutil
 LIBKRB5_DPADD+= ${LIBKRB5} ${LIBCOM_ERR} \
 	${LIBHX509} ${LIBCRYPTO} ${LIBASN1} \
 	${LIBWIND} ${LIBHEIMBASE} ${LIBCOM_ERR} ${LIBROKEN} \
-	${LIBCRYPT} ${LIBUTIL} ${LIBPTHREAD}
+	${LIBCRYPT} ${LIBUTIL}
 LIBGSSAPI_LDADD+= -lgssapi -lheimntlm ${LIBKRB5_LDADD}
 LIBGSSAPI_DPADD+= ${LIBGSSAPI} ${LIBHEIMNTLM} ${LIBKRB5_DPADD}
 .endif
 
 .if (${MKLDAP} != "no")
-LIBLDAP_LDADD+= -lldap -llber ${LIBGSSAPI_LDADD} -lssl -lcrypto -lpthread
+LIBLDAP_LDADD+= -lldap -llber ${LIBGSSAPI_LDADD} -lssl -lcrypto
 LIBLDAP_DPADD+= ${LIBLDAP} ${LIBLBER} ${LIBGSSAPI_DPADD} ${LIBSSL} \
-    ${LIBCRYPTO} ${LIBPTHREAD}
+    ${LIBCRYPTO}
 .endif
 
 # PAM applications, if linked statically, need more libraries
@@ -226,10 +226,10 @@ PAM_STATIC_LDADD+= -lssh
 PAM_STATIC_DPADD+= ${LIBSSH}
 .if (${MKKERBEROS} != "no")
 PAM_STATIC_LDADD+= -lkafs -lkrb5 -lhx509 -lwind -lasn1 \
-	-lroken -lcom_err -lheimbase -lcrypto -lsqlite3 -lpthread -lm
+	-lroken -lcom_err -lheimbase -lcrypto -lsqlite3 -lm
 PAM_STATIC_DPADD+= ${LIBKAFS} ${LIBKRB5} ${LIBHX509} ${LIBWIND} ${LIBASN1} \
 	${LIBROKEN} ${LIBCOM_ERR} ${LIBHEIMBASE} ${LIBCRYPTO} ${LIBSQLITE3} \
-	${LIBPTHREAD} ${LIBM}
+	${LIBM}
 .endif
 .if (${MKSKEY} != "no")
 PAM_STATIC_LDADD+= -lskey
diff -r 66d81a37c965 -r 9dd49a563f8e tests/crypto/libcrypto/Makefile
--- a/tests/crypto/libcrypto/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/tests/crypto/libcrypto/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -19,8 +19,8 @@ SUBDIR += lhash sha x509v3
 TESTSDIR=	${TESTSBASE}/crypto/libcrypto
 
 TESTS_C+=		t_sha512trunc
-DPADD.t_sha512trunc+=	${LIBCRYPTO} ${LIBPTHREAD}
-LDADD.t_sha512trunc+=	-lcrypto -lpthread
+DPADD.t_sha512trunc+=	${LIBCRYPTO}
+LDADD.t_sha512trunc+=	-lcrypto
 
 .if ${HAVE_OPENSSL} == 10
 TESTS_SH=	t_certs
diff -r 66d81a37c965 -r 9dd49a563f8e tests/crypto/libcrypto/Makefile.inc
--- a/tests/crypto/libcrypto/Makefile.inc	Sat Oct 04 02:47:51 2025 +0000
+++ b/tests/crypto/libcrypto/Makefile.inc	Sat Oct 04 02:35:17 2025 +0000
@@ -32,8 +32,8 @@ PROGDPLIBS+=	cryptotest ${OPENSSLSRC}/..
 .if ${HELPER_NAME} != "threadstest"
 PROGDPLIBS+=	crypto ${OPENSSLSRC}/../lib/libcrypto
 .endif
-DPADD_AFTER+=		${LIBCRYPT} ${LIBPTHREAD}
-LDADD_AFTER+=		-lcrypt -lpthread
+DPADD+=		${LIBCRYPT}
+LDADD+=		-lcrypt
 
 
 .include <bsd.test.mk>
diff -r 66d81a37c965 -r 9dd49a563f8e tests/crypto/libcrypto/dh/Makefile
--- a/tests/crypto/libcrypto/dh/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/tests/crypto/libcrypto/dh/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -3,7 +3,5 @@
 PROGDPLIBSSTATIC=yes
 HELPER_NAME=	dhtest
 HELPER_DIR=	dh
-DPADD+= ${LIBPTHREAD}
-LDADD+= -lpthread
 
 .include <bsd.init.mk>
diff -r 66d81a37c965 -r 9dd49a563f8e tests/lib/libc/hash/Makefile
--- a/tests/lib/libc/hash/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/tests/lib/libc/hash/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -6,8 +6,8 @@ TESTSDIR=	${TESTSBASE}/lib/libc/hash
 
 TESTS_C+=	t_sha2
 TESTS_C+=	t_hmac
-LDADD.t_hmac+=	-lcrypto -lpthread
-DDADD.t_hmac+=	${LIBCRYPTO} ${LIBPTHREAD}
+LDADD.t_hmac+=	-lcrypto
+DDADD.t_hmac+=	${LIBCRYPTO}
 
 TESTS_SH+=	t_hash
 
diff -r 66d81a37c965 -r 9dd49a563f8e usr.bin/dc/Makefile
--- a/usr.bin/dc/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/usr.bin/dc/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -6,8 +6,8 @@ PROG=	dc
 SRCS=	main.c dc.c bcode.c inout.c mem.c stack.c
 
 WARNS=6
-LDADD=	-lcrypto -lpthread
-DPADD=	${LIBCRYPTO} ${LIBPTHREAD}
+LDADD=	-lcrypto
+DPADD=	${LIBCRYPTO}
 
 SUBDIR.roff+=USD.doc
 
diff -r 66d81a37c965 -r 9dd49a563f8e usr.bin/ftp/Makefile
--- a/usr.bin/ftp/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/usr.bin/ftp/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -20,8 +20,8 @@ CPPFLAGS+=-DNO_EDITCOMPLETE -DNO_ABOUT -
 LDADD+=	-ledit -lterminfo
 DPADD+=	${LIBEDIT} ${LIBTERMINFO}
 CPPFLAGS+= -DWITH_SSL
-LDADD+= -lssl -lcrypto -lpthread
-DPADD+= ${LIBSSL} ${LIBCRYPTO} ${LIBPTHREAD}
+LDADD+= -lssl -lcrypto
+DPADD+= ${LIBSSL} ${LIBCRYPTO}
 .endif
 
 .if (!defined(SMALLPROG) || defined(SMALLPROG_INET6)) && (${USE_INET6} != "no")
diff -r 66d81a37c965 -r 9dd49a563f8e usr.bin/moduli/Makefile.inc
--- a/usr.bin/moduli/Makefile.inc	Sat Oct 04 02:47:51 2025 +0000
+++ b/usr.bin/moduli/Makefile.inc	Sat Oct 04 02:35:17 2025 +0000
@@ -2,8 +2,8 @@
 
 .include <bsd.own.mk>
 
-DPADD+= ${LIBCRYPTO} ${LIBPTHREAD}
-LDADD+= -lcrypto -lpthread
+DPADD+= ${LIBCRYPTO}
+LDADD+= -lcrypto
 
 .if exists(${.CURDIR}/../../Makefile.inc)
 .include "${.CURDIR}/../../Makefile.inc"
diff -r 66d81a37c965 -r 9dd49a563f8e usr.bin/nbsvtool/Makefile
--- a/usr.bin/nbsvtool/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/usr.bin/nbsvtool/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -1,8 +1,8 @@
 # $NetBSD: Makefile,v 1.4 2025/07/19 15:56:31 christos Exp $
 
 PROG=	nbsvtool
-LDADD+=	-lcrypto -lpthread
-DPADD+=	${LIBCRYPTO} ${LIBPTHREAD}
+LDADD+=	-lcrypto
+DPADD+=	${LIBCRYPTO}
 CPPFLAGS+=-DOPENSSL_API_COMPAT=0x10100000L
 
 .include <bsd.prog.mk>
diff -r 66d81a37c965 -r 9dd49a563f8e usr.sbin/plainrsa-gen/Makefile
--- a/usr.sbin/plainrsa-gen/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/usr.sbin/plainrsa-gen/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -9,8 +9,8 @@ SRCS+=	plainrsa-gen.c
 MAN=	plainrsa-gen.8
 
 CPPFLAGS+=-DNOUSE_PRIVSEP
-LDADD+= -lcrypto -lipsec -lpthread
-DPADD+= ${LIBCRYPTO} ${LIBIPSEC} ${LIBPTHREAD}
+LDADD+= -lcrypto -lipsec
+DPADD+= ${LIBCRYPTO} ${LIBIPSEC}
 
 .include "${.CURDIR}/../racoon/Makefile.racoon"
 
diff -r 66d81a37c965 -r 9dd49a563f8e usr.sbin/syslogd/Makefile
--- a/usr.sbin/syslogd/Makefile	Sat Oct 04 02:47:51 2025 +0000
+++ b/usr.sbin/syslogd/Makefile	Sat Oct 04 02:35:17 2025 +0000
@@ -28,8 +28,8 @@ CPPFLAGS+=-DOPENSSL_API_COMPAT=0x1010000
 LDADD+=	-lwrap -lblocklist 
 DPADD+=	${LIBWRAP} ${LIBBLOCKLIST} 
 
-LDADD+=	-lssl -lcrypto -lpthread
-DPADD+= ${LIBSSL} ${LIBCRYPTO} ${LIBPTHREAD}
+LDADD+=	-lssl -lcrypto
+DPADD+= ${LIBSSL} ${LIBCRYPTO}
 
 # Overflow that appears impossible
 COPTS.syslogd.c+=        ${CC_WNO_FORMAT_TRUNCATION} ${CC_WNO_STRINGOP_TRUNCATION}


Home | Main Index | Thread Index | Old Index