NetBSD Problem Report #58383

From www@netbsd.org  Sun Jun 30 18:55:43 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id D94841A923A
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 30 Jun 2024 18:55:43 +0000 (UTC)
Message-Id: <20240630185542.744EA1A923C@mollari.NetBSD.org>
Date: Sun, 30 Jun 2024 18:55:42 +0000 (UTC)
From: oshima-ya@yagoto-urayama.jp
Reply-To: oshima-ya@yagoto-urayama.jp
To: gnats-bugs@NetBSD.org
Subject: Cannot build databases/db4 on NetBSD/sh3 and cannot specify a 'posixmutexes' option when configure
X-Send-Pr-Version: www-1.0

>Number:         58383
>Category:       pkg
>Synopsis:       Cannot build databases/db4 on NetBSD/sh3 and cannot specify a 'posixmutexes' option when configure
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 30 19:00:01 +0000 2024
>Originator:     Yasushi Oshima
>Release:        pkgsrc-current
>Organization:
>Environment:
NetBSD usl5p 10.0_STABLE NetBSD 10.0_STABLE (GENERIC) #0: Fri Jun 28 03:34:19 JST 2024  oshima@sudachi:/export/netbsd-10/20240628/obj/landisk/sys/arch/landisk/compile/GENERIC landisk
>Description:
NetBSD/sh3 does not have HAVE_MUTEX_(arch)_GCC_ASSEMBLY in dbinc/mutex_int.h of db4, so db4 configure fails as below:

-----
checking for mutexes... UNIX/fcntl
configure: WARNING: NO SHARED LATCH IMPLEMENTATION FOUND FOR THIS PLATFORM
configure: Unable to find a mutex implementation
*** ERROR code 1
-----

So some pkgsrc pacakges that depends to db4 cannot build on NetBSD/sh3.

To fix this, it will be necessary to create a GCC_ASSEMBLY for sh3 in db4, just like any other arch.

However, by specifying --enable-posixmutexes in configure without creating a new code, it uses the POSIX standard mutexes of the pthread library which is provided as a standard library in all NetBSDs.
This option will not be checked automatically, so must be enabled manually.  

When add PKG_OPTIONS to be able to specify --enable-posixmutexes, it will be able to build on NetBSD/sh3.

In addition, an another arch which also does not have GCC_ASSEMBLY in db4 (ex. vax) will become buildable by posixmutexes, too.
If a new arch is added in NetBSD in the future, it will not be necessary to create a special assembly code in db4, as a GENERIC code.
(Of course, for performance or other reason, no problem to create a new code for a specific arch/cpu...)

However, db4's configure has a bug. This not to be able evaluate correctly the type of pthread implementation.

NetBSD's pthread does not have pthread_condattr_setpshared(), pthread_mutexattr_setpshared().
So, it is expected to be generated by configure as follows:

 #define	HAVE_MUTEX PTHREADS 1
 #define	HAVE_MUTEX_THREAD_ONLY 1

This is recognized to 'POSIX/pthreads/library/private' by 'configure --enable-posixmutexes'.
However it matches POSIX/pthreads* because the order of pthreads-style type in 'case' syntax. HAVE_MUTEX_THREAD_ONLY is not defined.

This reason, fix to db_cv_mutex case in configure.
The db5's configure has been fixed to be correct order.
The db4 is so old, it will be never fixed in upstream, just as everyone expected.

>How-To-Repeat:
In pkgsrc/databases/db4 on NetBSD/sh3(ex. landisk, hpcsh, ...)
   or NetBSD/vax

1. configure failed
 # make

2. build failed
 # make CONFIGURE_ARGS=--enable-posixmutexes

>Fix:
1. To add NEW option (for example:'posixmutexes') in options.mk for --enable-posixmutexes.
2. Add this to PKG_SUGGESTED_OPTIONS when sh3* or vax by default.
3. Fix the case for checking pthreads-style in configure.

An example is here:
https://github.com/oshimaya/pkgsrc/commit/e1d8cab7d349a1519e2e1869b6a1a1e80712f5e5

The 'posixmutexes' PKG_OPTION may be a good choice in databases/db5 and db6, however I have not used them, so no any test or verified it.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.