Subject: pthread + pkgsrc proposal
To: None <tech-pkg@NetBSD.org>
From: Johnny C. Lam <jlam@buildlink.org>
List: tech-pkg
Date: 11/24/2004 07:01:37
--bg08WKrSYDhXBjb5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
For pkgsrc, I will be making changes so that if the package uses
dlopen(), then it will be automatically linked with pthread support.
This follows the suggestion mentioned on tech-kern:
http://mail-index.netbsd.org/tech-kern/2004/11/23/0014.html
The precise description of what will happen is that a package should
include dlopen.buildlink3.mk in the package Makefile if it uses dlopen().
If there are native pthreads available, then the package will be
automatically built and linked with -pthread/-lpthread/-lc_r (depending
on the OS; gory details in pkgsrc/mk/pthread.{buildlink3,builtin}.mk).
On platforms that do not have native pthreads, pkgsrc can be forced
to follow this same behavior by setting DLOPEN_REQUIRE_PTHREADS=yes
in /etc/mk.conf.
I have initially modified the following packages to include
dlopen.buildlink3.mk:
lang/perl58
security/cyrus-sasl
security/cyrus-sasl2
www/apache
www/apache2
www/php4
www/ap-php
dlopen.buildlink3.mk should also be included by buildlink3.mk files
of packages with libraries that use dlopen(), e.g. security/cyrus-sasl2.
For example, on NetBSD-2.0, building www/apache will automatically
cause it to be linked with -pthread; however on NetBSD-1.6.2, it will
be built just as before. The lang/perl58-thread package will be removed
as lang/perl58 will simply be built with pthread support depending on
whether or not native pthreads are present. On NetBSD-1.6.2, we can
force using userland pthreads in packages that use dlopen() by setting
DLOPEN_REQUIRE_PTHREADS=yes in /etc/mk.conf.
These changes should fix the following PRs: 28343, 28359, 28398.
I have attached dlopen.buildlink3.mk and a diff of the changes I plan
on committing.
Comments?
Thanks,
-- Johnny Lam <jlam@buildlink.org>
--bg08WKrSYDhXBjb5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="dlopen.buildlink3.mk"
# $NetBSD$
#
# This Makefile fragment is included by package Makefiles and
# buildlink3.mk files for the packages that use dlopen().
#
# Packages that use dlopen() should be linked with pthread support or
# else they will core dump when they dlopen a shared module that _is_
# linked with pthread support. We automatically link with pthread
# support only if the pthreads are native.
#
# DLOPEN_REQUIRE_PTHREADS is a user-settable variable whose value
# decides whether pthread.buildlink3.mk is automatically included
# or not. If left unset, this file will provide a default value
# dependent on whether native pthreads exists. This variable
# should only be set in /etc/mk.conf and *not* in a package
# Makefile.
.include "../../mk/bsd.prefs.mk"
_DLOPEN_REQUIRE_PTHREADS?= no
.if exists(/usr/include/pthread.h) && \
!empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
. if empty(_DLOPEN_REQUIRE_PTHREADS:M[yY][eE][sS])
_DLOPEN_REQUIRE_PTHREADS= yes
. endif
.endif
DLOPEN_REQUIRE_PTHREADS?= ${_DLOPEN_REQUIRE_PTHREADS}
.if !empty(DLOPEN_REQUIRE_PTHREADS:M[yY][eE][sS])
. include "../../mk/pthread.buildlink3.mk"
.endif
--bg08WKrSYDhXBjb5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="dlopen.diff"
Index: mk/bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1540
diff -u -r1.1540 bsd.pkg.mk
--- mk/bsd.pkg.mk 17 Nov 2004 22:55:14 -0000 1.1540
+++ mk/bsd.pkg.mk 24 Nov 2004 06:55:54 -0000
@@ -306,17 +306,7 @@
_PERL5_DEPMETHOD= DEPENDS
. endif
_PERL5_DEPENDS= {perl>=${_PERL5_REQD},perl-thread>=${_PERL5_REQD}}
-#
-# On platforms that have native pthreads, default to installing the
-# threaded perl. This can be overridden by explicitly setting
-# PERL5_USE_THREADS.
-#
-. if exists(/usr/include/pthread.h) && \
- !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
-PERL5_PKGSRCDIR?= ../../lang/perl58-thread
-. else
PERL5_PKGSRCDIR?= ../../lang/perl58
-. endif
. if !defined(BUILDLINK_DEPENDS.perl)
${_PERL5_DEPMETHOD}+= ${_PERL5_DEPENDS}:${PERL5_PKGSRCDIR}
. endif
Index: lang/perl58/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/lang/perl58/Makefile,v
retrieving revision 1.61
diff -u -r1.61 Makefile
--- lang/perl58/Makefile 23 Nov 2004 17:32:36 -0000 1.61
+++ lang/perl58/Makefile 24 Nov 2004 06:55:55 -0000
@@ -8,19 +8,19 @@
.if empty(PERL5_SNAPSHOT) && empty(PERL5_RC_VERS)
DISTNAME= perl-${PERL5_VERS}
-PKGNAME= perl${PERL5_PKGSUFFIX}-${PERL5_VERS}
-PKGREVISION= 2
+PKGNAME= perl-${PERL5_VERS}
+PKGREVISION= 3
SNAPSHOT_SITES= # empty
.else
. if !empty(PERL5_SNAPSHOT)
DISTNAME= perl@${PERL5_SNAPSHOT}
-PKGNAME= perl${PERL5_PKGSUFFIX}-${PERL5_VERS}beta${PERL5_SNAPSHOT}
+PKGNAME= perl-${PERL5_VERS}beta${PERL5_SNAPSHOT}
SNAPSHOT_SITES= http://www.iki.fi/jhi/
EXTRACT_SUFX= .tbz
WRKSRC= ${WRKDIR}/perl
. else # !empty(PERL5_RC_VERS)
DISTNAME= perl-${PERL5_VERS}-RC${PERL5_RC_VERS}
-PKGNAME= perl${PERL5_PKGSUFFIX}-${PERL5_VERS}rc${PERL5_RC_VERS}
+PKGNAME= perl-${PERL5_VERS}rc${PERL5_RC_VERS}
SNAPSHOT_SITES= http://www.cpan.org/authors/id/J/JH/JHI/
. endif
.endif
@@ -39,7 +39,7 @@
p5-CGI-2.66 p5-CGI-2.75 p5-CGI-2.75.[0-2] \
p5-Data-Dumper-2.1[0-9][0-9] p5-Data-Dumper-[0-9][0-9] \
p5-Devel-DProf-[0-9]* p5-Devel-Peek-[0-9]* \
- perl-mk-[0-9]*
+ perl-mk-[0-9]* perl-thread-[0-9]*
PKG_INSTALLATION_TYPES= overwrite pkgviews
@@ -149,19 +149,14 @@
PERL5_HINTS_LDFLAGS+= ${LOCLIBRPATHFLAGS}
-# If perl58 is built with threads support, then name the package
-# "perl-thread", otherwise it's just "perl" as usual.
-#
-PERL5_USE_THREADS?= no
+.include "../../mk/dlopen.buildlink3.mk"
+
+PERL5_USE_THREADS?= ${DLOPEN_REQUIRE_PTHREADS}
.if !empty(PERL5_USE_THREADS:M[nN][oO])
-PERL5_PKGSUFFIX= # empty
-CONFLICTS+= perl-thread-[0-9]*
CONFIGURE_ARGS+= -Uuseithreads
.else
. include "../../mk/pthread.buildlink3.mk"
PERL5_ARCHLIB= ${PREFIX}/lib/perl5/${PERL5_VERS}/${MACHINE_ARCH}-${LOWER_OPSYS}-thread-multi
-PERL5_PKGSUFFIX= -thread
-CONFLICTS+= perl-[0-9]*
CONFIGURE_ARGS+= -Duseithreads
PERL5_HINTS_LDFLAGS+= ${PTHREAD_LDFLAGS}
PERL5_HINTS_LDDLFLAGS+= ${PTHREAD_LDFLAGS}
Index: security/cyrus-sasl/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/security/cyrus-sasl/Makefile,v
retrieving revision 1.46
diff -u -r1.46 Makefile
--- security/cyrus-sasl/Makefile 3 Oct 2004 00:18:08 -0000 1.46
+++ security/cyrus-sasl/Makefile 24 Nov 2004 06:55:55 -0000
@@ -2,7 +2,7 @@
.include "Makefile.common"
-PKGREVISION= 7
+PKGREVISION= 8
SVR4_PKGNAME= csasl
COMMENT= Simple Authentication and Security Layer
@@ -41,6 +41,9 @@
PLIST_SUBST+= GSSAPI="@comment "
.endif
+# Cyrus SASL mechanisms are loadable shared objects.
+.include "../../mk/dlopen.buildlink3.mk"
+
USE_PKGINSTALL= YES
DEINSTALL_EXTRA_TMPL+= ${.CURDIR}/DEINSTALL
INSTALL_EXTRA_TMPL+= ${.CURDIR}/INSTALL
Index: security/cyrus-sasl/buildlink3.mk
===================================================================
RCS file: /cvsroot/pkgsrc/security/cyrus-sasl/buildlink3.mk,v
retrieving revision 1.4
diff -u -r1.4 buildlink3.mk
--- security/cyrus-sasl/buildlink3.mk 3 Oct 2004 00:18:08 -0000 1.4
+++ security/cyrus-sasl/buildlink3.mk 24 Nov 2004 06:55:55 -0000
@@ -23,5 +23,6 @@
.if !empty(PKG_OPTIONS.cyrus-sasl:MPAM)
. include "../../security/PAM/buildlink3.mk"
.endif
+.include "../../mk/dlopen.buildlink3.mk"
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
Index: security/cyrus-sasl2/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/security/cyrus-sasl2/Makefile,v
retrieving revision 1.39
diff -u -r1.39 Makefile
--- security/cyrus-sasl2/Makefile 15 Nov 2004 21:58:16 -0000 1.39
+++ security/cyrus-sasl2/Makefile 24 Nov 2004 06:55:55 -0000
@@ -2,7 +2,7 @@
.include "Makefile.common"
-PKGREVISION= # empty
+PKGREVISION= 1
SVR4_PKGNAME= csasl
COMMENT= Simple Authentication and Security Layer
@@ -21,6 +21,9 @@
CONFIGURE_ARGS+= --with-dblib=${SASL_DBTYPE}
CONFIGURE_ARGS+= --with-dbpath=${PKG_SYSCONFDIR}/sasldb
+# Cyrus SASL mechanisms are loadable shared objects.
+.include "../../mk/dlopen.buildlink3.mk"
+
# Support using Cyrus saslauthd (security/cyrus-saslauthd) for plaintext
# password authentication.
#
Index: security/cyrus-sasl2/buildlink3.mk
===================================================================
RCS file: /cvsroot/pkgsrc/security/cyrus-sasl2/buildlink3.mk,v
retrieving revision 1.7
diff -u -r1.7 buildlink3.mk
--- security/cyrus-sasl2/buildlink3.mk 3 Oct 2004 00:18:08 -0000 1.7
+++ security/cyrus-sasl2/buildlink3.mk 24 Nov 2004 06:55:55 -0000
@@ -16,4 +16,6 @@
BUILDLINK_PKGSRCDIR.cyrus-sasl?= ../../security/cyrus-sasl2
.endif # CYRUS_SASL_BUILDLINK3_MK
+.include "../../mk/dlopen.buildlink3.mk"
+
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
Index: www/apache/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/www/apache/Makefile,v
retrieving revision 1.157
diff -u -r1.157 Makefile
--- www/apache/Makefile 22 Nov 2004 22:19:35 -0000 1.157
+++ www/apache/Makefile 24 Nov 2004 06:55:55 -0000
@@ -5,6 +5,7 @@
DISTNAME= apache_1.3.33
PKGNAME= ${DISTNAME:S/_/-/}
+PKGREVISION= 1
CATEGORIES= www
MASTER_SITES= ${MASTER_SITE_APACHE:=httpd/} \
${MASTER_SITE_APACHE:=httpd/old/}
@@ -162,6 +163,7 @@
.include "../../devel/libmm/buildlink3.mk"
.include "../../textproc/expat/buildlink3.mk"
.include "../../mk/bdb.buildlink3.mk"
+.include "../../mk/dlopen.buildlink3.mk"
post-extract:
@${CP} ${FILESDIR}/ap_include_extern.h ${WRKSRC}/src/include
Index: www/apache2/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/www/apache2/Makefile,v
retrieving revision 1.56
diff -u -r1.56 Makefile
--- www/apache2/Makefile 23 Nov 2004 00:37:04 -0000 1.56
+++ www/apache2/Makefile 24 Nov 2004 06:55:55 -0000
@@ -16,6 +16,7 @@
USE_BUILDLINK3= YES
USE_PKGINSTALL= YES
USE_LIBTOOL= YES
+USE_DLOPEN= YES
GNU_CONFIGURE= YES
CONFIGURE_ARGS+= --enable-layout=NetBSD
@@ -32,6 +33,7 @@
.include "../../devel/apr/buildlink3.mk"
.include "../../lang/perl5/buildlink3.mk"
.include "../../textproc/expat/buildlink3.mk"
+.include "../../mk/dlopen.buildlink3.mk"
# Set the "Multi-Processing Model" used by Apache to handle requests.
# Valid values are:
Index: www/php4/Makefile.php
===================================================================
RCS file: /cvsroot/pkgsrc/www/php4/Makefile.php,v
retrieving revision 1.18
diff -u -r1.18 Makefile.php
--- www/php4/Makefile.php 3 Oct 2004 00:18:27 -0000 1.18
+++ www/php4/Makefile.php 24 Nov 2004 06:55:55 -0000
@@ -3,7 +3,7 @@
.include "../../www/php4/Makefile.common"
# revision of the core PHP interepreter package
-PKGREVISION= 1
+PKGREVISION= 2
DISTINFO_FILE= ${.CURDIR}/../../www/php4/distinfo
PATCHDIR= ${.CURDIR}/../../www/php4/patches
@@ -55,3 +55,6 @@
. include "../../security/openssl/buildlink3.mk"
CONFIGURE_ARGS+= --with-openssl
.endif
+
+# PHP is designed to have loadable plugins to extend the PHP language.
+.include "../../mk/dlopen.buildlink3.mk"
--bg08WKrSYDhXBjb5--