Subject: pkg/17476: USE_PTHREAD/ need to be re-thought.
To: None <>
From: Nick Hudson <>
List: netbsd-bugs
Date: 07/04/2002 09:23:03
>Number:         17476
>Category:       pkg
>Synopsis:       USE_PTHREAD/ need to be re-thought.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 04 00:24:00 PDT 2002
>Originator:     Nick Hudson
>Release:        NetBSD 1.6B
	Not much.
System: NetBSD btcl045611 1.6B NetBSD 1.6B (TECRA8100) #1: Tue Jul 2 22:21:39 BST 2002 nick@btcl045611:/dsk/home/nick/work/netbsd-current/src/sys/arch/i386/compile/TECRA8100 i386
Architecture: i386
Machine: i386
	The main problem is that USE_PTHREAD/ can't be used within files.

 	I played around with a patch (see below) from Chris Gilbert that
	introduces a BUILDLINK_USE_PTHREAD variable that can be checked
	against USE_PTHREAD, but this doesn't work if two pthreads enabled
	libraries are linked into a pkg.

RCS file: /cvsroot/pkgsrc/mk/,v
retrieving revision 1.5
diff -u -p -r1.5
---	2002/05/29 08:19:55	1.5
+++	2002/06/15 23:27:42
@@ -33,6 +33,12 @@
 # _PKG_PTHREADS is the list of package pthread implementations recognized by
+# BUILDLINK_USE_PTHREAD is a list of pthread implementations that may have
+#	been used to create the package, this is used in  Note
+#	that it is assumed that BUILDLINK_USE_PTHREAD will give the same
+#	result as USE_PTHREAD did for the initial package.  The value 
+#	derived from BUILDLINK_USE_PTHREAD is compared against PTHREAD_TYPE.
 .if defined(USE_PTHREAD)
 _PKG_PTHREADS?=		pth pth-syscall ptl2 mit-pthreads unproven-pthreads
@@ -102,3 +108,35 @@ DEPENDS+=		mit-pthreads-1.60b6:../../dev
 .endif	# BSD_PREFS_MK
+# This is a bit of sanity checking that BUILDLINK Files that pass in threads
+# all match up.
+.for __valid_buildlink_pthread__ in ${BUILDLINK_USE_PTHREAD}
+.  if !empty(_PKG_PTHREADS:M${__valid_buildlink_pthread__})
+_BUILDLINK_PTHREAD_TYPE?=	${__valid_buildlink_pthread__}
+.  endif
+# We check for a native pthread implementation by checking for the presence
+# of /usr/include/pthread.h (we might want to make this check stricter).
+.if !empty(BUILDLINK_USE_PTHREAD:Mnative)
+.  if exists(/usr/include/pthread.h)
+.  else
+.  endif
+# buildlink and main package thread packages don't match
+	@${ECHO} "Mismatch in required pthreads, main package uses ${PTHREAD_TYPE}, buildlink package uses ${BUILDLINK_PTHREAD_TYPE}";
+	@${FALSE};

	See pkg/17177, pkg/17272, pkg/17273, and pkg/17437
	Dunno. I think, though, that we should pick a userland pthreads
	package (pth - with hard syscalls?) as the non-nathanw_sa
	replacement. The logic can then be similar
	to how the MesaLib handling is done.