git: f0404eb39e87 - stable/13 - libthr: Add src.conf variable WITHOUT_PTHREADS_ASSERTIONS

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 14 Jul 2023 04:13:06 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=f0404eb39e877425d70b4ba0da530f67d9c36771

commit f0404eb39e877425d70b4ba0da530f67d9c36771
Author:     Greg Becker <becker.greg@att.net>
AuthorDate: 2023-07-07 00:30:02 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-07-13 01:29:17 +0000

    libthr: Add src.conf variable WITHOUT_PTHREADS_ASSERTIONS
    
    (cherry picked from commit 642cd511028b8839db2c89a44cf7807d80664f38)
---
 lib/libthr/Makefile                             | 2 ++
 lib/libthr/thread/thr_mutex.c                   | 2 +-
 share/mk/src.opts.mk                            | 1 +
 tools/build/options/WITHOUT_PTHREADS_ASSERTIONS | 1 +
 4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile
index 0b550d995241..dff8905a1670 100644
--- a/lib/libthr/Makefile
+++ b/lib/libthr/Makefile
@@ -45,8 +45,10 @@ SYMBOL_MAPS=${.CURDIR}/pthread.map
 
 MAN=	libthr.3
 
+.if ${MK_PTHREADS_ASSERTIONS} != "no"
 # enable extra internal consistency checks
 CFLAGS+=-D_PTHREADS_INVARIANTS
+.endif
 
 PRECIOUSLIB=
 
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 8dccdf4dfa8c..2cbfd9a459d3 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -120,7 +120,7 @@ __weak_reference(_pthread_mutex_getyieldloops_np, pthread_mutex_getyieldloops_np
 __weak_reference(_pthread_mutex_isowned_np, pthread_mutex_isowned_np);
 
 static void
-mutex_init_link(struct pthread_mutex *m)
+mutex_init_link(struct pthread_mutex *m __unused)
 {
 
 #if defined(_PTHREADS_INVARIANTS)
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index 403bbfb1a138..f7120b69fdbd 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -160,6 +160,7 @@ __DEFAULT_YES_OPTIONS = \
     PMC \
     PORTSNAP \
     PPP \
+    PTHREADS_ASSERTIONS \
     QUOTAS \
     RADIUS_SUPPORT \
     RBOOTD \
diff --git a/tools/build/options/WITHOUT_PTHREADS_ASSERTIONS b/tools/build/options/WITHOUT_PTHREADS_ASSERTIONS
new file mode 100644
index 000000000000..b0961fa43cb6
--- /dev/null
+++ b/tools/build/options/WITHOUT_PTHREADS_ASSERTIONS
@@ -0,0 +1 @@
+Disable debugging assertions in pthreads library.